summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore3
-rw-r--r--.travis.yml4
-rw-r--r--COPYRIGHT.txt57
-rw-r--r--README.md2
-rw-r--r--SConstruct60
-rw-r--r--core/SCsub6
-rw-r--r--core/bind/core_bind.cpp16
-rw-r--r--core/bind/core_bind.h5
-rw-r--r--core/core_string_names.cpp1
-rw-r--r--core/core_string_names.h1
-rw-r--r--core/dictionary.cpp21
-rw-r--r--core/dvector.h17
-rw-r--r--core/engine.cpp6
-rw-r--r--core/engine.h4
-rw-r--r--core/error_macros.h54
-rw-r--r--core/global_constants.cpp1
-rw-r--r--core/hash_map.h3
-rw-r--r--core/image.cpp54
-rw-r--r--core/image.h2
-rw-r--r--core/input_map.cpp16
-rw-r--r--core/io/compression.cpp36
-rw-r--r--core/io/compression.h8
-rw-r--r--core/io/file_access_memory.cpp6
-rw-r--r--core/io/file_access_network.cpp2
-rw-r--r--core/io/ip.cpp2
-rw-r--r--core/io/packet_peer.cpp4
-rw-r--r--core/io/resource_format_binary.cpp89
-rw-r--r--core/io/resource_import.cpp7
-rw-r--r--core/io/resource_loader.cpp19
-rw-r--r--core/io/resource_saver.cpp4
-rw-r--r--core/io/tcp_server.cpp2
-rw-r--r--core/io/translation_loader_po.cpp21
-rw-r--r--core/list.h14
-rw-r--r--core/map.h6
-rw-r--r--core/math/a_star.cpp7
-rw-r--r--core/math/a_star.h1
-rw-r--r--core/math/audio_frame.h10
-rw-r--r--core/math/camera_matrix.cpp124
-rw-r--r--core/math/camera_matrix.h2
-rw-r--r--core/math/face3.cpp8
-rw-r--r--core/math/face3.h24
-rw-r--r--core/math/matrix3.cpp7
-rw-r--r--core/math/quick_hull.cpp2
-rw-r--r--core/math/triangle_mesh.cpp2
-rw-r--r--core/math/vector3.cpp10
-rw-r--r--core/math/vector3.h10
-rw-r--r--core/message_queue.cpp4
-rw-r--r--core/method_ptrcall.h56
-rw-r--r--core/object.cpp39
-rw-r--r--core/object.h21
-rw-r--r--core/os/dir_access.cpp8
-rw-r--r--core/os/file_access.cpp8
-rw-r--r--core/os/input.cpp6
-rw-r--r--core/os/input_event.cpp2
-rw-r--r--core/os/keyboard.cpp2
-rw-r--r--core/os/keyboard.h1
-rw-r--r--core/os/main_loop.cpp2
-rw-r--r--core/os/os.cpp31
-rw-r--r--core/os/os.h20
-rw-r--r--core/project_settings.cpp (renamed from core/global_config.cpp)373
-rw-r--r--core/project_settings.h (renamed from core/global_config.h)35
-rw-r--r--core/reference.cpp3
-rw-r--r--core/reference.h6
-rw-r--r--core/register_core_types.cpp28
-rw-r--r--core/resource.cpp3
-rw-r--r--core/safe_refcount.cpp229
-rw-r--r--core/safe_refcount.h10
-rw-r--r--core/script_debugger_remote.cpp12
-rw-r--r--core/script_language.cpp12
-rw-r--r--core/script_language.h6
-rw-r--r--core/self_list.h19
-rw-r--r--core/sort.h10
-rw-r--r--core/translation.cpp8
-rw-r--r--core/variant_call.cpp2
-rw-r--r--core/variant_op.cpp16
-rw-r--r--core/variant_parser.cpp4
-rw-r--r--core/vector.h11
-rw-r--r--core/vmap.h6
-rw-r--r--doc/base/classes.xml3901
-rw-r--r--doc/tools/makerst.py25
-rw-r--r--drivers/alsa/audio_driver_alsa.cpp2
-rw-r--r--drivers/gles2/rasterizer_gles2.cpp18
-rw-r--r--drivers/gles2/rasterizer_gles2.h4
-rw-r--r--drivers/gles2/shaders/copy.glsl30
-rw-r--r--drivers/gles3/rasterizer_canvas_gles3.cpp132
-rw-r--r--drivers/gles3/rasterizer_canvas_gles3.h2
-rw-r--r--drivers/gles3/rasterizer_gles3.cpp15
-rw-r--r--drivers/gles3/rasterizer_scene_gles3.cpp271
-rw-r--r--drivers/gles3/rasterizer_scene_gles3.h49
-rw-r--r--drivers/gles3/rasterizer_storage_gles3.cpp407
-rw-r--r--drivers/gles3/rasterizer_storage_gles3.h29
-rw-r--r--drivers/gles3/shader_compiler_gles3.cpp23
-rw-r--r--drivers/gles3/shader_gles3.cpp4
-rw-r--r--drivers/gles3/shaders/copy.glsl13
-rw-r--r--drivers/gles3/shaders/cubemap_filter.glsl61
-rw-r--r--drivers/gles3/shaders/effect_blur.glsl10
-rw-r--r--drivers/gles3/shaders/particles.glsl4
-rw-r--r--drivers/gles3/shaders/resolve.glsl3
-rw-r--r--drivers/gles3/shaders/scene.glsl544
-rw-r--r--drivers/gles3/shaders/tonemap.glsl127
-rw-r--r--drivers/png/resource_saver_png.cpp2
-rw-r--r--drivers/pulseaudio/audio_driver_pulseaudio.cpp2
-rw-r--r--drivers/rtaudio/audio_driver_rtaudio.cpp2
-rw-r--r--drivers/unix/os_unix.cpp25
-rw-r--r--drivers/unix/os_unix.h4
-rw-r--r--drivers/xaudio2/audio_driver_xaudio2.cpp2
-rw-r--r--editor/SCsub192
-rw-r--r--editor/animation_editor.cpp1
-rw-r--r--editor/animation_editor.h1
-rw-r--r--editor/asset_library_editor_plugin.cpp28
-rw-r--r--editor/collada/collada.cpp8
-rw-r--r--editor/collada/collada.h2
-rw-r--r--editor/doc/doc_data.cpp10
-rw-r--r--editor/editor_about.cpp209
-rw-r--r--editor/editor_about.h70
-rw-r--r--editor/editor_audio_buses.cpp10
-rw-r--r--editor/editor_autoload_settings.cpp76
-rw-r--r--editor/editor_data.cpp22
-rw-r--r--editor/editor_data.h24
-rw-r--r--editor/editor_export.cpp83
-rw-r--r--editor/editor_export.h18
-rw-r--r--editor/editor_file_system.cpp27
-rw-r--r--editor/editor_help.cpp24
-rw-r--r--editor/editor_name_dialog.cpp1
-rw-r--r--editor/editor_node.cpp388
-rw-r--r--editor/editor_node.h21
-rw-r--r--editor/editor_plugin.cpp75
-rw-r--r--editor/editor_plugin.h14
-rw-r--r--editor/editor_plugin_settings.cpp4
-rw-r--r--editor/editor_resource_preview.cpp4
-rw-r--r--editor/editor_run.cpp12
-rw-r--r--editor/editor_run_script.cpp4
-rw-r--r--editor/editor_settings.cpp32
-rw-r--r--editor/editor_themes.cpp265
-rw-r--r--editor/file_type_cache.cpp6
-rw-r--r--editor/filesystem_dock.cpp12
-rw-r--r--editor/icons/2x/icon_GUI_checked.pngbin0 -> 516 bytes
-rw-r--r--editor/icons/2x/icon_GUI_dropdown.pngbin0 -> 183 bytes
-rw-r--r--editor/icons/2x/icon_GUI_hslider_bg.pngbin0 -> 124 bytes
-rw-r--r--editor/icons/2x/icon_GUI_hsplitter.pngbin0 -> 190 bytes
-rw-r--r--editor/icons/2x/icon_GUI_option_arrow.pngbin0 -> 304 bytes
-rw-r--r--editor/icons/2x/icon_GUI_play_button_group.pngbin0 -> 886 bytes
-rw-r--r--editor/icons/2x/icon_GUI_progress_bar.pngbin0 -> 289 bytes
-rw-r--r--editor/icons/2x/icon_GUI_progress_fill.pngbin0 -> 196 bytes
-rw-r--r--editor/icons/2x/icon_GUI_scroll_bg.pngbin0 -> 99 bytes
-rw-r--r--editor/icons/2x/icon_GUI_scroll_grabber.pngbin0 -> 193 bytes
-rw-r--r--editor/icons/2x/icon_GUI_scroll_grabber_hl.pngbin0 -> 297 bytes
-rw-r--r--editor/icons/2x/icon_GUI_slider_grabber.pngbin0 -> 260 bytes
-rw-r--r--editor/icons/2x/icon_GUI_slider_grabber_hl.pngbin0 -> 1040 bytes
-rw-r--r--editor/icons/2x/icon_GUI_spinbox_updown.pngbin0 -> 516 bytes
-rw-r--r--editor/icons/2x/icon_GUI_tab_menu.pngbin0 -> 221 bytes
-rw-r--r--editor/icons/2x/icon_GUI_toggle_off.pngbin0 -> 2606 bytes
-rw-r--r--editor/icons/2x/icon_GUI_toggle_on.pngbin0 -> 2178 bytes
-rw-r--r--editor/icons/2x/icon_GUI_tree_arrow_down.pngbin0 -> 256 bytes
-rw-r--r--editor/icons/2x/icon_GUI_tree_arrow_right.pngbin0 -> 263 bytes
-rw-r--r--editor/icons/2x/icon_GUI_unchecked.pngbin0 -> 369 bytes
-rw-r--r--editor/icons/2x/icon_GUI_vslider_bg.pngbin0 -> 131 bytes
-rw-r--r--editor/icons/2x/icon_GUI_vsplit_bg.pngbin0 -> 104 bytes
-rw-r--r--editor/icons/2x/icon_GUI_vsplitter.pngbin0 -> 168 bytes
-rw-r--r--editor/icons/2x/icon_animation_tree.pngbin421 -> 264 bytes
-rw-r--r--editor/icons/2x/icon_animation_tree_player.pngbin421 -> 264 bytes
-rw-r--r--editor/icons/2x/icon_audio_stream_player.png (renamed from editor/icons/2x/icon_audio_player.png)bin769 -> 769 bytes
-rw-r--r--editor/icons/2x/icon_audio_stream_player_2_d.pngbin0 -> 782 bytes
-rw-r--r--editor/icons/2x/icon_audio_stream_sample.pngbin0 -> 712 bytes
-rw-r--r--editor/icons/2x/icon_bit_map.pngbin148 -> 152 bytes
-rw-r--r--editor/icons/2x/icon_button.pngbin186 -> 456 bytes
-rw-r--r--editor/icons/2x/icon_button_group.pngbin251 -> 529 bytes
-rw-r--r--editor/icons/2x/icon_capsule_mesh.pngbin0 -> 767 bytes
-rw-r--r--editor/icons/2x/icon_color_rect.pngbin289 -> 285 bytes
-rw-r--r--editor/icons/2x/icon_confirmation_dialog.pngbin694 -> 614 bytes
-rw-r--r--editor/icons/2x/icon_cube_mesh.pngbin0 -> 681 bytes
-rw-r--r--editor/icons/2x/icon_curve.pngbin0 -> 607 bytes
-rw-r--r--editor/icons/2x/icon_cylinder_mesh.pngbin0 -> 650 bytes
-rw-r--r--editor/icons/2x/icon_debug.pngbin1018 -> 900 bytes
-rw-r--r--editor/icons/2x/icon_environment.pngbin1270 -> 1193 bytes
-rw-r--r--editor/icons/2x/icon_file_big.pngbin505 -> 934 bytes
-rw-r--r--editor/icons/2x/icon_file_dialog.pngbin342 -> 397 bytes
-rw-r--r--editor/icons/2x/icon_g_d_native_library.pngbin0 -> 677 bytes
-rw-r--r--editor/icons/2x/icon_godot.pngbin0 -> 1743 bytes
-rw-r--r--editor/icons/2x/icon_gradient.pngbin0 -> 249 bytes
-rw-r--r--editor/icons/2x/icon_grid_map.pngbin138 -> 378 bytes
-rw-r--r--editor/icons/2x/icon_gui_close_dark.pngbin0 -> 371 bytes
-rw-r--r--editor/icons/2x/icon_gui_close_light.pngbin0 -> 366 bytes
-rw-r--r--editor/icons/2x/icon_h_button_array.pngbin224 -> 470 bytes
-rw-r--r--editor/icons/2x/icon_h_scroll_bar.pngbin324 -> 688 bytes
-rw-r--r--editor/icons/2x/icon_h_slider.pngbin360 -> 424 bytes
-rw-r--r--editor/icons/2x/icon_help.pngbin1126 -> 654 bytes
-rw-r--r--editor/icons/2x/icon_help_search.pngbin0 -> 881 bytes
-rw-r--r--editor/icons/2x/icon_line_edit.pngbin323 -> 223 bytes
-rw-r--r--editor/icons/2x/icon_load.pngbin228 -> 523 bytes
-rw-r--r--editor/icons/2x/icon_multi_script.pngbin0 -> 586 bytes
-rw-r--r--editor/icons/2x/icon_nine_patch_rect.pngbin162 -> 163 bytes
-rw-r--r--editor/icons/2x/icon_open.pngbin228 -> 523 bytes
-rw-r--r--editor/icons/2x/icon_option_button.pngbin366 -> 527 bytes
-rw-r--r--editor/icons/2x/icon_panorama_sky.pngbin0 -> 661 bytes
-rw-r--r--editor/icons/2x/icon_plane_mesh.pngbin0 -> 535 bytes
-rw-r--r--editor/icons/2x/icon_prism_mesh.pngbin0 -> 612 bytes
-rw-r--r--editor/icons/2x/icon_procedural_sky.pngbin0 -> 639 bytes
-rw-r--r--editor/icons/2x/icon_quad_mesh.pngbin0 -> 291 bytes
-rw-r--r--editor/icons/2x/icon_reference_rect.pngbin160 -> 151 bytes
-rw-r--r--editor/icons/2x/icon_remote_transform.pngbin1140 -> 1003 bytes
-rw-r--r--editor/icons/2x/icon_remote_transform_2d.pngbin1197 -> 1044 bytes
-rw-r--r--editor/icons/2x/icon_slider_joint.pngbin180 -> 393 bytes
-rw-r--r--editor/icons/2x/icon_sphere_mesh.pngbin0 -> 979 bytes
-rw-r--r--editor/icons/2x/icon_texture_rect.pngbin201 -> 203 bytes
-rw-r--r--editor/icons/2x/icon_timer.pngbin909 -> 765 bytes
-rw-r--r--editor/icons/2x/icon_tool_button.pngbin425 -> 753 bytes
-rw-r--r--editor/icons/2x/icon_tools.pngbin759 -> 544 bytes
-rw-r--r--editor/icons/2x/icon_tree.pngbin417 -> 211 bytes
-rw-r--r--editor/icons/2x/icon_v_button_array.pngbin231 -> 461 bytes
-rw-r--r--editor/icons/2x/icon_v_scroll_bar.pngbin328 -> 791 bytes
-rw-r--r--editor/icons/2x/icon_v_slider.pngbin391 -> 442 bytes
-rw-r--r--editor/icons/2x/icon_variant.pngbin0 -> 398 bytes
-rw-r--r--editor/icons/2x/icon_video_player.pngbin501 -> 380 bytes
-rw-r--r--editor/icons/2x/icon_visual_script.pngbin707 -> 728 bytes
-rw-r--r--editor/icons/2x/icon_world_environment.pngbin1371 -> 1297 bytes
-rw-r--r--editor/icons/icon_GUI_checked.pngbin0 -> 341 bytes
-rw-r--r--editor/icons/icon_GUI_dropdown.pngbin0 -> 130 bytes
-rw-r--r--editor/icons/icon_GUI_hslider_bg.pngbin0 -> 105 bytes
-rw-r--r--editor/icons/icon_GUI_hsplitter.pngbin0 -> 132 bytes
-rw-r--r--editor/icons/icon_GUI_option_arrow.pngbin0 -> 205 bytes
-rw-r--r--editor/icons/icon_GUI_play_button_group.pngbin0 -> 427 bytes
-rw-r--r--editor/icons/icon_GUI_progress_bar.pngbin0 -> 183 bytes
-rw-r--r--editor/icons/icon_GUI_progress_fill.pngbin0 -> 139 bytes
-rw-r--r--editor/icons/icon_GUI_scroll_bg.pngbin0 -> 90 bytes
-rw-r--r--editor/icons/icon_GUI_scroll_grabber.pngbin0 -> 147 bytes
-rw-r--r--editor/icons/icon_GUI_scroll_grabber_hl.pngbin0 -> 176 bytes
-rw-r--r--editor/icons/icon_GUI_slider_grabber.pngbin0 -> 168 bytes
-rw-r--r--editor/icons/icon_GUI_slider_grabber_hl.pngbin0 -> 477 bytes
-rw-r--r--editor/icons/icon_GUI_spinbox_updown.pngbin0 -> 345 bytes
-rw-r--r--editor/icons/icon_GUI_tab_menu.pngbin0 -> 146 bytes
-rw-r--r--editor/icons/icon_GUI_toggle_off.pngbin0 -> 1143 bytes
-rw-r--r--editor/icons/icon_GUI_toggle_on.pngbin0 -> 1030 bytes
-rw-r--r--editor/icons/icon_GUI_tree_arrow_down.pngbin0 -> 170 bytes
-rw-r--r--editor/icons/icon_GUI_tree_arrow_right.pngbin0 -> 189 bytes
-rw-r--r--editor/icons/icon_GUI_unchecked.pngbin0 -> 231 bytes
-rw-r--r--editor/icons/icon_GUI_vslider_bg.pngbin0 -> 108 bytes
-rw-r--r--editor/icons/icon_GUI_vsplit_bg.pngbin0 -> 96 bytes
-rw-r--r--editor/icons/icon_GUI_vsplitter.pngbin0 -> 122 bytes
-rw-r--r--editor/icons/icon_animation_tree.pngbin291 -> 218 bytes
-rw-r--r--editor/icons/icon_animation_tree_player.pngbin291 -> 218 bytes
-rw-r--r--editor/icons/icon_audio_stream_player.pngbin0 -> 443 bytes
-rw-r--r--editor/icons/icon_audio_stream_player_2_d.pngbin0 -> 445 bytes
-rw-r--r--editor/icons/icon_audio_stream_sample.pngbin0 -> 425 bytes
-rw-r--r--editor/icons/icon_bit_map.pngbin113 -> 119 bytes
-rw-r--r--editor/icons/icon_button.pngbin163 -> 274 bytes
-rw-r--r--editor/icons/icon_button_group.pngbin165 -> 283 bytes
-rw-r--r--editor/icons/icon_capsule_mesh.pngbin0 -> 408 bytes
-rw-r--r--editor/icons/icon_color_rect.pngbin214 -> 232 bytes
-rw-r--r--editor/icons/icon_confirmation_dialog.pngbin330 -> 343 bytes
-rw-r--r--editor/icons/icon_cube_mesh.pngbin0 -> 447 bytes
-rw-r--r--editor/icons/icon_curve.pngbin315 -> 339 bytes
-rw-r--r--editor/icons/icon_cylinder_mesh.pngbin0 -> 364 bytes
-rw-r--r--editor/icons/icon_debug.pngbin492 -> 455 bytes
-rw-r--r--editor/icons/icon_environment.pngbin588 -> 506 bytes
-rw-r--r--editor/icons/icon_file_big.pngbin317 -> 509 bytes
-rw-r--r--editor/icons/icon_file_dialog.pngbin220 -> 241 bytes
-rw-r--r--editor/icons/icon_g_d_native_library.pngbin0 -> 360 bytes
-rw-r--r--editor/icons/icon_godot.pngbin0 -> 739 bytes
-rw-r--r--editor/icons/icon_gradient.pngbin0 -> 180 bytes
-rw-r--r--editor/icons/icon_grid_map.pngbin122 -> 268 bytes
-rw-r--r--editor/icons/icon_gui_close_dark.pngbin0 -> 171 bytes
-rw-r--r--editor/icons/icon_gui_close_light.pngbin0 -> 216 bytes
-rw-r--r--editor/icons/icon_h_button_array.pngbin0 -> 298 bytes
-rw-r--r--editor/icons/icon_h_scroll_bar.pngbin205 -> 381 bytes
-rw-r--r--editor/icons/icon_h_slider.pngbin204 -> 224 bytes
-rw-r--r--editor/icons/icon_help.pngbin578 -> 353 bytes
-rw-r--r--editor/icons/icon_help_search.pngbin0 -> 431 bytes
-rw-r--r--editor/icons/icon_line_edit.pngbin201 -> 152 bytes
-rw-r--r--editor/icons/icon_load.pngbin170 -> 271 bytes
-rw-r--r--editor/icons/icon_multi_script.pngbin0 -> 318 bytes
-rw-r--r--editor/icons/icon_nine_patch_rect.pngbin128 -> 142 bytes
-rw-r--r--editor/icons/icon_open.pngbin170 -> 271 bytes
-rw-r--r--editor/icons/icon_option_button.pngbin218 -> 324 bytes
-rw-r--r--editor/icons/icon_panorama_sky.pngbin0 -> 354 bytes
-rw-r--r--editor/icons/icon_plane_mesh.pngbin0 -> 328 bytes
-rw-r--r--editor/icons/icon_prism_mesh.pngbin0 -> 448 bytes
-rw-r--r--editor/icons/icon_procedural_sky.pngbin0 -> 339 bytes
-rw-r--r--editor/icons/icon_quad_mesh.pngbin0 -> 244 bytes
-rw-r--r--editor/icons/icon_reference_rect.pngbin128 -> 141 bytes
-rw-r--r--editor/icons/icon_remote_transform.pngbin530 -> 506 bytes
-rw-r--r--editor/icons/icon_remote_transform_2d.pngbin552 -> 542 bytes
-rw-r--r--editor/icons/icon_slider_joint.pngbin150 -> 247 bytes
-rw-r--r--editor/icons/icon_sphere_mesh.pngbin0 -> 495 bytes
-rw-r--r--editor/icons/icon_texture_rect.pngbin158 -> 166 bytes
-rw-r--r--editor/icons/icon_timer.pngbin447 -> 378 bytes
-rw-r--r--editor/icons/icon_tool_button.pngbin263 -> 400 bytes
-rw-r--r--editor/icons/icon_tools.pngbin392 -> 298 bytes
-rw-r--r--editor/icons/icon_tree.pngbin243 -> 151 bytes
-rw-r--r--editor/icons/icon_v_button_array.pngbin0 -> 278 bytes
-rw-r--r--editor/icons/icon_v_scroll_bar.pngbin218 -> 416 bytes
-rw-r--r--editor/icons/icon_v_slider.pngbin231 -> 244 bytes
-rw-r--r--editor/icons/icon_variant.pngbin240 -> 237 bytes
-rw-r--r--editor/icons/icon_video_player.pngbin302 -> 241 bytes
-rw-r--r--editor/icons/icon_visual_script.pngbin388 -> 386 bytes
-rw-r--r--editor/icons/icon_world_environment.pngbin578 -> 534 bytes
-rw-r--r--editor/icons/source/icon_2_d.svg (renamed from editor/icons/source/icon_dropdown.svg)42
-rw-r--r--editor/icons/source/icon_3_d.svg105
-rw-r--r--editor/icons/source/icon_GUI_checked.svg (renamed from editor/icons/source/icon_checked.svg)0
-rw-r--r--editor/icons/source/icon_GUI_dropdown.svg93
-rw-r--r--editor/icons/source/icon_GUI_hslider_bg.svg (renamed from editor/icons/source/icon_hslider_bg.svg)34
-rw-r--r--editor/icons/source/icon_GUI_hsplitter.svg (renamed from editor/icons/source/icon_hsplitter.svg)0
-rw-r--r--editor/icons/source/icon_GUI_option_arrow.svg (renamed from editor/icons/source/icon_option_arrow.svg)0
-rw-r--r--editor/icons/source/icon_GUI_play_button_group.svg (renamed from editor/icons/source/icon_play_button_group.svg)0
-rw-r--r--editor/icons/source/icon_GUI_progress_bar.svg81
-rw-r--r--editor/icons/source/icon_GUI_progress_fill.svg (renamed from editor/icons/source/icon_vslider_bg.svg)36
-rw-r--r--editor/icons/source/icon_GUI_scroll_bg.svg (renamed from editor/icons/source/icon_scroll_bg.svg)0
-rw-r--r--editor/icons/source/icon_GUI_scroll_grabber.svg (renamed from editor/icons/source/icon_scroll_grabber.svg)0
-rw-r--r--editor/icons/source/icon_GUI_scroll_grabber_hl.svg (renamed from editor/icons/source/icon_scroll_grabber_hl.svg)0
-rw-r--r--editor/icons/source/icon_GUI_slider_grabber.svg (renamed from editor/icons/source/icon_slider_grabber.svg)31
-rw-r--r--editor/icons/source/icon_GUI_slider_grabber_hl.svg86
-rw-r--r--editor/icons/source/icon_GUI_spinbox_updown.svg (renamed from editor/icons/source/icon_spinbox_updown.svg)0
-rw-r--r--editor/icons/source/icon_GUI_tab_menu.svg (renamed from editor/icons/source/icon_tab_menu.svg)0
-rw-r--r--editor/icons/source/icon_GUI_toggle_off.svg80
-rw-r--r--editor/icons/source/icon_GUI_toggle_on.svg80
-rw-r--r--editor/icons/source/icon_GUI_tree_arrow_down.svg (renamed from editor/icons/source/icon_tree_arrow_down.svg)0
-rw-r--r--editor/icons/source/icon_GUI_tree_arrow_right.svg (renamed from editor/icons/source/icon_tree_arrow_right.svg)0
-rw-r--r--editor/icons/source/icon_GUI_unchecked.svg (renamed from editor/icons/source/icon_unchecked.svg)0
-rw-r--r--editor/icons/source/icon_GUI_vslider_bg.svg83
-rw-r--r--editor/icons/source/icon_GUI_vsplit_bg.svg (renamed from editor/icons/source/icon_vsplit_bg.svg)0
-rw-r--r--editor/icons/source/icon_GUI_vsplitter.svg (renamed from editor/icons/source/icon_vsplitter.svg)0
-rw-r--r--editor/icons/source/icon_animation_tree_player.svg8
-rw-r--r--editor/icons/source/icon_audio_stream_player.svg (renamed from editor/icons/source/icon_audio_player.svg)0
-rw-r--r--editor/icons/source/icon_audio_stream_player_2_d.svg114
-rw-r--r--editor/icons/source/icon_audio_stream_sample.svg108
-rw-r--r--editor/icons/source/icon_bit_map.svg12
-rw-r--r--editor/icons/source/icon_button.svg66
-rw-r--r--editor/icons/source/icon_button_group.svg118
-rw-r--r--editor/icons/source/icon_capsule_mesh.svg93
-rw-r--r--editor/icons/source/icon_color_rect.svg44
-rw-r--r--editor/icons/source/icon_confirmation_dialog.svg16
-rw-r--r--editor/icons/source/icon_cube_mesh.svg87
-rw-r--r--editor/icons/source/icon_curve.svg (renamed from editor/icons/source/icon_sample_player_2d.svg)27
-rw-r--r--editor/icons/source/icon_cylinder_mesh.svg89
-rw-r--r--editor/icons/source/icon_debug.svg72
-rw-r--r--editor/icons/source/icon_environment.svg41
-rw-r--r--editor/icons/source/icon_file_big.svg28
-rw-r--r--editor/icons/source/icon_file_dialog.svg20
-rw-r--r--editor/icons/source/icon_g_d_native_library.svg83
-rw-r--r--editor/icons/source/icon_godot.svg176
-rw-r--r--editor/icons/source/icon_godot_docs.svg173
-rw-r--r--editor/icons/source/icon_gradient.svg (renamed from editor/icons/source/icon_image_sky_box.svg)139
-rw-r--r--editor/icons/source/icon_grid_map.svg82
-rw-r--r--editor/icons/source/icon_gui_close_dark.svg79
-rw-r--r--editor/icons/source/icon_gui_close_light.svg79
-rw-r--r--editor/icons/source/icon_h_button_array.svg54
-rw-r--r--editor/icons/source/icon_h_scroll_bar.svg32
-rw-r--r--editor/icons/source/icon_h_slider.svg65
-rw-r--r--editor/icons/source/icon_help.svg50
-rw-r--r--editor/icons/source/icon_help_search.svg91
-rw-r--r--editor/icons/source/icon_line_edit.svg30
-rw-r--r--editor/icons/source/icon_mini_matrix32.svg145
-rw-r--r--editor/icons/source/icon_multi_script.svg83
-rw-r--r--editor/icons/source/icon_nine_patch_rect.svg44
-rw-r--r--editor/icons/source/icon_option_button.svg18
-rw-r--r--editor/icons/source/icon_panorama_sky.svg131
-rw-r--r--editor/icons/source/icon_particles_shader.svg159
-rw-r--r--editor/icons/source/icon_patch_9_rect.svg130
-rw-r--r--editor/icons/source/icon_plane_mesh.svg (renamed from editor/icons/source/icon_sample_player.svg)21
-rw-r--r--editor/icons/source/icon_prism_mesh.svg79
-rw-r--r--editor/icons/source/icon_procedural_sky.svg129
-rw-r--r--editor/icons/source/icon_quad_mesh.svg79
-rw-r--r--editor/icons/source/icon_reference_rect.svg84
-rw-r--r--editor/icons/source/icon_remote_transform.svg94
-rw-r--r--editor/icons/source/icon_remote_transform_2d.svg88
-rw-r--r--editor/icons/source/icon_sample.svg128
-rw-r--r--editor/icons/source/icon_slider_grabber_hl.svg80
-rw-r--r--editor/icons/source/icon_slider_joint.svg45
-rw-r--r--editor/icons/source/icon_spatial_shader.svg165
-rw-r--r--editor/icons/source/icon_sphere_mesh.svg79
-rw-r--r--editor/icons/source/icon_texture.svg137
-rw-r--r--editor/icons/source/icon_texture_rect.svg43
-rw-r--r--editor/icons/source/icon_timer.svg69
-rw-r--r--editor/icons/source/icon_tool_button.svg66
-rw-r--r--editor/icons/source/icon_tools.svg22
-rw-r--r--editor/icons/source/icon_tree.svg83
-rw-r--r--editor/icons/source/icon_v_button_array.svg47
-rw-r--r--editor/icons/source/icon_v_scroll_bar.svg35
-rw-r--r--editor/icons/source/icon_v_slider.svg52
-rw-r--r--editor/icons/source/icon_variant.svg146
-rw-r--r--editor/icons/source/icon_video_player.svg49
-rw-r--r--editor/icons/source/icon_visual_script.svg28
-rw-r--r--editor/icons/source/icon_world_environment.svg59
-rw-r--r--editor/import/editor_import_collada.cpp12
-rw-r--r--editor/import/resource_importer_obj.cpp341
-rw-r--r--editor/import/resource_importer_obj.h25
-rw-r--r--editor/import/resource_importer_scene.cpp118
-rw-r--r--editor/import/resource_importer_scene.h13
-rw-r--r--editor/import/resource_importer_texture.cpp18
-rw-r--r--editor/import/resource_importer_wav.cpp11
-rw-r--r--editor/import_dock.cpp70
-rw-r--r--editor/import_dock.h7
-rw-r--r--editor/io_plugins/editor_export_scene.cpp4
-rw-r--r--editor/io_plugins/editor_scene_import_plugin.cpp12
-rw-r--r--editor/io_plugins/editor_texture_import_plugin.cpp4
-rw-r--r--editor/plugins/animation_player_editor_plugin.cpp8
-rw-r--r--editor/plugins/animation_tree_editor_plugin.cpp9
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp467
-rw-r--r--editor/plugins/canvas_item_editor_plugin.h12
-rw-r--r--editor/plugins/collision_polygon_2d_editor_plugin.cpp12
-rw-r--r--editor/plugins/collision_polygon_editor_plugin.cpp638
-rw-r--r--editor/plugins/collision_polygon_editor_plugin.h18
-rw-r--r--editor/plugins/curve_editor_plugin.cpp73
-rw-r--r--editor/plugins/curve_editor_plugin.h7
-rw-r--r--editor/plugins/editor_preview_plugins.cpp8
-rw-r--r--editor/plugins/item_list_editor_plugin.cpp40
-rw-r--r--editor/plugins/item_list_editor_plugin.h29
-rw-r--r--editor/plugins/light_occluder_2d_editor_plugin.cpp12
-rw-r--r--editor/plugins/line_2d_editor_plugin.cpp4
-rw-r--r--editor/plugins/mesh_editor_plugin.cpp165
-rw-r--r--editor/plugins/mesh_editor_plugin.h23
-rw-r--r--editor/plugins/mesh_instance_editor_plugin.cpp2
-rw-r--r--editor/plugins/navigation_polygon_editor_plugin.cpp10
-rw-r--r--editor/plugins/path_2d_editor_plugin.cpp8
-rw-r--r--editor/plugins/path_editor_plugin.cpp6
-rw-r--r--editor/plugins/polygon_2d_editor_plugin.cpp10
-rw-r--r--editor/plugins/resource_preloader_editor_plugin.cpp2
-rw-r--r--editor/plugins/sample_editor_plugin.cpp2
-rw-r--r--editor/plugins/sample_library_editor_plugin.cpp2
-rw-r--r--editor/plugins/script_editor_plugin.cpp113
-rw-r--r--editor/plugins/script_editor_plugin.h15
-rw-r--r--editor/plugins/script_text_editor.cpp7
-rw-r--r--editor/plugins/script_text_editor.h2
-rw-r--r--editor/plugins/shader_graph_editor_plugin.cpp2
-rw-r--r--editor/plugins/spatial_editor_plugin.cpp165
-rw-r--r--editor/plugins/spatial_editor_plugin.h1
-rw-r--r--editor/plugins/sprite_frames_editor_plugin.cpp2
-rw-r--r--editor/plugins/texture_editor_plugin.cpp2
-rw-r--r--editor/plugins/theme_editor_plugin.cpp59
-rw-r--r--editor/plugins/theme_editor_plugin.h3
-rw-r--r--editor/plugins/tile_set_editor_plugin.cpp23
-rw-r--r--editor/project_export.cpp79
-rw-r--r--editor/project_export.h9
-rw-r--r--editor/project_manager.cpp45
-rw-r--r--editor/project_settings_editor.cpp (renamed from editor/project_settings.cpp)454
-rw-r--r--editor/project_settings_editor.h (renamed from editor/project_settings.h)16
-rw-r--r--editor/property_editor.cpp93
-rw-r--r--editor/property_editor.h8
-rw-r--r--editor/property_selector.cpp2
-rw-r--r--editor/resources_dock.cpp4
-rw-r--r--editor/scene_tree_dock.cpp148
-rw-r--r--editor/scene_tree_dock.h11
-rw-r--r--editor/scene_tree_editor.cpp173
-rw-r--r--editor/scene_tree_editor.h14
-rw-r--r--editor/script_create_dialog.cpp55
-rw-r--r--editor/script_create_dialog.h2
-rw-r--r--editor/script_editor_debugger.cpp31
-rw-r--r--editor/settings_config_dialog.cpp8
-rw-r--r--editor/spatial_editor_gizmos.cpp135
-rw-r--r--editor/spatial_editor_gizmos.h19
-rw-r--r--main/input_default.cpp1
-rw-r--r--main/main.cpp214
-rw-r--r--main/tests/test_io.cpp10
-rw-r--r--methods.py14
-rw-r--r--misc/scripts/svgs_2_pngs.py6
-rw-r--r--modules/etc/config.py6
-rw-r--r--modules/etc/image_etc.cpp4
-rw-r--r--modules/gdnative/gdnative.cpp1311
-rw-r--r--modules/gdnative/gdnative.h396
-rw-r--r--modules/gdnative/godot/array.cpp (renamed from modules/gdnative/godot/godot_array.cpp)4
-rw-r--r--modules/gdnative/godot/array.h (renamed from modules/gdnative/godot/godot_array.h)15
-rw-r--r--modules/gdnative/godot/basis.cpp (renamed from modules/gdnative/godot/godot_basis.cpp)4
-rw-r--r--modules/gdnative/godot/basis.h (renamed from modules/gdnative/godot/godot_basis.h)13
-rw-r--r--modules/gdnative/godot/color.cpp (renamed from modules/gdnative/godot/godot_color.cpp)4
-rw-r--r--modules/gdnative/godot/color.h (renamed from modules/gdnative/godot/godot_color.h)12
-rw-r--r--modules/gdnative/godot/dictionary.cpp (renamed from modules/gdnative/godot/godot_dictionary.cpp)12
-rw-r--r--modules/gdnative/godot/dictionary.h (renamed from modules/gdnative/godot/godot_dictionary.h)16
-rw-r--r--modules/gdnative/godot/gdnative.cpp (renamed from modules/gdnative/godot.cpp)79
-rw-r--r--modules/gdnative/godot/gdnative.h303
-rw-r--r--modules/gdnative/godot/icon.png.import23
-rw-r--r--modules/gdnative/godot/node_path.cpp (renamed from modules/gdnative/godot/godot_node_path.cpp)4
-rw-r--r--modules/gdnative/godot/node_path.h (renamed from modules/gdnative/godot/godot_node_path.h)12
-rw-r--r--modules/gdnative/godot/plane.cpp (renamed from modules/gdnative/godot/godot_plane.cpp)4
-rw-r--r--modules/gdnative/godot/plane.h (renamed from modules/gdnative/godot/godot_plane.h)12
-rw-r--r--modules/gdnative/godot/pool_arrays.cpp (renamed from modules/gdnative/godot/godot_pool_arrays.cpp)10
-rw-r--r--modules/gdnative/godot/pool_arrays.h (renamed from modules/gdnative/godot/godot_pool_arrays.h)61
-rw-r--r--modules/gdnative/godot/quat.cpp (renamed from modules/gdnative/godot/godot_quat.cpp)4
-rw-r--r--modules/gdnative/godot/quat.h (renamed from modules/gdnative/godot/godot_quat.h)12
-rw-r--r--modules/gdnative/godot/rect2.cpp (renamed from modules/gdnative/godot/godot_rect2.cpp)4
-rw-r--r--modules/gdnative/godot/rect2.h (renamed from modules/gdnative/godot/godot_rect2.h)6
-rw-r--r--modules/gdnative/godot/rect3.cpp (renamed from modules/gdnative/godot/godot_rect3.cpp)4
-rw-r--r--modules/gdnative/godot/rect3.h (renamed from modules/gdnative/godot/godot_rect3.h)14
-rw-r--r--modules/gdnative/godot/rid.cpp (renamed from modules/gdnative/godot/godot_rid.cpp)4
-rw-r--r--modules/gdnative/godot/rid.h (renamed from modules/gdnative/godot/godot_rid.h)10
-rw-r--r--modules/gdnative/godot/string.cpp (renamed from modules/gdnative/godot/godot_string.cpp)4
-rw-r--r--modules/gdnative/godot/string.h (renamed from modules/gdnative/godot/godot_string.h)11
-rw-r--r--modules/gdnative/godot/transform.cpp (renamed from modules/gdnative/godot/godot_transform.cpp)4
-rw-r--r--modules/gdnative/godot/transform.h (renamed from modules/gdnative/godot/godot_transform.h)16
-rw-r--r--modules/gdnative/godot/transform2d.cpp (renamed from modules/gdnative/godot/godot_transform2d.cpp)4
-rw-r--r--modules/gdnative/godot/transform2d.h (renamed from modules/gdnative/godot/godot_transform2d.h)14
-rw-r--r--modules/gdnative/godot/variant.cpp (renamed from modules/gdnative/godot/godot_variant.cpp)4
-rw-r--r--modules/gdnative/godot/variant.h (renamed from modules/gdnative/godot/godot_variant.h)47
-rw-r--r--modules/gdnative/godot/vector2.cpp (renamed from modules/gdnative/godot/godot_vector2.cpp)4
-rw-r--r--modules/gdnative/godot/vector2.h (renamed from modules/gdnative/godot/godot_vector2.h)10
-rw-r--r--modules/gdnative/godot/vector3.cpp (renamed from modules/gdnative/godot/godot_vector3.cpp)9
-rw-r--r--modules/gdnative/godot/vector3.h (renamed from modules/gdnative/godot/godot_vector3.h)14
-rw-r--r--modules/gdnative/register_types.cpp55
-rw-r--r--modules/gdscript/gd_editor.cpp24
-rw-r--r--modules/gdscript/gd_function.cpp34
-rw-r--r--modules/gdscript/gd_functions.cpp4
-rw-r--r--modules/gdscript/gd_parser.cpp86
-rw-r--r--modules/gdscript/gd_script.cpp10
-rw-r--r--modules/gdscript/gd_tokenizer.cpp318
-rw-r--r--modules/gdscript/gd_tokenizer.h3
-rw-r--r--modules/gridmap/grid_map.cpp1
-rw-r--r--modules/nativescript/SCsub10
-rw-r--r--modules/nativescript/api_generator.cpp (renamed from modules/gdnative/api_generator.cpp)6
-rw-r--r--modules/nativescript/api_generator.h (renamed from modules/gdnative/api_generator.h)0
-rw-r--r--modules/nativescript/config.py8
-rw-r--r--modules/nativescript/godot_nativescript.cpp205
-rw-r--r--modules/nativescript/godot_nativescript.h (renamed from modules/gdnative/godot.h)267
-rw-r--r--modules/nativescript/nativescript.cpp1232
-rw-r--r--modules/nativescript/nativescript.h317
-rw-r--r--modules/nativescript/register_types.cpp124
-rw-r--r--modules/nativescript/register_types.h31
-rw-r--r--modules/openssl/stream_peer_openssl.cpp4
-rw-r--r--modules/openssl/stream_peer_openssl.h2
-rw-r--r--modules/stb_vorbis/audio_stream_ogg_vorbis.cpp2
-rw-r--r--modules/theora/video_stream_theora.cpp4
-rw-r--r--modules/tinyexr/config.py6
-rw-r--r--modules/visual_script/register_types.cpp1
-rw-r--r--modules/visual_script/visual_script.cpp28
-rw-r--r--modules/visual_script/visual_script.h2
-rw-r--r--modules/visual_script/visual_script_editor.cpp324
-rw-r--r--modules/visual_script/visual_script_editor.h24
-rw-r--r--modules/visual_script/visual_script_expression.cpp16
-rw-r--r--modules/visual_script/visual_script_flow_control.cpp45
-rw-r--r--modules/visual_script/visual_script_flow_control.h3
-rw-r--r--modules/visual_script/visual_script_func_nodes.cpp345
-rw-r--r--modules/visual_script/visual_script_func_nodes.h30
-rw-r--r--modules/visual_script/visual_script_nodes.cpp227
-rw-r--r--modules/visual_script/visual_script_nodes.h35
-rw-r--r--modules/visual_script/visual_script_yield_nodes.cpp14
-rw-r--r--modules/webm/video_stream_webm.cpp4
-rw-r--r--platform/android/audio_driver_jandroid.cpp2
-rw-r--r--platform/android/detect.py154
-rw-r--r--platform/android/export/export.cpp77
-rw-r--r--platform/android/globals/global_defaults.cpp4
-rw-r--r--platform/android/godot_android.cpp8
-rw-r--r--platform/android/java/src/org/godotengine/godot/Godot.java2
-rw-r--r--platform/android/java_glue.cpp16
-rw-r--r--platform/android/os_android.cpp8
-rw-r--r--platform/android/os_android.h1
-rw-r--r--platform/haiku/audio_driver_media_kit.cpp2
-rw-r--r--platform/haiku/detect.py51
-rw-r--r--platform/haiku/os_haiku.cpp5
-rw-r--r--platform/haiku/os_haiku.h2
-rw-r--r--platform/iphone/SCsub9
-rw-r--r--platform/iphone/app_delegate.mm17
-rw-r--r--platform/iphone/detect.py180
-rw-r--r--platform/iphone/export/export.cpp366
-rw-r--r--platform/iphone/export/export.h30
-rw-r--r--platform/iphone/gl_view.mm4
-rw-r--r--platform/iphone/globals/global_defaults.cpp4
-rw-r--r--platform/iphone/ios.mm2
-rw-r--r--platform/iphone/os_iphone.cpp26
-rw-r--r--platform/iphone/os_iphone.h1
-rw-r--r--platform/javascript/SCsub41
-rw-r--r--platform/javascript/detect.py62
-rw-r--r--platform/javascript/export/export.cpp12
-rw-r--r--platform/javascript/godot_shell.html6
-rw-r--r--platform/javascript/os_javascript.cpp128
-rw-r--r--platform/javascript/os_javascript.h2
-rw-r--r--platform/osx/audio_driver_osx.cpp175
-rw-r--r--platform/osx/audio_driver_osx.h8
-rw-r--r--platform/osx/detect.py70
-rw-r--r--platform/osx/export/export.cpp363
-rw-r--r--platform/osx/os_osx.h8
-rw-r--r--platform/osx/os_osx.mm362
-rw-r--r--platform/server/detect.py78
-rw-r--r--platform/uwp/detect.py107
-rw-r--r--platform/uwp/export/export.cpp2179
-rw-r--r--platform/uwp/os_uwp.cpp9
-rw-r--r--platform/uwp/os_uwp.h2
-rw-r--r--platform/windows/detect.py283
-rw-r--r--platform/windows/export/export.cpp1
-rw-r--r--platform/windows/os_windows.cpp141
-rw-r--r--platform/windows/os_windows.h6
-rw-r--r--platform/x11/detect.py151
-rw-r--r--platform/x11/export/export.cpp1
-rw-r--r--platform/x11/godot_x11.cpp3
-rw-r--r--platform/x11/key_mapping_x11.cpp1
-rw-r--r--platform/x11/os_x11.cpp247
-rw-r--r--platform/x11/os_x11.h9
-rw-r--r--platform/x11/power_x11.cpp11
-rw-r--r--scene/2d/animated_sprite.cpp6
-rw-r--r--scene/2d/area_2d.cpp7
-rw-r--r--scene/2d/canvas_item.cpp29
-rw-r--r--scene/2d/canvas_item.h2
-rw-r--r--scene/2d/collision_object_2d.cpp33
-rw-r--r--scene/2d/collision_object_2d.h3
-rw-r--r--scene/2d/collision_shape_2d.cpp4
-rw-r--r--scene/2d/light_2d.cpp4
-rw-r--r--scene/2d/line_2d.cpp8
-rw-r--r--scene/2d/node_2d.cpp17
-rw-r--r--scene/2d/node_2d.h3
-rw-r--r--scene/2d/physics_body_2d.cpp5
-rw-r--r--scene/2d/polygon_2d.cpp4
-rw-r--r--scene/2d/remote_transform_2d.cpp101
-rw-r--r--scene/2d/remote_transform_2d.h17
-rw-r--r--scene/2d/screen_button.cpp16
-rw-r--r--scene/2d/sprite.cpp13
-rw-r--r--scene/2d/tile_map.cpp8
-rw-r--r--scene/3d/area.cpp129
-rw-r--r--scene/3d/area.h28
-rw-r--r--scene/3d/arvr_nodes.cpp313
-rw-r--r--scene/3d/arvr_nodes.h126
-rw-r--r--scene/3d/audio_stream_player_3d.cpp930
-rw-r--r--scene/3d/audio_stream_player_3d.h175
-rw-r--r--scene/3d/body_shape.cpp920
-rw-r--r--scene/3d/camera.cpp40
-rw-r--r--scene/3d/camera.h16
-rw-r--r--scene/3d/collision_object.cpp313
-rw-r--r--scene/3d/collision_object.h58
-rw-r--r--scene/3d/collision_polygon.cpp237
-rw-r--r--scene/3d/collision_polygon.h29
-rw-r--r--scene/3d/collision_shape.cpp214
-rw-r--r--scene/3d/collision_shape.h (renamed from scene/3d/body_shape.h)38
-rw-r--r--scene/3d/gi_probe.cpp46
-rw-r--r--scene/3d/gi_probe.h11
-rw-r--r--scene/3d/light.cpp2
-rw-r--r--scene/3d/mesh_instance.cpp108
-rw-r--r--scene/3d/mesh_instance.h2
-rw-r--r--scene/3d/multimesh_instance.cpp4
-rw-r--r--scene/3d/navigation_mesh.cpp8
-rw-r--r--scene/3d/physics_body.cpp573
-rw-r--r--scene/3d/physics_body.h107
-rw-r--r--scene/3d/portal.cpp2
-rw-r--r--scene/3d/reflection_probe.cpp2
-rw-r--r--scene/3d/remote_transform.cpp96
-rw-r--r--scene/3d/remote_transform.h17
-rw-r--r--scene/3d/room_instance.cpp2
-rw-r--r--scene/3d/skeleton.cpp2
-rw-r--r--scene/3d/spatial.cpp30
-rw-r--r--scene/3d/spatial.h3
-rw-r--r--scene/3d/spatial_velocity_tracker.cpp104
-rw-r--r--scene/3d/spatial_velocity_tracker.h31
-rw-r--r--scene/audio/audio_player.cpp2
-rw-r--r--scene/gui/base_button.cpp8
-rw-r--r--scene/gui/button.cpp9
-rw-r--r--scene/gui/color_picker.cpp46
-rw-r--r--scene/gui/color_picker.h2
-rw-r--r--scene/gui/container.cpp18
-rw-r--r--scene/gui/control.cpp114
-rw-r--r--scene/gui/control.h24
-rw-r--r--scene/gui/dialogs.cpp6
-rw-r--r--scene/gui/gradient_edit.cpp4
-rw-r--r--scene/gui/graph_edit.cpp24
-rw-r--r--scene/gui/graph_edit.h2
-rw-r--r--scene/gui/item_list.cpp88
-rw-r--r--scene/gui/item_list.h11
-rw-r--r--scene/gui/label.cpp24
-rw-r--r--scene/gui/line_edit.cpp27
-rw-r--r--scene/gui/option_button.cpp21
-rw-r--r--scene/gui/patch_9_rect.cpp4
-rw-r--r--scene/gui/popup_menu.cpp25
-rw-r--r--scene/gui/popup_menu.h1
-rw-r--r--scene/gui/range.cpp6
-rw-r--r--scene/gui/rich_text_label.cpp35
-rw-r--r--scene/gui/rich_text_label.h6
-rw-r--r--scene/gui/slider.cpp29
-rw-r--r--scene/gui/slider.h4
-rw-r--r--scene/gui/spin_box.cpp2
-rw-r--r--scene/gui/split_container.cpp22
-rw-r--r--scene/gui/tabs.cpp71
-rw-r--r--scene/gui/tabs.h15
-rw-r--r--scene/gui/text_edit.cpp13
-rw-r--r--scene/gui/texture_button.cpp2
-rw-r--r--scene/gui/texture_progress.cpp12
-rw-r--r--scene/gui/texture_rect.cpp4
-rw-r--r--scene/gui/tree.cpp54
-rw-r--r--scene/gui/tree.h9
-rw-r--r--scene/io/resource_format_image.cpp4
-rwxr-xr-xscene/main/node.cpp113
-rw-r--r--scene/main/node.h21
-rw-r--r--scene/main/resource_preloader.cpp4
-rw-r--r--scene/main/scene_tree.cpp70
-rw-r--r--scene/main/scene_tree.h4
-rw-r--r--scene/main/viewport.cpp36
-rw-r--r--scene/main/viewport.h5
-rw-r--r--scene/register_scene_types.cpp28
-rw-r--r--scene/resources/audio_stream_resampled.cpp2
-rw-r--r--scene/resources/audio_stream_sample.cpp2
-rw-r--r--scene/resources/bit_mask.cpp2
-rw-r--r--scene/resources/curve.cpp8
-rw-r--r--scene/resources/curve.h4
-rw-r--r--scene/resources/default_theme/default_theme.cpp14
-rw-r--r--scene/resources/default_theme/hslider_grabber_disabled.pngbin0 -> 386 bytes
-rw-r--r--scene/resources/default_theme/theme_data.h8
-rw-r--r--scene/resources/default_theme/vslider_grabber_disabled.pngbin0 -> 335 bytes
-rw-r--r--scene/resources/dynamic_font.cpp4
-rw-r--r--scene/resources/environment.cpp49
-rw-r--r--scene/resources/environment.h8
-rw-r--r--scene/resources/font.cpp6
-rw-r--r--scene/resources/material.cpp376
-rw-r--r--scene/resources/material.h95
-rw-r--r--scene/resources/mesh.cpp21
-rw-r--r--scene/resources/mesh.h4
-rw-r--r--scene/resources/mesh_data_tool.cpp12
-rw-r--r--scene/resources/packed_scene.cpp4
-rw-r--r--scene/resources/primitive_meshes.cpp172
-rw-r--r--scene/resources/primitive_meshes.h26
-rw-r--r--scene/resources/scene_format_text.cpp26
-rw-r--r--scene/resources/sky_box.cpp29
-rw-r--r--scene/resources/sky_box.h5
-rw-r--r--scene/resources/style_box.cpp78
-rw-r--r--scene/resources/style_box.h34
-rw-r--r--scene/resources/surface_tool.cpp20
-rw-r--r--scene/resources/texture.cpp4
-rw-r--r--scene/resources/texture.h2
-rw-r--r--scene/resources/theme.cpp4
-rw-r--r--scene/resources/tile_set.cpp49
-rw-r--r--scene/resources/tile_set.h8
-rw-r--r--scene/resources/world.cpp7
-rw-r--r--scene/resources/world.h2
-rw-r--r--scene/resources/world_2d.cpp3
-rw-r--r--scene/resources/world_2d.h2
-rw-r--r--servers/SCsub3
-rw-r--r--servers/arvr/SCsub7
-rw-r--r--servers/arvr/arvr_interface.cpp82
-rw-r--r--servers/arvr/arvr_interface.h89
-rw-r--r--servers/arvr/arvr_positional_tracker.cpp142
-rw-r--r--servers/arvr/arvr_positional_tracker.h85
-rw-r--r--servers/arvr/arvr_script_interface.cpp127
-rw-r--r--servers/arvr/arvr_script_interface.h47
-rw-r--r--servers/arvr_server.cpp313
-rw-r--r--servers/arvr_server.h167
-rw-r--r--servers/audio/audio_driver_dummy.cpp2
-rw-r--r--servers/audio/audio_filter_sw.cpp37
-rw-r--r--servers/audio/audio_filter_sw.h25
-rw-r--r--servers/audio/audio_stream.cpp131
-rw-r--r--servers/audio/audio_stream.h55
-rw-r--r--servers/audio/effects/audio_effect_compressor.cpp20
-rw-r--r--servers/audio/effects/audio_effect_compressor.h6
-rw-r--r--servers/audio/effects/audio_effect_limiter.cpp20
-rw-r--r--servers/audio/effects/audio_effect_limiter.h6
-rw-r--r--servers/audio_server.cpp20
-rw-r--r--servers/audio_server.h3
-rw-r--r--servers/physics/area_pair_sw.cpp22
-rw-r--r--servers/physics/body_pair_sw.cpp11
-rw-r--r--servers/physics/body_sw.cpp2
-rw-r--r--servers/physics/broad_phase_basic.cpp20
-rw-r--r--servers/physics/broad_phase_basic.h1
-rw-r--r--servers/physics/broad_phase_octree.cpp5
-rw-r--r--servers/physics/broad_phase_octree.h1
-rw-r--r--servers/physics/broad_phase_sw.h1
-rw-r--r--servers/physics/collision_object_sw.h8
-rw-r--r--servers/physics/collision_solver_sat.cpp2
-rw-r--r--servers/physics/physics_server_sw.cpp38
-rw-r--r--servers/physics/physics_server_sw.h13
-rw-r--r--servers/physics/shape_sw.cpp249
-rw-r--r--servers/physics/shape_sw.h24
-rw-r--r--servers/physics/space_sw.cpp427
-rw-r--r--servers/physics/space_sw.h12
-rw-r--r--servers/physics_2d/body_2d_sw.cpp2
-rw-r--r--servers/physics_2d/broad_phase_2d_hash_grid.cpp4
-rw-r--r--servers/physics_2d/physics_2d_server_sw.cpp8
-rw-r--r--servers/physics_2d/physics_2d_server_sw.h4
-rw-r--r--servers/physics_2d/physics_2d_server_wrap_mt.cpp12
-rw-r--r--servers/physics_2d/physics_2d_server_wrap_mt.h6
-rw-r--r--servers/physics_2d/shape_2d_sw.cpp8
-rw-r--r--servers/physics_2d/shape_2d_sw.h6
-rw-r--r--servers/physics_2d/space_2d_sw.cpp170
-rw-r--r--servers/physics_2d/space_2d_sw.h10
-rw-r--r--servers/physics_2d_server.cpp4
-rw-r--r--servers/physics_2d_server.h8
-rw-r--r--servers/physics_server.h46
-rw-r--r--servers/register_server_types.cpp28
-rw-r--r--servers/visual/rasterizer.h54
-rw-r--r--servers/visual/shader_language.cpp3
-rw-r--r--servers/visual/shader_types.cpp15
-rw-r--r--servers/visual/visual_server_canvas.cpp84
-rw-r--r--servers/visual/visual_server_canvas.h1
-rw-r--r--servers/visual/visual_server_raster.cpp2
-rw-r--r--servers/visual/visual_server_raster.h6
-rw-r--r--servers/visual/visual_server_scene.cpp53
-rw-r--r--servers/visual/visual_server_scene.h3
-rw-r--r--servers/visual/visual_server_viewport.cpp87
-rw-r--r--servers/visual/visual_server_viewport.h8
-rw-r--r--servers/visual/visual_server_wrap_mt.cpp4
-rw-r--r--servers/visual/visual_server_wrap_mt.h7
-rw-r--r--servers/visual_server.cpp53
-rw-r--r--servers/visual_server.h8
-rw-r--r--thirdparty/README.md4
-rw-r--r--thirdparty/libpng/arm/filter_neon.S6
-rw-r--r--thirdparty/libpng/png.c118
-rw-r--r--thirdparty/libpng/png.h46
-rw-r--r--thirdparty/libpng/pngconf.h2
-rw-r--r--thirdparty/libpng/pngerror.c8
-rw-r--r--thirdparty/libpng/pngget.c18
-rw-r--r--thirdparty/libpng/pnginfo.h5
-rw-r--r--thirdparty/libpng/pnglibconf.h9
-rw-r--r--thirdparty/libpng/pngpriv.h52
-rw-r--r--thirdparty/libpng/pngread.c15
-rw-r--r--thirdparty/libpng/pngrtran.c11
-rw-r--r--thirdparty/libpng/pngrutil.c61
-rw-r--r--thirdparty/libpng/pngset.c48
-rw-r--r--thirdparty/libpng/pngstruct.h3
-rw-r--r--thirdparty/libpng/pngtrans.c38
-rw-r--r--thirdparty/libpng/pngwrite.c10
-rw-r--r--thirdparty/libpng/pngwutil.c37
-rw-r--r--thirdparty/zstd/README.md19
-rw-r--r--thirdparty/zstd/common/bitstream.h32
-rw-r--r--thirdparty/zstd/common/error_private.c5
-rw-r--r--thirdparty/zstd/common/huf.h20
-rw-r--r--thirdparty/zstd/common/mem.h14
-rw-r--r--thirdparty/zstd/common/pool.c12
-rw-r--r--thirdparty/zstd/common/pool.h5
-rw-r--r--thirdparty/zstd/common/threading.c1
-rw-r--r--thirdparty/zstd/common/zstd_common.c43
-rw-r--r--thirdparty/zstd/common/zstd_errors.h22
-rw-r--r--thirdparty/zstd/common/zstd_internal.h80
-rw-r--r--thirdparty/zstd/compress/huf_compress.c10
-rw-r--r--thirdparty/zstd/compress/zstd_compress.c1569
-rw-r--r--thirdparty/zstd/compress/zstd_opt.h45
-rw-r--r--thirdparty/zstd/compress/zstdmt_compress.c520
-rw-r--r--thirdparty/zstd/compress/zstdmt_compress.h62
-rw-r--r--thirdparty/zstd/decompress/huf_decompress.c176
-rw-r--r--thirdparty/zstd/decompress/zstd_decompress.c645
-rw-r--r--thirdparty/zstd/zstd.h673
820 files changed, 29078 insertions, 15898 deletions
diff --git a/.gitignore b/.gitignore
index 7552e8fd17..497d8b50d2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -284,3 +284,6 @@ platform/windows/godot_res.res
# Visual Studio 2017 and Visual Studio Code workspace folder
/.vs
/.vscode
+
+# Scons progress indicator
+.scons_node_count
diff --git a/.travis.yml b/.travis.yml
index 12d49f5d5d..371c965db4 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -88,8 +88,8 @@ script:
sh ./misc/travis/clang-format.sh;
else
if [ "$TRAVIS_OS_NAME" = "windows" ]; then
- scons platform=$GODOT_TARGET CXX=$CXX openssl=builtin;
+ scons -j 2 platform=$GODOT_TARGET progress=no verbose=yes CXX=$CXX openssl=builtin;
else
- scons platform=$GODOT_TARGET bits=64 CXX=$CXX openssl=builtin;
+ scons -j 2 platform=$GODOT_TARGET progress=no verbose=yes bits=64 CXX=$CXX openssl=builtin;
fi
fi
diff --git a/COPYRIGHT.txt b/COPYRIGHT.txt
index 698e4b1dc8..b36f2b1134 100644
--- a/COPYRIGHT.txt
+++ b/COPYRIGHT.txt
@@ -41,6 +41,7 @@ Upstream-Contact: Rémi Verschelde <contact@godotengine.org>
Source: https://github.com/godotengine/godot
Files: *
+Comment: Godot Engine
Copyright: 2007-2017, Juan Linietsky, Ariel Manzur.
2014-2017, Godot Engine contributors (cf. AUTHORS.md)
License: Expat
@@ -49,6 +50,7 @@ Files: ./icon.png
./icon.svg
./logo.png
./logo.svg
+Comment: Godot Engine logo
Copyright: Andrea Calabró
License: CC-BY-3.0
@@ -61,21 +63,25 @@ Files: ./platform/android/android_native_app_glue.c
./platform/android/java/src/org/godotengine/godot/input/InputManagerCompat.java
./platform/android/java/src/org/godotengine/godot/input/InputManagerV16.java
./platform/android/java/src/org/godotengine/godot/input/InputManagerV9.java
+Comment: The Android Open Source Project
Copyright: 2008-2013, The Android Open Source Project
License: Apache-2.0
Files: ./platform/android/cpu-features.c
./platform/android/cpu-features.h
+Comment: The Android Open Source Project
Copyright: 2010, The Android Open Source Project
License: BSD-2-clause
Files: ./platform/android/ifaddrs_android.cpp
./platform/android/ifaddrs_android.h
+Comment: The Android Open Source Project
Copyright: 2012-2013, Google Inc.
License: BSD-3-clause
Files: ./platform/android/java/src/com/android/vending/licensing/util/Base64.java
./platform/android/java/src/com/android/vending/licensing/util/Base64DecoderException.java
+Comment: The Android Open Source Project
Copyright: 2002, Google Inc.
License: Apache-2.0
@@ -83,17 +89,12 @@ Files: ./platform/android/power_android.cpp
./platform/osx/power_osx.cpp
./platform/windows/power_windows.cpp
./platform/x11/power_x11.cpp
+Comment: Simple DirectMedia Layer
Copyright: 1997-2017, Sam Lantinga
2007-2017, Juan Linietsky, Ariel Manzur.
2014-2017, Godot Engine contributors (cf. AUTHORS.md)
License: Expat and Zlib
-Files: ./platform/uwp/export/export.cpp
-Copyright: 2016, Facebook, Inc. All rights reserved.
- 2007-2017, Juan Linietsky, Ariel Manzur.
- 2014-2017, Godot Engine contributors (cf. AUTHORS.md)
-License: BSD-3-clause and Expat
-
Files: ./servers/physics/gjk_epa.cpp
./servers/physics/joints/generic_6dof_joint_sw.cpp
./servers/physics/joints/generic_6dof_joint_sw.h
@@ -104,6 +105,7 @@ Files: ./servers/physics/gjk_epa.cpp
./servers/physics/joints/pin_joint_sw.h
./servers/physics/joints/slider_joint_sw.cpp
./servers/physics/joints/slider_joint_sw.h
+Comment: Bullet Continuous Collision Detection and Physics Library
Copyright: 2003-2008, Erwin Coumans
2007-2017, Juan Linietsky, Ariel Manzur.
2014-2017, Godot Engine contributors (cf. AUTHORS.md)
@@ -111,79 +113,97 @@ License: Expat and Zlib
Files: ./servers/physics/joints/cone_twist_joint_sw.cpp
./servers/physics/joints/cone_twist_joint_sw.h
+Comment: Bullet Continuous Collision Detection and Physics Library
Copyright: 2007, Starbreeze Studios
2007-2017, Juan Linietsky, Ariel Manzur.
2014-2017, Godot Engine contributors (cf. AUTHORS.md)
License: Expat and Zlib
Files: ./thirdparty/b2d_convexdecomp/
+Comment: Box2D (ConvexDecomp)
Copyright: 2007, Eric Jordan
Copyright: 2006-2009, Erin Catto
License: Zlib
Files: ./thirdparty/certs/ca-certificates.crt
+Comment: FIXME
Copyright: FIXME
License: FIXME
Files: ./thirdparty/enet/
+Comment: ENet
Copyright: 2002-2016, Lee Salzman
License: Expat
Files: ./thirdparty/fonts/DroidSans*.ttf
+Comment: DroidSans font
Copyright: 2008, The Android Open Source Project
License: Apache-2.0
Files: ./thirdparty/fonts/source_code_pro.otf
+Comment: Source Code Pro font
Copyright: 2010, 2012, Adobe Systems Incorporated
License: OFL-1.1
Files: ./thirdparty/freetype/
+Comment: The FreeType Project
Copyright: 1996-2016, David Turner, Robert Wilhelm, and Werner Lemberg.
License: FTL
Files: ./thirdparty/glad/
+Comment: glad
Copyright: 2013, David Herberth
License: Expat
Files: ./thirdparty/jpeg_compressor/
+Comment: jpeg-compressor
Copyright: 2012, Rich Geldreich
License: public-domain
Files: ./thirdparty/libogg/
+Comment: OggVorbis
Copyright: 2002, Xiph.org Foundation
License: BSD-3-clause
Files: ./thirdparty/libpng/
+Comment: libpng
Copyright: 1995-1996, Guy Eric Schalnat, Group 42, Inc.
1996-1997, Andreas Dilger
1998-2016, Glenn Randers-Pehrson
License: Zlib
Files: ./thirdparty/libsimplewebm/
+Comment: libsimplewebm
Copyright: 2016, Błażej Szczygieł
License: Expat
Files: ./thirdparty/libsimplewebm/libwebm/
+Comment: The WebM Project
Copyright: 2010, Google Inc.
License: BSD-3-clause
Files: ./thirdparty/libtheora/
+Comment: OggTheora
Copyright: 2002-2009, Xiph.org Foundation
License: BSD-3-clause
Files: ./thirdparty/libvorbis/
+Comment: OggVorbis
Copyright: 2002-2015, Xiph.org Foundation
License: BSD-3-clause
Files: ./thirdparty/libvpx/
+Comment: The WebM Project
Copyright: 2010, The WebM Project authors.
License: BSD-3-clause
-Files: ./thirdparty/libwebp/COPYING
+Files: ./thirdparty/libwebp/
+Comment: WebP codec
Copyright: 2010, Google Inc.
License: BSD-3-clause
Files: ./thirdparty/minizip/
+Comment: MiniZip
Copyright: 1998-2010, Gilles Vollant
2007-2008, Even Rouault
2009-2010, Mathias Svensson
@@ -193,68 +213,82 @@ Files: ./thirdparty/misc/aes256.cpp
./thirdparty/misc/aes256.h
./thirdparty/misc/sha256.c
./thirdparty/misc/sha256.h
+Comment: AES-256 and SHA-256 implementation
Copyright: 2007-2011, Ilya O. Levin
License: ISC
Files: ./thirdparty/misc/base64.c
./thirdparty/misc/base64.h
+Comment: BASE64 conversion methods
Copyright: Ari Edelkind
License: public-domain
Files: ./thirdparty/misc/curl_hostcheck.c
./thirdparty/misc/curl_hostcheck.h
+Comment: curl
Copyright: 1998-2012, Daniel Stenberg et al.
License: curl
Files: ./thirdparty/misc/fastlz.c
./thirdparty/misc/fastlz.h
+Comment: FastLZ
Copyright: 2005-2007, Ariya Hidayat
License: Expat
Files: ./thirdparty/misc/hq2x.cpp
./thirdparty/misc/hq2x.h
+Comment: hq2x implementation
Copyright: 2016, Bruno Ribeiro
License: Apache-2.0
Files: ./thirdparty/misc/md5.cpp
./thirdparty/misc/md5.h
+Comment: MD5 Message Digest Algorithm
Copyright: 1990, RSA Data Security, Inc.
License: RSA-MD
Files: ./thirdparty/misc/mikktspace.c
./thirdparty/misc/mikktspace.h
+Comment: Tangent Space Normal Maps implementation
Copyright: 2011, Morten S. Mikkelsen
License: Zlib
Files: ./thirdparty/misc/pcg.cpp
./thirdparty/misc/pcg.h
+Comment: Minimal PCG32 implementation
Copyright: 2014, M.E. O'Neill
License: Apache-2.0
Files: ./thirdparty/misc/smaz.c
./thirdparty/misc/smaz.h
+Comment: SMAZ
Copyright: 2006-2009, Salvatore Sanfilippo
License: BSD-3-clause
Files: ./thirdparty/misc/stb_truetype.h
./thirdparty/misc/stb_vorbis.c
+Comment: stb libraries
Copyright: 2007-2015, Sean Barrett
License: public-domain
Files: ./thirdparty/misc/triangulator.cpp
./thirdparty/misc/triangulator.h
+Comment: PolyPartition
Copyright: 2011, Ivan Fratric
License: Expat
Files: ./thirdparty/misc/yuv2rgb.h
+Comment: YUV2RGB
Copyright: 2008-2011, Robin Watts
License: BSD-2-clause
Files: ./thirdparty/openssl/
+Comment: The OpenSSL Project
Copyright: 1998-2016, The OpenSSL Project.
License: OpenSSL
Files: ./thirdparty/opus/
+Comment: Opus
Copyright: 2001-2011, Xiph.Org, Skype Limited, Octasic,
Jean-Marc Valin, Timothy B. Terriberry,
CSIRO, Gregory Maxwell, Mark Borgerding,
@@ -262,27 +296,28 @@ Copyright: 2001-2011, Xiph.Org, Skype Limited, Octasic,
License: BSD-3-clause
Files: ./thirdparty/pvrtccompressor/
+Comment: PvrTcCompressor
Copyright: 2014, Jeffrey Lim.
License: BSD-3-clause
-Files: ./thirdparty/rg-etc1/
-Copyright: 2012, Rich Geldreich
-License: Zlib
-
Files: ./thirdparty/rtaudio/
+Comment: RtAudio
Copyright: 2001-2016, Gary P. Scavone
License: Expat
Files: ./thirdparty/squish/
+Comment: libSquish
Copyright: 2006, Simon Brown
License: Expat
Files: ./thirdparty/tinyexr/
+Comment: TinyEXR
Copyright: 2014-2017, Syoyo Fujita
2002, Industrial Light & Magic, a division of Lucas Digital Ltd. LLC
License: BSD-3-Clause
Files: ./thirdparty/zlib/
+Comment: zlib
Copyright: 1995-2017, Jean-loup Gailly and Mark Adler
License: Zlib
diff --git a/README.md b/README.md
index 0c4ab6498a..dc0dad6b90 100644
--- a/README.md
+++ b/README.md
@@ -63,4 +63,4 @@ such as text and video tutorials, demos, etc. Consult the [community channels](h
for more info.
[![Build Status](https://travis-ci.org/godotengine/godot.svg?branch=master)](https://travis-ci.org/godotengine/godot)
-[![Code Triagers Badge](http://www.codetriage.com/godotengine/godot/badges/users.svg)](http://www.codetriage.com/godotengine/godot)
+[![Code Triagers Badge](https://www.codetriage.com/godotengine/godot/badges/users.svg)](https://www.codetriage.com/godotengine/godot)
diff --git a/SConstruct b/SConstruct
index e745d7bb15..4085f713b7 100644
--- a/SConstruct
+++ b/SConstruct
@@ -62,7 +62,7 @@ platform_arg = ARGUMENTS.get("platform", ARGUMENTS.get("p", False))
if (os.name == "posix"):
pass
elif (os.name == "nt"):
- if (os.getenv("VCINSTALLDIR") == None or platform_arg == "android"):
+ if (os.getenv("VCINSTALLDIR") == None or platform_arg == "android" or platform_arg == "javascript"):
custom_tools = ['mingw']
env_base = Environment(tools=custom_tools)
@@ -87,6 +87,13 @@ env_base.disabled_modules = []
env_base.use_ptrcall = False
env_base.split_drivers = False
+# To decide whether to rebuild a file, use the MD5 sum only if the timestamp has changed.
+# http://scons.org/doc/production/HTML/scons-user/ch06.html#idm139837621851792
+env_base.Decider('MD5-timestamp')
+# Use cached implicit dependencies by default. Can be overridden by specifying `--implicit-deps-changed` in the command line.
+# http://scons.org/doc/production/HTML/scons-user/ch06s04.html
+env_base.SetOption('implicit_cache', 1)
+
env_base.__class__.android_add_maven_repository = methods.android_add_maven_repository
env_base.__class__.android_add_dependency = methods.android_add_dependency
@@ -143,9 +150,11 @@ opts.Add('disable_3d', "Disable 3D nodes for smaller executable (yes/no)", 'no')
opts.Add('disable_advanced_gui', "Disable advance 3D gui nodes and behaviors (yes/no)", 'no')
opts.Add('extra_suffix', "Custom extra suffix added to the base filename of all generated binary files", '')
opts.Add('unix_global_settings_path', "UNIX-specific path to system-wide settings. Currently only used for templates", '')
-opts.Add('verbose', "Enable verbose output for the compilation (yes/no)", 'yes')
+opts.Add('verbose', "Enable verbose output for the compilation (yes/no)", 'no')
opts.Add('vsproj', "Generate Visual Studio Project. (yes/no)", 'no')
-opts.Add('warnings', "Set the level of warnings emitted during compilation (extra/all/moderate/no)", 'all')
+opts.Add('warnings', "Set the level of warnings emitted during compilation (extra/all/moderate/no)", 'no')
+opts.Add('progress', "Show a progress indicator during build (yes/no)", 'yes')
+opts.Add('dev', "If yes, alias for verbose=yes warnings=all (yes/no)", 'no')
# Thirdparty libraries
opts.Add('builtin_enet', "Use the builtin enet library (yes/no)", 'yes')
@@ -201,8 +210,8 @@ if (env_base['target'] == 'debug'):
env_base.Append(CPPFLAGS=['-DDEBUG_MEMORY_ALLOC'])
env_base.Append(CPPFLAGS=['-DSCI_NAMESPACE'])
-if (env_base['deprecated'] != 'no'):
- env_base.Append(CPPFLAGS=['-DENABLE_DEPRECATED'])
+if (env_base['deprecated'] == 'no'):
+ env_base.Append(CPPFLAGS=['-DDISABLE_DEPRECATED'])
env_base.platforms = {}
@@ -224,6 +233,10 @@ if selected_platform in platform_list:
env = detect.create(env_base)
else:
env = env_base.Clone()
+
+ if (env["dev"] == "yes"):
+ env["warnings"] = "all"
+ env["verbose"] = "yes"
if env['vsproj'] == "yes":
env.vs_incs = []
@@ -275,7 +288,7 @@ if selected_platform in platform_list:
if (env["warnings"] == 'yes'):
print("WARNING: warnings=yes is deprecated; assuming warnings=all")
- if (os.name == "nt" and os.getenv("VSINSTALLDIR")): # MSVC, needs to stand out of course
+ if (os.name == "nt" and os.getenv("VCINSTALLDIR") and (platform_arg == "windows" or platform_arg == "uwp")): # MSVC, needs to stand out of course
disable_nonessential_warnings = ['/wd4267', '/wd4244', '/wd4305', '/wd4800'] # Truncations, narrowing conversions...
if (env["warnings"] == 'extra'):
env.Append(CCFLAGS=['/Wall']) # Implies /W4
@@ -442,3 +455,38 @@ else:
for x in platform_list:
print("\t" + x)
print("\nPlease run scons again with argument: platform=<string>")
+
+
+screen = sys.stdout
+node_count = 0
+node_count_max = 0
+node_count_interval = 1
+node_count_fname = str(env.Dir('#')) + '/.scons_node_count'
+
+def progress_function(node):
+ global node_count, node_count_max, node_count_interval, node_count_fname
+ node_count += node_count_interval
+ if (node_count_max > 0 and node_count <= node_count_max):
+ screen.write('\r[%3d%%] ' % (node_count * 100 / node_count_max))
+ screen.flush()
+ elif (node_count_max > 0 and node_count > node_count_max):
+ screen.write('\r[100%] ')
+ screen.flush()
+ else:
+ screen.write('\r[Initial build] ')
+ screen.flush()
+
+def progress_finish(target, source, env):
+ global node_count
+ with open(node_count_fname, 'w') as f:
+ f.write('%d\n' % node_count)
+
+if (env["progress"] == "yes"):
+ try:
+ with open(node_count_fname) as f:
+ node_count_max = int(f.readline())
+ except:
+ pass
+ Progress(progress_function, interval = node_count_interval)
+ progress_finish_command = Command('progress_finish', [], progress_finish)
+ AlwaysBuild(progress_finish_command)
diff --git a/core/SCsub b/core/SCsub
index 02abaa2bb6..4c541d7269 100644
--- a/core/SCsub
+++ b/core/SCsub
@@ -14,9 +14,9 @@ for x in env.global_defaults:
gd_inc += '#include "platform/' + x + '/globals/global_defaults.h"\n'
gd_call += "\tregister_" + x + "_global_defaults();\n"
-gd_cpp = '#include "global_config.h"\n'
+gd_cpp = '#include "project_settings.h"\n'
gd_cpp += gd_inc
-gd_cpp += "void GlobalConfig::register_global_defaults() {\n" + gd_call + "\n}\n"
+gd_cpp += "void ProjectSettings::register_global_defaults() {\n" + gd_call + "\n}\n"
f = open("global_defaults.gen.cpp", "wb")
f.write(gd_cpp)
@@ -48,7 +48,7 @@ if ("SCRIPT_AES256_ENCRYPTION_KEY" in os.environ):
print("Invalid AES256 encryption key, not 64 bits hex: " + e)
f = open("script_encryption_key.gen.cpp", "wb")
-f.write("#include \"global_config.h\"\nuint8_t script_encryption_key[32]={" + txt + "};\n")
+f.write("#include \"project_settings.h\"\nuint8_t script_encryption_key[32]={" + txt + "};\n")
f.close()
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp
index 095f058ed9..ce08b3f754 100644
--- a/core/bind/core_bind.cpp
+++ b/core/bind/core_bind.cpp
@@ -29,7 +29,7 @@
/*************************************************************************/
#include "core_bind.h"
-#include "core/global_config.h"
+#include "core/project_settings.h"
#include "geometry.h"
#include "io/file_access_compressed.h"
#include "io/file_access_encrypted.h"
@@ -106,7 +106,7 @@ PoolStringArray _ResourceLoader::get_dependencies(const String &p_path) {
bool _ResourceLoader::has(const String &p_path) {
- String local_path = GlobalConfig::get_singleton()->localize_path(p_path);
+ String local_path = ProjectSettings::get_singleton()->localize_path(p_path);
return ResourceCache::has(local_path);
};
@@ -149,7 +149,7 @@ _ResourceSaver *_ResourceSaver::singleton = NULL;
void _ResourceSaver::_bind_methods() {
ClassDB::bind_method(D_METHOD("save", "path", "resource:Resource", "flags"), &_ResourceSaver::save, DEFVAL(0));
- ClassDB::bind_method(D_METHOD("get_recognized_extensions", "type"), &_ResourceSaver::get_recognized_extensions);
+ ClassDB::bind_method(D_METHOD("get_recognized_extensions", "type:Resource"), &_ResourceSaver::get_recognized_extensions);
BIND_CONSTANT(FLAG_RELATIVE_PATHS);
BIND_CONSTANT(FLAG_BUNDLE_RESOURCES);
@@ -300,6 +300,11 @@ bool _OS::get_borderless_window() const {
return OS::get_singleton()->get_borderless_window();
}
+void _OS::set_ime_position(const Point2 &p_pos) {
+
+ return OS::get_singleton()->set_ime_position(p_pos);
+}
+
void _OS::set_use_file_access_save_and_swap(bool p_enable) {
FileAccess::set_backup_save(p_enable);
@@ -993,6 +998,8 @@ void _OS::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_borderless_window", "borderless"), &_OS::set_borderless_window);
ClassDB::bind_method(D_METHOD("get_borderless_window"), &_OS::get_borderless_window);
+ ClassDB::bind_method(D_METHOD("set_ime_position", "position"), &_OS::set_ime_position);
+
ClassDB::bind_method(D_METHOD("set_screen_orientation", "orientation"), &_OS::set_screen_orientation);
ClassDB::bind_method(D_METHOD("get_screen_orientation"), &_OS::get_screen_orientation);
@@ -1031,7 +1038,7 @@ void _OS::_bind_methods() {
&_OS::get_unix_time_from_datetime);
ClassDB::bind_method(D_METHOD("get_system_time_secs"), &_OS::get_system_time_secs);
- ClassDB::bind_method(D_METHOD("set_icon", "icon"), &_OS::set_icon);
+ ClassDB::bind_method(D_METHOD("set_icon", "icon:Image"), &_OS::set_icon);
ClassDB::bind_method(D_METHOD("get_exit_code"), &_OS::get_exit_code);
ClassDB::bind_method(D_METHOD("set_exit_code", "code"), &_OS::set_exit_code);
@@ -1773,6 +1780,7 @@ void _File::_bind_methods() {
BIND_CONSTANT(COMPRESSION_FASTLZ);
BIND_CONSTANT(COMPRESSION_DEFLATE);
BIND_CONSTANT(COMPRESSION_ZSTD);
+ BIND_CONSTANT(COMPRESSION_GZIP);
}
_File::_File() {
diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h
index 87d84c0732..ec4fd3f476 100644
--- a/core/bind/core_bind.h
+++ b/core/bind/core_bind.h
@@ -158,6 +158,8 @@ public:
virtual void set_borderless_window(bool p_borderless);
virtual bool get_borderless_window() const;
+ virtual void set_ime_position(const Point2 &p_pos);
+
Error native_video_play(String p_path, float p_volume, String p_audio_track, String p_subtitle_track);
bool native_video_is_playing();
void native_video_pause();
@@ -370,7 +372,8 @@ public:
enum CompressionMode {
COMPRESSION_FASTLZ = Compression::MODE_FASTLZ,
COMPRESSION_DEFLATE = Compression::MODE_DEFLATE,
- COMPRESSION_ZSTD = Compression::MODE_ZSTD
+ COMPRESSION_ZSTD = Compression::MODE_ZSTD,
+ COMPRESSION_GZIP = Compression::MODE_GZIP
};
Error open_encrypted(const String &p_path, int p_mode_flags, const Vector<uint8_t> &p_key);
diff --git a/core/core_string_names.cpp b/core/core_string_names.cpp
index 0ed44b0cb7..2adc15447a 100644
--- a/core/core_string_names.cpp
+++ b/core/core_string_names.cpp
@@ -44,6 +44,7 @@ CoreStringNames::CoreStringNames() {
_iter_next = StaticCString::create("_iter_next");
_iter_get = StaticCString::create("_iter_get");
get_rid = StaticCString::create("get_rid");
+ _custom_features = StaticCString::create("_custom_features");
#ifdef TOOLS_ENABLED
_sections_unfolded = StaticCString::create("_sections_unfolded");
#endif
diff --git a/core/core_string_names.h b/core/core_string_names.h
index 4b4f87a8f0..501185f5b7 100644
--- a/core/core_string_names.h
+++ b/core/core_string_names.h
@@ -61,6 +61,7 @@ public:
StringName _iter_next;
StringName _iter_get;
StringName get_rid;
+ StringName _custom_features;
#ifdef TOOLS_ENABLED
StringName _sections_unfolded;
#endif
diff --git a/core/dictionary.cpp b/core/dictionary.cpp
index e6d549b83d..1fe45aff94 100644
--- a/core/dictionary.cpp
+++ b/core/dictionary.cpp
@@ -200,6 +200,7 @@ uint32_t Dictionary::hash() const {
Array Dictionary::keys() const {
+#if 0
Array karr;
karr.resize(size());
const Variant *K = NULL;
@@ -208,6 +209,26 @@ Array Dictionary::keys() const {
karr[idx++] = (*K);
}
return karr;
+#else
+
+ Array varr;
+ varr.resize(size());
+ if (_p->variant_map.empty())
+ return varr;
+
+ int count = _p->variant_map.size();
+ const HashMap<Variant, DictionaryPrivate::Data, _DictionaryVariantHash>::Pair **pairs = (const HashMap<Variant, DictionaryPrivate::Data, _DictionaryVariantHash>::Pair **)alloca(count * sizeof(HashMap<Variant, DictionaryPrivate::Data, _DictionaryVariantHash>::Pair *));
+ _p->variant_map.get_key_value_ptr_array(pairs);
+
+ SortArray<const HashMap<Variant, DictionaryPrivate::Data, _DictionaryVariantHash>::Pair *, DictionaryPrivateSort> sort;
+ sort.sort(pairs, count);
+
+ for (int i = 0; i < count; i++) {
+ varr[i] = pairs[i]->key;
+ }
+
+ return varr;
+#endif
}
Array Dictionary::values() const {
diff --git a/core/dvector.h b/core/dvector.h
index 4584a300f9..66af42f7e2 100644
--- a/core/dvector.h
+++ b/core/dvector.h
@@ -409,14 +409,9 @@ public:
if (p_to < 0) {
p_to = size() + p_to;
}
- if (p_from < 0 || p_from >= size()) {
- PoolVector<T> &aux = *((PoolVector<T> *)0); // nullreturn
- ERR_FAIL_COND_V(p_from < 0 || p_from >= size(), aux)
- }
- if (p_to < 0 || p_to >= size()) {
- PoolVector<T> &aux = *((PoolVector<T> *)0); // nullreturn
- ERR_FAIL_COND_V(p_to < 0 || p_to >= size(), aux)
- }
+
+ CRASH_BAD_INDEX(p_from, size());
+ CRASH_BAD_INDEX(p_to, size());
PoolVector<T> slice;
int span = 1 + p_to - p_from;
@@ -506,13 +501,9 @@ void PoolVector<T>::push_back(const T &p_val) {
template <class T>
const T PoolVector<T>::operator[](int p_index) const {
- if (p_index < 0 || p_index >= size()) {
- T &aux = *((T *)0); //nullreturn
- ERR_FAIL_COND_V(p_index < 0 || p_index >= size(), aux);
- }
+ CRASH_BAD_INDEX(p_index, size());
Read r = read();
-
return r[p_index];
}
diff --git a/core/engine.cpp b/core/engine.cpp
index 5301c4e519..c16a2903d3 100644
--- a/core/engine.cpp
+++ b/core/engine.cpp
@@ -30,6 +30,7 @@
#include "engine.h"
#include "version.h"
+#include "version_hash.gen.h"
void Engine::set_iterations_per_second(int p_ips) {
@@ -87,6 +88,9 @@ Dictionary Engine::get_version_info() const {
dict["revision"] = _MKSTR(VERSION_REVISION);
dict["year"] = VERSION_YEAR;
+ String hash = String(VERSION_HASH);
+ dict["hash"] = hash.length() == 0 ? String("unknown") : hash;
+
String stringver = String(dict["major"]) + "." + String(dict["minor"]);
if ((int)dict["patch"] != 0)
stringver += "." + String(dict["patch"]);
@@ -115,4 +119,6 @@ Engine::Engine() {
_fixed_frames = 0;
_idle_frames = 0;
_in_fixed = false;
+ _frame_ticks = 0;
+ _frame_step = 0;
}
diff --git a/core/engine.h b/core/engine.h
index 80b11c095d..16dfb77593 100644
--- a/core/engine.h
+++ b/core/engine.h
@@ -42,6 +42,8 @@ class Engine {
String _custom_level;
uint64_t frames_drawn;
uint32_t _frame_delay;
+ uint64_t _frame_ticks;
+ float _frame_step;
int ips;
float _fps;
@@ -72,6 +74,8 @@ public:
uint64_t get_fixed_frames() const { return _fixed_frames; }
uint64_t get_idle_frames() const { return _idle_frames; }
bool is_in_fixed_frame() const { return _in_fixed; }
+ uint64_t get_idle_frame_ticks() const { return _frame_ticks; }
+ float get_idle_frame_step() const { return _frame_step; }
void set_time_scale(float p_scale);
float get_time_scale() const;
diff --git a/core/error_macros.h b/core/error_macros.h
index 00fced3586..6c803951a1 100644
--- a/core/error_macros.h
+++ b/core/error_macros.h
@@ -115,6 +115,19 @@ extern bool _err_error_exists;
#define FUNCTION_STR __FUNCTION__
#endif
+// Don't use this directly; instead, use any of the CRASH_* macros
+#ifdef _MSC_VER
+#define GENERATE_TRAP \
+ __debugbreak(); \
+ /* Avoid warning about control paths */ \
+ for (;;) { \
+ }
+#else
+#define GENERATE_TRAP __builtin_trap();
+#endif
+
+// (*): See https://stackoverflow.com/questions/257418/do-while-0-what-is-it-good-for
+
#define ERR_FAIL_INDEX(m_index, m_size) \
do { \
if ((m_index) < 0 || (m_index) >= (m_size)) { \
@@ -122,12 +135,12 @@ extern bool _err_error_exists;
return; \
} else \
_err_error_exists = false; \
- } while (0);
+ } while (0); // (*)
/** An index has failed if m_index<0 or m_index >=m_size, the function exists.
- * This function returns an error value, if returning Error, please select the most
- * appropriate error condition from error_macros.h
- */
+* This function returns an error value, if returning Error, please select the most
+* appropriate error condition from error_macros.h
+*/
#define ERR_FAIL_INDEX_V(m_index, m_size, m_retval) \
do { \
@@ -136,7 +149,18 @@ extern bool _err_error_exists;
return m_retval; \
} else \
_err_error_exists = false; \
- } while (0);
+ } while (0); // (*)
+
+/** Use this one if there is no sensible fallback, that is, the error is unrecoverable.
+* We'll return a null reference and try to keep running.
+*/
+#define CRASH_BAD_INDEX(m_index, m_size) \
+ do { \
+ if ((m_index) < 0 || (m_index) >= (m_size)) { \
+ _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "FATAL: Index " _STR(m_index) " out of size (" _STR(m_size) ")."); \
+ GENERATE_TRAP \
+ } \
+ } while (0); // (*)
/** An error condition happened (m_cond tested true) (WARNING this is the opposite as assert().
* the function will exit.
@@ -173,6 +197,17 @@ extern bool _err_error_exists;
_err_error_exists = false; \
}
+/** Use this one if there is no sensible fallback, that is, the error is unrecoverable.
+ */
+
+#define CRASH_COND(m_cond) \
+ { \
+ if (m_cond) { \
+ _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "FATAL: Condition ' " _STR(m_cond) " ' is true."); \
+ GENERATE_TRAP \
+ } \
+ }
+
/** An error condition happened (m_cond tested true) (WARNING this is the opposite as assert().
* the function will exit.
* This function returns an error value, if returning Error, please select the most
@@ -234,6 +269,15 @@ extern bool _err_error_exists;
return m_value; \
}
+/** Use this one if there is no sensible fallback, that is, the error is unrecoverable.
+ */
+
+#define CRASH_NOW() \
+ { \
+ _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "FATAL: Method/Function Failed."); \
+ GENERATE_TRAP \
+ }
+
/** Print an error string.
*/
diff --git a/core/global_constants.cpp b/core/global_constants.cpp
index 4f535fb05e..18071d7748 100644
--- a/core/global_constants.cpp
+++ b/core/global_constants.cpp
@@ -106,7 +106,6 @@ static _GlobalConstant _global_constants[] = {
BIND_GLOBAL_CONSTANT(KEY_F14),
BIND_GLOBAL_CONSTANT(KEY_F15),
BIND_GLOBAL_CONSTANT(KEY_F16),
- BIND_GLOBAL_CONSTANT(KEY_KP_ENTER),
BIND_GLOBAL_CONSTANT(KEY_KP_MULTIPLY),
BIND_GLOBAL_CONSTANT(KEY_KP_DIVIDE),
BIND_GLOBAL_CONSTANT(KEY_KP_SUBTRACT),
diff --git a/core/hash_map.h b/core/hash_map.h
index 49701188ab..45e7b82d24 100644
--- a/core/hash_map.h
+++ b/core/hash_map.h
@@ -473,8 +473,7 @@ public:
if (!e) {
e = create_entry(p_key);
- if (!e)
- return *(TData *)NULL; /* panic! */
+ CRASH_COND(!e);
check_hash_table(); // perform mantenience routine
}
diff --git a/core/image.cpp b/core/image.cpp
index 023a058667..50dc9c109d 100644
--- a/core/image.cpp
+++ b/core/image.cpp
@@ -423,7 +423,7 @@ void Image::convert(Format p_new_format) {
for (int i = 0; i < width; i++) {
for (int j = 0; j < height; j++) {
- new_img.put_pixel(i, j, get_pixel(i, j));
+ new_img.set_pixel(i, j, get_pixel(i, j));
}
}
@@ -1325,19 +1325,19 @@ void Image::create(const char **p_xpm) {
line++;
}
}
-#define DETECT_ALPHA_MAX_TRESHOLD 254
-#define DETECT_ALPHA_MIN_TRESHOLD 2
-
-#define DETECT_ALPHA(m_value) \
- { \
- uint8_t value = m_value; \
- if (value < DETECT_ALPHA_MIN_TRESHOLD) \
- bit = true; \
- else if (value < DETECT_ALPHA_MAX_TRESHOLD) { \
- \
- detected = true; \
- break; \
- } \
+#define DETECT_ALPHA_MAX_THRESHOLD 254
+#define DETECT_ALPHA_MIN_THRESHOLD 2
+
+#define DETECT_ALPHA(m_value) \
+ { \
+ uint8_t value = m_value; \
+ if (value < DETECT_ALPHA_MIN_THRESHOLD) \
+ bit = true; \
+ else if (value < DETECT_ALPHA_MAX_THRESHOLD) { \
+ \
+ detected = true; \
+ break; \
+ } \
}
#define DETECT_NON_ALPHA(m_value) \
@@ -1673,7 +1673,7 @@ void Image::blit_rect_mask(const Ref<Image> &p_src, const Ref<Image> &p_mask, co
const uint8_t *src_data_ptr = rp.ptr();
int pixel_size = get_format_pixel_size(format);
-
+
Ref<Image> msk = p_mask;
msk->lock();
@@ -1683,7 +1683,7 @@ void Image::blit_rect_mask(const Ref<Image> &p_src, const Ref<Image> &p_mask, co
int src_x = clipped_src_rect.position.x + j;
int src_y = clipped_src_rect.position.y + i;
-
+
if (msk->get_pixel(src_x, src_y).a != 0) {
int dst_x = dest_rect.position.x + j;
@@ -1737,7 +1737,7 @@ void Image::blend_rect(const Ref<Image> &p_src, const Rect2 &p_src_rect, const P
dc.g = (double)(sc.a * sc.g + dc.a * (1.0 - sc.a) * dc.g);
dc.b = (double)(sc.a * sc.b + dc.a * (1.0 - sc.a) * dc.b);
dc.a = (double)(sc.a + dc.a * (1.0 - sc.a));
- put_pixel(dst_x, dst_y, dc);
+ set_pixel(dst_x, dst_y, dc);
}
}
@@ -1792,7 +1792,7 @@ void Image::blend_rect_mask(const Ref<Image> &p_src, const Ref<Image> &p_mask, c
dc.g = (double)(sc.a * sc.g + dc.a * (1.0 - sc.a) * dc.g);
dc.b = (double)(sc.a * sc.b + dc.a * (1.0 - sc.a) * dc.b);
dc.a = (double)(sc.a + dc.a * (1.0 - sc.a));
- put_pixel(dst_x, dst_y, dc);
+ set_pixel(dst_x, dst_y, dc);
}
}
}
@@ -1812,7 +1812,7 @@ void Image::fill(const Color &c) {
int pixel_size = get_format_pixel_size(format);
// put first pixel with the format-aware API
- put_pixel(0, 0, c);
+ set_pixel(0, 0, c);
for (int y = 0; y < height; y++) {
@@ -2041,12 +2041,12 @@ Color Image::get_pixel(int p_x, int p_y) const {
return Color();
}
-void Image::put_pixel(int p_x, int p_y, const Color &p_color) {
+void Image::set_pixel(int p_x, int p_y, const Color &p_color) {
uint8_t *ptr = write_lock.ptr();
#ifdef DEBUG_ENABLED
if (!ptr) {
- ERR_EXPLAIN("Image must be locked with 'lock()' before using put_pixel()");
+ ERR_EXPLAIN("Image must be locked with 'lock()' before using set_pixel()");
ERR_FAIL_COND(!ptr);
}
@@ -2160,7 +2160,7 @@ void Image::put_pixel(int p_x, int p_y, const Color &p_color) {
} break;
default: {
- ERR_EXPLAIN("Can't put_pixel() on compressed image, sorry.");
+ ERR_EXPLAIN("Can't set_pixel() on compressed image, sorry.");
ERR_FAIL();
}
}
@@ -2245,7 +2245,7 @@ void Image::_bind_methods() {
ClassDB::bind_method(D_METHOD("detect_alpha"), &Image::detect_alpha);
ClassDB::bind_method(D_METHOD("is_invisible"), &Image::is_invisible);
- ClassDB::bind_method(D_METHOD("compress", "mode"), &Image::compress);
+ ClassDB::bind_method(D_METHOD("compress", "mode", "source", "lossy_quality"), &Image::compress);
ClassDB::bind_method(D_METHOD("decompress"), &Image::decompress);
ClassDB::bind_method(D_METHOD("is_compressed"), &Image::is_compressed);
@@ -2270,7 +2270,7 @@ void Image::_bind_methods() {
ClassDB::bind_method(D_METHOD("lock"), &Image::lock);
ClassDB::bind_method(D_METHOD("unlock"), &Image::unlock);
- ClassDB::bind_method(D_METHOD("put_pixel", "x", "y", "color"), &Image::put_pixel);
+ ClassDB::bind_method(D_METHOD("set_pixel", "x", "y", "color"), &Image::set_pixel);
ClassDB::bind_method(D_METHOD("get_pixel", "x", "y"), &Image::get_pixel);
ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE), "_set_data", "_get_data");
@@ -2434,7 +2434,7 @@ void Image::fix_alpha_edges() {
unsigned char *data_ptr = wp.ptr();
const int max_radius = 4;
- const int alpha_treshold = 20;
+ const int alpha_threshold = 20;
const int max_dist = 0x7FFFFFFF;
for (int i = 0; i < height; i++) {
@@ -2443,7 +2443,7 @@ void Image::fix_alpha_edges() {
const uint8_t *rptr = &srcptr[(i * width + j) * 4];
uint8_t *wptr = &data_ptr[(i * width + j) * 4];
- if (rptr[3] >= alpha_treshold)
+ if (rptr[3] >= alpha_threshold)
continue;
int closest_dist = max_dist;
@@ -2465,7 +2465,7 @@ void Image::fix_alpha_edges() {
const uint8_t *rp = &srcptr[(k * width + l) << 2];
- if (rp[3] < alpha_treshold)
+ if (rp[3] < alpha_threshold)
continue;
closest_color[0] = rp[0];
diff --git a/core/image.h b/core/image.h
index e523f703fa..7acc4744e9 100644
--- a/core/image.h
+++ b/core/image.h
@@ -315,7 +315,7 @@ public:
DetectChannels get_detected_channels();
Color get_pixel(int p_x, int p_y) const;
- void put_pixel(int p_x, int p_y, const Color &p_color);
+ void set_pixel(int p_x, int p_y, const Color &p_color);
void copy_internals_from(const Ref<Image> &p_image) {
ERR_FAIL_COND(p_image.is_null());
diff --git a/core/input_map.cpp b/core/input_map.cpp
index 1307c467e6..24d0624e98 100644
--- a/core/input_map.cpp
+++ b/core/input_map.cpp
@@ -29,8 +29,8 @@
/*************************************************************************/
#include "input_map.h"
-#include "global_config.h"
#include "os/keyboard.h"
+#include "project_settings.h"
InputMap *InputMap::singleton = NULL;
@@ -41,11 +41,11 @@ void InputMap::_bind_methods() {
ClassDB::bind_method(D_METHOD("add_action", "action"), &InputMap::add_action);
ClassDB::bind_method(D_METHOD("erase_action", "action"), &InputMap::erase_action);
- ClassDB::bind_method(D_METHOD("action_add_event", "action", "event"), &InputMap::action_add_event);
- ClassDB::bind_method(D_METHOD("action_has_event", "action", "event"), &InputMap::action_has_event);
- ClassDB::bind_method(D_METHOD("action_erase_event", "action", "event"), &InputMap::action_erase_event);
+ ClassDB::bind_method(D_METHOD("action_add_event", "action", "event:InputEvent"), &InputMap::action_add_event);
+ ClassDB::bind_method(D_METHOD("action_has_event", "action", "event:InputEvent"), &InputMap::action_has_event);
+ ClassDB::bind_method(D_METHOD("action_erase_event", "action", "event:InputEvent"), &InputMap::action_erase_event);
ClassDB::bind_method(D_METHOD("get_action_list", "action"), &InputMap::_get_action_list);
- ClassDB::bind_method(D_METHOD("event_is_action", "event", "action"), &InputMap::event_is_action);
+ ClassDB::bind_method(D_METHOD("event_is_action", "event:InputEvent", "action"), &InputMap::event_is_action);
ClassDB::bind_method(D_METHOD("load_from_globals"), &InputMap::load_from_globals);
}
@@ -189,7 +189,7 @@ void InputMap::load_from_globals() {
input_map.clear();
List<PropertyInfo> pinfo;
- GlobalConfig::get_singleton()->get_property_list(&pinfo);
+ ProjectSettings::get_singleton()->get_property_list(&pinfo);
for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
const PropertyInfo &pi = E->get();
@@ -201,7 +201,7 @@ void InputMap::load_from_globals() {
add_action(name);
- Array va = GlobalConfig::get_singleton()->get(pi.name);
+ Array va = ProjectSettings::get_singleton()->get(pi.name);
for (int i = 0; i < va.size(); i++) {
@@ -281,7 +281,7 @@ void InputMap::load_default() {
key->set_scancode(KEY_PAGEDOWN);
action_add_event("ui_page_down", key);
- //set("display/handheld/orientation", "landscape");
+ //set("display/window/handheld/orientation", "landscape");
}
InputMap::InputMap() {
diff --git a/core/io/compression.cpp b/core/io/compression.cpp
index f806c4da6d..139383710c 100644
--- a/core/io/compression.cpp
+++ b/core/io/compression.cpp
@@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "compression.h"
-#include "global_config.h"
#include "os/copymem.h"
+#include "project_settings.h"
#include "zip_io.h"
#include "thirdparty/misc/fastlz.h"
@@ -52,23 +52,22 @@ int Compression::compress(uint8_t *p_dst, const uint8_t *p_src, int p_src_size,
}
} break;
- case MODE_DEFLATE: {
+ case MODE_DEFLATE:
+ case MODE_GZIP: {
+
+ int window_bits = p_mode == MODE_DEFLATE ? 15 : 15 + 16;
z_stream strm;
strm.zalloc = zipio_alloc;
strm.zfree = zipio_free;
strm.opaque = Z_NULL;
- int level = GLOBAL_GET("compression/zlib/compression_level");
- int err = deflateInit(&strm, level);
+ int level = p_mode == MODE_DEFLATE ? zlib_level : gzip_level;
+ int err = deflateInit2(&strm, level, Z_DEFLATED, window_bits, 8, Z_DEFAULT_STRATEGY);
if (err != Z_OK)
return -1;
strm.avail_in = p_src_size;
int aout = deflateBound(&strm, p_src_size);
- /*if (aout>p_src_size) {
- deflateEnd(&strm);
- return -1;
- }*/
strm.avail_out = aout;
strm.next_in = (Bytef *)p_src;
strm.next_out = p_dst;
@@ -81,8 +80,7 @@ int Compression::compress(uint8_t *p_dst, const uint8_t *p_src, int p_src_size,
case MODE_ZSTD: {
int max_dst_size = get_max_compressed_buffer_size(p_src_size, MODE_ZSTD);
- int level = GLOBAL_GET("compression/zstd/compression_level");
- return ZSTD_compress(p_dst, max_dst_size, p_src, p_src_size, level);
+ return ZSTD_compress(p_dst, max_dst_size, p_src, p_src_size, zstd_level);
} break;
}
@@ -100,13 +98,16 @@ int Compression::get_max_compressed_buffer_size(int p_src_size, Mode p_mode) {
return ss;
} break;
- case MODE_DEFLATE: {
+ case MODE_DEFLATE:
+ case MODE_GZIP: {
+
+ int window_bits = p_mode == MODE_DEFLATE ? 15 : 15 + 16;
z_stream strm;
strm.zalloc = zipio_alloc;
strm.zfree = zipio_free;
strm.opaque = Z_NULL;
- int err = deflateInit(&strm, Z_DEFAULT_COMPRESSION);
+ int err = deflateInit2(&strm, Z_DEFAULT_COMPRESSION, Z_DEFLATED, window_bits, 8, Z_DEFAULT_STRATEGY);
if (err != Z_OK)
return -1;
int aout = deflateBound(&strm, p_src_size);
@@ -138,7 +139,10 @@ int Compression::decompress(uint8_t *p_dst, int p_dst_max_size, const uint8_t *p
}
return ret_size;
} break;
- case MODE_DEFLATE: {
+ case MODE_DEFLATE:
+ case MODE_GZIP: {
+
+ int window_bits = p_mode == MODE_DEFLATE ? 15 : 15 + 16;
z_stream strm;
strm.zalloc = zipio_alloc;
@@ -146,7 +150,7 @@ int Compression::decompress(uint8_t *p_dst, int p_dst_max_size, const uint8_t *p
strm.opaque = Z_NULL;
strm.avail_in = 0;
strm.next_in = Z_NULL;
- int err = inflateInit(&strm);
+ int err = inflateInit2(&strm, window_bits);
ERR_FAIL_COND_V(err != Z_OK, -1);
strm.avail_in = p_src_size;
@@ -168,3 +172,7 @@ int Compression::decompress(uint8_t *p_dst, int p_dst_max_size, const uint8_t *p
ERR_FAIL_V(-1);
}
+
+int Compression::zlib_level = Z_DEFAULT_COMPRESSION;
+int Compression::gzip_level = Z_DEFAULT_COMPRESSION;
+int Compression::zstd_level = 3;
diff --git a/core/io/compression.h b/core/io/compression.h
index 742f0f4d68..5eb7806d7b 100644
--- a/core/io/compression.h
+++ b/core/io/compression.h
@@ -33,11 +33,17 @@
#include "typedefs.h"
class Compression {
+
public:
+ static int zlib_level;
+ static int gzip_level;
+ static int zstd_level;
+
enum Mode {
MODE_FASTLZ,
MODE_DEFLATE,
- MODE_ZSTD
+ MODE_ZSTD,
+ MODE_GZIP
};
static int compress(uint8_t *p_dst, const uint8_t *p_src, int p_src_size, Mode p_mode = MODE_ZSTD);
diff --git a/core/io/file_access_memory.cpp b/core/io/file_access_memory.cpp
index 32ea4ce096..8e719568e5 100644
--- a/core/io/file_access_memory.cpp
+++ b/core/io/file_access_memory.cpp
@@ -29,10 +29,10 @@
/*************************************************************************/
#include "file_access_memory.h"
-#include "global_config.h"
#include "map.h"
#include "os/copymem.h"
#include "os/dir_access.h"
+#include "project_settings.h"
static Map<String, Vector<uint8_t> > *files = NULL;
@@ -43,8 +43,8 @@ void FileAccessMemory::register_file(String p_name, Vector<uint8_t> p_data) {
}
String name;
- if (GlobalConfig::get_singleton())
- name = GlobalConfig::get_singleton()->globalize_path(p_name);
+ if (ProjectSettings::get_singleton())
+ name = ProjectSettings::get_singleton()->globalize_path(p_name);
else
name = p_name;
//name = DirAccess::normalize_path(name);
diff --git a/core/io/file_access_network.cpp b/core/io/file_access_network.cpp
index 50e78899fb..aa67479d7e 100644
--- a/core/io/file_access_network.cpp
+++ b/core/io/file_access_network.cpp
@@ -28,10 +28,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "file_access_network.h"
-#include "global_config.h"
#include "io/ip.h"
#include "marshalls.h"
#include "os/os.h"
+#include "project_settings.h"
//#define DEBUG_PRINT(m_p) print_line(m_p)
//#define DEBUG_TIME(m_what) printf("MS: %s - %lli\n",m_what,OS::get_singleton()->get_ticks_usec());
diff --git a/core/io/ip.cpp b/core/io/ip.cpp
index 6c463b983c..c869bdad9b 100644
--- a/core/io/ip.cpp
+++ b/core/io/ip.cpp
@@ -240,7 +240,7 @@ void IP::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_resolve_item_address", "id"), &IP::get_resolve_item_address);
ClassDB::bind_method(D_METHOD("erase_resolve_item", "id"), &IP::erase_resolve_item);
ClassDB::bind_method(D_METHOD("get_local_addresses"), &IP::_get_local_addresses);
- ClassDB::bind_method(D_METHOD("clear_cache"), &IP::clear_cache, DEFVAL(""));
+ ClassDB::bind_method(D_METHOD("clear_cache", "hostname"), &IP::clear_cache, DEFVAL(""));
BIND_CONSTANT(RESOLVER_STATUS_NONE);
BIND_CONSTANT(RESOLVER_STATUS_WAITING);
diff --git a/core/io/packet_peer.cpp b/core/io/packet_peer.cpp
index ac68d5240c..a3d33593dd 100644
--- a/core/io/packet_peer.cpp
+++ b/core/io/packet_peer.cpp
@@ -29,8 +29,8 @@
/*************************************************************************/
#include "packet_peer.h"
-#include "global_config.h"
#include "io/marshalls.h"
+#include "project_settings.h"
/* helpers / binders */
PacketPeer::PacketPeer() {
@@ -254,7 +254,7 @@ void PacketPeerStream::set_input_buffer_max_size(int p_max_size) {
PacketPeerStream::PacketPeerStream() {
- int rbsize = GLOBAL_GET("network/packets/packet_stream_peer_max_buffer_po2");
+ int rbsize = GLOBAL_GET("network/limits/packet_peer_stream/max_buffer_po2");
ring_buffer.resize(rbsize);
temp_buffer.resize(1 << rbsize);
diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp
index b474c2e078..9aa16ed7e7 100644
--- a/core/io/resource_format_binary.cpp
+++ b/core/io/resource_format_binary.cpp
@@ -28,10 +28,11 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "resource_format_binary.h"
-#include "global_config.h"
+#include "image.h"
#include "io/file_access_compressed.h"
#include "io/marshalls.h"
#include "os/dir_access.h"
+#include "project_settings.h"
#include "version.h"
//#define print_bl(m_what) print_line(m_what)
#define print_bl(m_what)
@@ -54,7 +55,6 @@ enum {
VARIANT_TRANSFORM = 17,
VARIANT_MATRIX32 = 18,
VARIANT_COLOR = 20,
- //VARIANT_IMAGE = 21, - no longer variant type
VARIANT_NODE_PATH = 22,
VARIANT_RID = 23,
VARIANT_OBJECT = 24,
@@ -70,7 +70,13 @@ enum {
VARIANT_VECTOR2_ARRAY = 37,
VARIANT_INT64 = 40,
VARIANT_DOUBLE = 41,
-
+#ifndef DISABLE_DEPRECATED
+ VARIANT_IMAGE = 21, // - no longer variant type
+ IMAGE_ENCODING_EMPTY = 0,
+ IMAGE_ENCODING_RAW = 1,
+ IMAGE_ENCODING_LOSSLESS = 2,
+ IMAGE_ENCODING_LOSSY = 3,
+#endif
OBJECT_EMPTY = 0,
OBJECT_EXTERNAL_RESOURCE = 1,
OBJECT_INTERNAL_RESOURCE = 2,
@@ -311,7 +317,7 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) {
if (path.find("://") == -1 && path.is_rel_path()) {
// path is relative to file being loaded, so convert to a resource path
- path = GlobalConfig::get_singleton()->localize_path(res_path.get_base_dir().plus_file(path));
+ path = ProjectSettings::get_singleton()->localize_path(res_path.get_base_dir().plus_file(path));
}
if (remaps.find(path)) {
@@ -340,7 +346,7 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) {
if (path.find("://") == -1 && path.is_rel_path()) {
// path is relative to file being loaded, so convert to a resource path
- path = GlobalConfig::get_singleton()->localize_path(res_path.get_base_dir().plus_file(path));
+ path = ProjectSettings::get_singleton()->localize_path(res_path.get_base_dir().plus_file(path));
}
RES res = ResourceLoader::load(path, type);
@@ -541,7 +547,69 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) {
w = PoolVector<Color>::Write();
r_v = array;
} break;
+#ifndef DISABLE_DEPRECATED
+ case VARIANT_IMAGE: {
+ uint32_t encoding = f->get_32();
+ if (encoding == IMAGE_ENCODING_EMPTY) {
+ r_v = Ref<Image>();
+ break;
+ } else if (encoding == IMAGE_ENCODING_RAW) {
+ uint32_t width = f->get_32();
+ uint32_t height = f->get_32();
+ uint32_t mipmaps = f->get_32();
+ uint32_t format = f->get_32();
+ const uint32_t format_version_shift = 24;
+ const uint32_t format_version_mask = format_version_shift - 1;
+
+ uint32_t format_version = format >> format_version_shift;
+
+ const uint32_t current_version = 0;
+ if (format_version > current_version) {
+
+ ERR_PRINT("Format version for encoded binary image is too new");
+ return ERR_PARSE_ERROR;
+ }
+
+ Image::Format fmt = Image::Format(format & format_version_mask); //if format changes, we can add a compatibility bit on top
+
+ uint32_t datalen = f->get_32();
+
+ PoolVector<uint8_t> imgdata;
+ imgdata.resize(datalen);
+ PoolVector<uint8_t>::Write w = imgdata.write();
+ f->get_buffer(w.ptr(), datalen);
+ _advance_padding(datalen);
+ w = PoolVector<uint8_t>::Write();
+
+ Ref<Image> image;
+ image.instance();
+ image->create(width, height, mipmaps, fmt, imgdata);
+ r_v = image;
+
+ } else {
+ //compressed
+ PoolVector<uint8_t> data;
+ data.resize(f->get_32());
+ PoolVector<uint8_t>::Write w = data.write();
+ f->get_buffer(w.ptr(), data.size());
+ w = PoolVector<uint8_t>::Write();
+
+ Ref<Image> image;
+ if (encoding == IMAGE_ENCODING_LOSSY && Image::lossy_unpacker) {
+
+ image = Image::lossy_unpacker(data);
+ } else if (encoding == IMAGE_ENCODING_LOSSLESS && Image::lossless_unpacker) {
+
+ image = Image::lossless_unpacker(data);
+ }
+ _advance_padding(data.size());
+
+ r_v = image;
+ }
+
+ } break;
+#endif
default: {
ERR_FAIL_V(ERR_FILE_CORRUPT);
} break;
@@ -949,7 +1017,7 @@ Ref<ResourceInteractiveLoader> ResourceFormatLoaderBinary::load_interactive(cons
}
Ref<ResourceInteractiveLoaderBinary> ria = memnew(ResourceInteractiveLoaderBinary);
- ria->local_path = GlobalConfig::get_singleton()->localize_path(p_path);
+ ria->local_path = ProjectSettings::get_singleton()->localize_path(p_path);
ria->res_path = ria->local_path;
//ria->set_local_path( Globals::get_singleton()->localize_path(p_path) );
ria->open(f);
@@ -997,7 +1065,7 @@ void ResourceFormatLoaderBinary::get_dependencies(const String &p_path, List<Str
ERR_FAIL_COND(!f);
Ref<ResourceInteractiveLoaderBinary> ria = memnew(ResourceInteractiveLoaderBinary);
- ria->local_path = GlobalConfig::get_singleton()->localize_path(p_path);
+ ria->local_path = ProjectSettings::get_singleton()->localize_path(p_path);
ria->res_path = ria->local_path;
//ria->set_local_path( Globals::get_singleton()->localize_path(p_path) );
ria->get_dependencies(f, p_dependencies, p_add_types);
@@ -1084,7 +1152,7 @@ Error ResourceFormatLoaderBinary::rename_dependencies(const String &p_path, cons
}
Ref<ResourceInteractiveLoaderBinary> ria = memnew(ResourceInteractiveLoaderBinary);
- ria->local_path = GlobalConfig::get_singleton()->localize_path(p_path);
+ ria->local_path = ProjectSettings::get_singleton()->localize_path(p_path);
ria->res_path = ria->local_path;
ria->remaps = p_map;
//ria->set_local_path( Globals::get_singleton()->localize_path(p_path) );
@@ -1213,7 +1281,7 @@ String ResourceFormatLoaderBinary::get_resource_type(const String &p_path) const
}
Ref<ResourceInteractiveLoaderBinary> ria = memnew(ResourceInteractiveLoaderBinary);
- ria->local_path = GlobalConfig::get_singleton()->localize_path(p_path);
+ ria->local_path = ProjectSettings::get_singleton()->localize_path(p_path);
ria->res_path = ria->local_path;
//ria->set_local_path( Globals::get_singleton()->localize_path(p_path) );
String r = ria->recognize(f);
@@ -1644,7 +1712,6 @@ void ResourceFormatSaverBinaryInstance::_find_resources(const Variant &p_variant
get_string_index(np.get_property());
} break;
-
default: {}
}
}
@@ -1917,7 +1984,7 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p
Error ResourceFormatSaverBinary::save(const String &p_path, const RES &p_resource, uint32_t p_flags) {
- String local_path = GlobalConfig::get_singleton()->localize_path(p_path);
+ String local_path = ProjectSettings::get_singleton()->localize_path(p_path);
ResourceFormatSaverBinaryInstance saver;
return saver.save(local_path, p_resource, p_flags);
}
diff --git a/core/io/resource_import.cpp b/core/io/resource_import.cpp
index ffb27bc26a..61da4f3350 100644
--- a/core/io/resource_import.cpp
+++ b/core/io/resource_import.cpp
@@ -49,6 +49,7 @@ Error ResourceFormatImporter::_get_path_and_type(const String &p_path, PathAndTy
int lines = 0;
String error_text;
+ bool path_found = false; //first match must have priority
while (true) {
assign = Variant();
@@ -66,14 +67,16 @@ Error ResourceFormatImporter::_get_path_and_type(const String &p_path, PathAndTy
}
if (assign != String()) {
- if (assign.begins_with("path.") && r_path_and_type.path == String()) {
+ if (!path_found && assign.begins_with("path.") && r_path_and_type.path == String()) {
String feature = assign.get_slicec('.', 1);
if (OS::get_singleton()->check_feature_support(feature)) {
r_path_and_type.path = value;
+ path_found = true; //first match must have priority
}
- } else if (assign == "path") {
+ } else if (!path_found && assign == "path") {
r_path_and_type.path = value;
+ path_found = true; //first match must have priority
} else if (assign == "type") {
r_path_and_type.type = value;
}
diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp
index bb7be38413..9b89fa3399 100644
--- a/core/io/resource_loader.cpp
+++ b/core/io/resource_loader.cpp
@@ -28,12 +28,12 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "resource_loader.h"
-#include "global_config.h"
#include "io/resource_import.h"
#include "os/file_access.h"
#include "os/os.h"
#include "path_remap.h"
#include "print_string.h"
+#include "project_settings.h"
#include "translation.h"
ResourceFormatLoader *ResourceLoader::loader[MAX_LOADERS];
@@ -84,7 +84,7 @@ void ResourceLoader::get_recognized_extensions_for_type(const String &p_type, Li
void ResourceInteractiveLoader::_bind_methods() {
- ClassDB::bind_method(D_METHOD("get_resource"), &ResourceInteractiveLoader::get_resource);
+ ClassDB::bind_method(D_METHOD("get_resource:Resource"), &ResourceInteractiveLoader::get_resource);
ClassDB::bind_method(D_METHOD("poll"), &ResourceInteractiveLoader::poll);
ClassDB::bind_method(D_METHOD("wait"), &ResourceInteractiveLoader::wait);
ClassDB::bind_method(D_METHOD("get_stage"), &ResourceInteractiveLoader::get_stage);
@@ -166,7 +166,7 @@ RES ResourceLoader::load(const String &p_path, const String &p_type_hint, bool p
if (p_path.is_rel_path())
local_path = "res://" + p_path;
else
- local_path = GlobalConfig::get_singleton()->localize_path(p_path);
+ local_path = ProjectSettings::get_singleton()->localize_path(p_path);
bool xl_remapped = false;
String path = _path_remap(local_path, &xl_remapped);
@@ -233,7 +233,7 @@ Ref<ResourceInteractiveLoader> ResourceLoader::load_interactive(const String &p_
if (p_path.is_rel_path())
local_path = "res://" + p_path;
else
- local_path = GlobalConfig::get_singleton()->localize_path(p_path);
+ local_path = ProjectSettings::get_singleton()->localize_path(p_path);
bool xl_remapped = false;
String path = _path_remap(local_path, &xl_remapped);
@@ -304,7 +304,7 @@ void ResourceLoader::get_dependencies(const String &p_path, List<String> *p_depe
if (path.is_rel_path())
local_path = "res://" + path;
else
- local_path = GlobalConfig::get_singleton()->localize_path(path);
+ local_path = ProjectSettings::get_singleton()->localize_path(path);
for (int i = 0; i < loader_count; i++) {
@@ -327,7 +327,7 @@ Error ResourceLoader::rename_dependencies(const String &p_path, const Map<String
if (path.is_rel_path())
local_path = "res://" + path;
else
- local_path = GlobalConfig::get_singleton()->localize_path(path);
+ local_path = ProjectSettings::get_singleton()->localize_path(path);
for (int i = 0; i < loader_count; i++) {
@@ -350,7 +350,7 @@ String ResourceLoader::get_resource_type(const String &p_path) {
if (p_path.is_rel_path())
local_path = "res://" + p_path;
else
- local_path = GlobalConfig::get_singleton()->localize_path(p_path);
+ local_path = ProjectSettings::get_singleton()->localize_path(p_path);
for (int i = 0; i < loader_count; i++) {
@@ -430,7 +430,10 @@ void ResourceLoader::reload_translation_remaps() {
void ResourceLoader::load_translation_remaps() {
- Dictionary remaps = GlobalConfig::get_singleton()->get("locale/translation_remaps");
+ if (!ProjectSettings::get_singleton()->has("locale/translation_remaps"))
+ return;
+
+ Dictionary remaps = ProjectSettings::get_singleton()->get("locale/translation_remaps");
List<Variant> keys;
remaps.get_key_list(&keys);
for (List<Variant>::Element *E = keys.front(); E; E = E->next()) {
diff --git a/core/io/resource_saver.cpp b/core/io/resource_saver.cpp
index 8592346a72..314259b2e9 100644
--- a/core/io/resource_saver.cpp
+++ b/core/io/resource_saver.cpp
@@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "resource_saver.h"
-#include "global_config.h"
#include "os/file_access.h"
+#include "project_settings.h"
#include "resource_loader.h"
#include "script_language.h"
@@ -64,7 +64,7 @@ Error ResourceSaver::save(const String &p_path, const RES &p_resource, uint32_t
String old_path = p_resource->get_path();
- String local_path = GlobalConfig::get_singleton()->localize_path(p_path);
+ String local_path = ProjectSettings::get_singleton()->localize_path(p_path);
RES rwcopy = p_resource;
if (p_flags & FLAG_CHANGE_PATH)
diff --git a/core/io/tcp_server.cpp b/core/io/tcp_server.cpp
index 29a80ecc19..4c891188ee 100644
--- a/core/io/tcp_server.cpp
+++ b/core/io/tcp_server.cpp
@@ -49,7 +49,7 @@ void TCP_Server::_bind_methods() {
ClassDB::bind_method(D_METHOD("listen", "port", "bind_address"), &TCP_Server::listen, DEFVAL("*"));
ClassDB::bind_method(D_METHOD("is_connection_available"), &TCP_Server::is_connection_available);
- ClassDB::bind_method(D_METHOD("take_connection"), &TCP_Server::take_connection);
+ ClassDB::bind_method(D_METHOD("take_connection:StreamPeerTCP"), &TCP_Server::take_connection);
ClassDB::bind_method(D_METHOD("stop"), &TCP_Server::stop);
}
diff --git a/core/io/translation_loader_po.cpp b/core/io/translation_loader_po.cpp
index 6104608961..1a670b0ab0 100644
--- a/core/io/translation_loader_po.cpp
+++ b/core/io/translation_loader_po.cpp
@@ -51,6 +51,8 @@ RES TranslationLoaderPO::load_translation(FileAccess *f, Error *r_error, const S
Ref<Translation> translation = Ref<Translation>(memnew(Translation));
int line = 1;
+ bool skip_this;
+ bool skip_next;
while (true) {
@@ -60,9 +62,10 @@ RES TranslationLoaderPO::load_translation(FileAccess *f, Error *r_error, const S
if (status == STATUS_READING_STRING) {
- if (msg_id != "")
- translation->add_message(msg_id, msg_str);
- else if (config == "")
+ if (msg_id != "") {
+ if (!skip_this)
+ translation->add_message(msg_id, msg_str);
+ } else if (config == "")
config = msg_str;
break;
@@ -85,15 +88,18 @@ RES TranslationLoaderPO::load_translation(FileAccess *f, Error *r_error, const S
ERR_FAIL_V(RES());
}
- if (msg_id != "")
- translation->add_message(msg_id, msg_str);
- else if (config == "")
+ if (msg_id != "") {
+ if (!skip_this)
+ translation->add_message(msg_id, msg_str);
+ } else if (config == "")
config = msg_str;
l = l.substr(5, l.length()).strip_edges();
status = STATUS_READING_ID;
msg_id = "";
msg_str = "";
+ skip_this = skip_next;
+ skip_next = false;
}
if (l.begins_with("msgstr")) {
@@ -110,6 +116,9 @@ RES TranslationLoaderPO::load_translation(FileAccess *f, Error *r_error, const S
}
if (l == "" || l.begins_with("#")) {
+ if (l.find("fuzzy") != -1) {
+ skip_next = true;
+ }
line++;
continue; //nothing to read or comment
}
diff --git a/core/list.h b/core/list.h
index 4390cb65fc..df69b1dc40 100644
--- a/core/list.h
+++ b/core/list.h
@@ -398,10 +398,7 @@ public:
T &operator[](int p_index) {
- if (p_index < 0 || p_index >= size()) {
- T &aux = *((T *)0); //nullreturn
- ERR_FAIL_COND_V(p_index < 0 || p_index >= size(), aux);
- }
+ CRASH_BAD_INDEX(p_index, size());
Element *I = front();
int c = 0;
@@ -415,15 +412,12 @@ public:
c++;
}
- ERR_FAIL_V(*((T *)0)); // bug!!
+ CRASH_NOW(); // bug!!
}
const T &operator[](int p_index) const {
- if (p_index < 0 || p_index >= size()) {
- T &aux = *((T *)0); //nullreturn
- ERR_FAIL_COND_V(p_index < 0 || p_index >= size(), aux);
- }
+ CRASH_BAD_INDEX(p_index, size());
const Element *I = front();
int c = 0;
@@ -437,7 +431,7 @@ public:
c++;
}
- ERR_FAIL_V(*((T *)0)); // bug!
+ CRASH_NOW(); // bug!!
}
void move_to_back(Element *p_I) {
diff --git a/core/map.h b/core/map.h
index acf1d608d8..ef0f75fc9b 100644
--- a/core/map.h
+++ b/core/map.h
@@ -599,9 +599,9 @@ public:
const V &operator[](const K &p_key) const {
- ERR_FAIL_COND_V(!_data._root, *(V *)NULL); // crash on purpose
+ CRASH_COND(!_data._root);
const Element *e = find(p_key);
- ERR_FAIL_COND_V(!e, *(V *)NULL); // crash on purpose
+ CRASH_COND(!e);
return e->_value;
}
V &operator[](const K &p_key) {
@@ -613,7 +613,7 @@ public:
if (!e)
e = insert(p_key, V());
- ERR_FAIL_COND_V(!e, *(V *)NULL); // crash on purpose
+ CRASH_COND(!e);
return e->_value;
}
diff --git a/core/math/a_star.cpp b/core/math/a_star.cpp
index 838fec22f0..04e4383f03 100644
--- a/core/math/a_star.cpp
+++ b/core/math/a_star.cpp
@@ -123,6 +123,12 @@ void AStar::disconnect_points(int p_id, int p_with_id) {
a->neighbours.erase(b);
b->neighbours.erase(a);
}
+
+bool AStar::has_point(int p_id) const {
+
+ return points.has(p_id);
+}
+
bool AStar::are_points_connected(int p_id, int p_with_id) const {
Segment s(p_id, p_with_id);
@@ -400,6 +406,7 @@ void AStar::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_point_pos", "id"), &AStar::get_point_pos);
ClassDB::bind_method(D_METHOD("get_point_weight_scale", "id"), &AStar::get_point_weight_scale);
ClassDB::bind_method(D_METHOD("remove_point", "id"), &AStar::remove_point);
+ ClassDB::bind_method(D_METHOD("has_point", "id"), &AStar::has_point);
ClassDB::bind_method(D_METHOD("connect_points", "id", "to_id", "bidirectional"), &AStar::connect_points, DEFVAL(true));
ClassDB::bind_method(D_METHOD("disconnect_points", "id", "to_id"), &AStar::disconnect_points);
diff --git a/core/math/a_star.h b/core/math/a_star.h
index 34a5358344..ebf1407c17 100644
--- a/core/math/a_star.h
+++ b/core/math/a_star.h
@@ -104,6 +104,7 @@ public:
Vector3 get_point_pos(int p_id) const;
real_t get_point_weight_scale(int p_id) const;
void remove_point(int p_id);
+ bool has_point(int p_id) const;
void connect_points(int p_id, int p_with_id, bool bidirectional = true);
void disconnect_points(int p_id, int p_with_id);
diff --git a/core/math/audio_frame.h b/core/math/audio_frame.h
index 5ccc9d9e5e..d54f622197 100644
--- a/core/math/audio_frame.h
+++ b/core/math/audio_frame.h
@@ -102,6 +102,16 @@ struct AudioFrame {
r = ::undenormalise(r);
}
+ _FORCE_INLINE_ AudioFrame linear_interpolate(const AudioFrame &p_b, float p_t) const {
+
+ AudioFrame res = *this;
+
+ res.l += (p_t * (p_b.l - l));
+ res.r += (p_t * (p_b.r - r));
+
+ return res;
+ }
+
_ALWAYS_INLINE_ AudioFrame(float p_l, float p_r) {
l = p_l;
r = p_r;
diff --git a/core/math/camera_matrix.cpp b/core/math/camera_matrix.cpp
index 33ad522315..a1666ccd8b 100644
--- a/core/math/camera_matrix.cpp
+++ b/core/math/camera_matrix.cpp
@@ -91,6 +91,72 @@ void CameraMatrix::set_perspective(real_t p_fovy_degrees, real_t p_aspect, real_
matrix[3][3] = 0;
}
+void CameraMatrix::set_perspective(real_t p_fovy_degrees, real_t p_aspect, real_t p_z_near, real_t p_z_far, bool p_flip_fov, int p_eye, real_t p_intraocular_dist, real_t p_convergence_dist) {
+ if (p_flip_fov) {
+ p_fovy_degrees = get_fovy(p_fovy_degrees, 1.0 / p_aspect);
+ }
+
+ real_t left, right, modeltranslation, ymax, xmax, frustumshift;
+
+ ymax = p_z_near * tan(p_fovy_degrees * Math_PI / 360.0f);
+ xmax = ymax * p_aspect;
+ frustumshift = (p_intraocular_dist / 2.0) * p_z_near / p_convergence_dist;
+
+ switch (p_eye) {
+ case 1: { // left eye
+ left = -xmax + frustumshift;
+ right = xmax + frustumshift;
+ modeltranslation = p_intraocular_dist / 2.0;
+ }; break;
+ case 2: { // right eye
+ left = -xmax - frustumshift;
+ right = xmax - frustumshift;
+ modeltranslation = -p_intraocular_dist / 2.0;
+ }; break;
+ default: { // mono, should give the same result as set_perspective(p_fovy_degrees,p_aspect,p_z_near,p_z_far,p_flip_fov)
+ left = -xmax;
+ right = xmax;
+ modeltranslation = 0.0;
+ }; break;
+ };
+
+ set_frustum(left, right, -ymax, ymax, p_z_near, p_z_far);
+
+ // translate matrix by (modeltranslation, 0.0, 0.0)
+ CameraMatrix cm;
+ cm.set_identity();
+ cm.matrix[3][0] = modeltranslation;
+ *this = *this * cm;
+}
+
+void CameraMatrix::set_for_hmd(int p_eye, real_t p_aspect, real_t p_intraocular_dist, real_t p_display_width, real_t p_display_to_lens, real_t p_oversample, real_t p_z_near, real_t p_z_far) {
+ // we first calculate our base frustum on our values without taking our lens magnification into account.
+ real_t display_to_eye = 2.0 * p_display_to_lens;
+ real_t f1 = (p_intraocular_dist * 0.5) / p_display_to_lens;
+ real_t f2 = ((p_display_width - p_intraocular_dist) * 0.5) / p_display_to_lens;
+ real_t f3 = (p_display_width / 4.0) / p_display_to_lens;
+
+ // now we apply our oversample factor to increase our FOV. how much we oversample is always a balance we strike between performance and how much
+ // we're willing to sacrifice in FOV.
+ real_t add = ((f1 + f2) * (p_oversample - 1.0)) / 2.0;
+ f1 += add;
+ f2 += add;
+
+ // always apply KEEP_WIDTH aspect ratio
+ f3 *= p_aspect;
+
+ switch (p_eye) {
+ case 1: { // left eye
+ set_frustum(-f2 * p_z_near, f1 * p_z_near, -f3 * p_z_near, f3 * p_z_near, p_z_near, p_z_far);
+ }; break;
+ case 2: { // right eye
+ set_frustum(-f1 * p_z_near, f2 * p_z_near, -f3 * p_z_near, f3 * p_z_near, p_z_near, p_z_far);
+ }; break;
+ default: { // mono, does not apply here!
+ }; break;
+ };
+};
+
void CameraMatrix::set_orthogonal(real_t p_left, real_t p_right, real_t p_bottom, real_t p_top, real_t p_znear, real_t p_zfar) {
set_identity();
@@ -243,23 +309,44 @@ bool CameraMatrix::get_endpoints(const Transform &p_transform, Vector3 *p_8point
-matrix[15] + matrix[13]);
top_plane.normalize();
- Vector3 near_endpoint;
- Vector3 far_endpoint;
+ Vector3 near_endpoint_left, near_endpoint_right;
+ Vector3 far_endpoint_left, far_endpoint_right;
- bool res = near_plane.intersect_3(right_plane, top_plane, &near_endpoint);
+ bool res = near_plane.intersect_3(right_plane, top_plane, &near_endpoint_right);
ERR_FAIL_COND_V(!res, false);
- res = far_plane.intersect_3(right_plane, top_plane, &far_endpoint);
+ res = far_plane.intersect_3(right_plane, top_plane, &far_endpoint_right);
ERR_FAIL_COND_V(!res, false);
- p_8points[0] = p_transform.xform(Vector3(near_endpoint.x, near_endpoint.y, near_endpoint.z));
- p_8points[1] = p_transform.xform(Vector3(near_endpoint.x, -near_endpoint.y, near_endpoint.z));
- p_8points[2] = p_transform.xform(Vector3(-near_endpoint.x, near_endpoint.y, near_endpoint.z));
- p_8points[3] = p_transform.xform(Vector3(-near_endpoint.x, -near_endpoint.y, near_endpoint.z));
- p_8points[4] = p_transform.xform(Vector3(far_endpoint.x, far_endpoint.y, far_endpoint.z));
- p_8points[5] = p_transform.xform(Vector3(far_endpoint.x, -far_endpoint.y, far_endpoint.z));
- p_8points[6] = p_transform.xform(Vector3(-far_endpoint.x, far_endpoint.y, far_endpoint.z));
- p_8points[7] = p_transform.xform(Vector3(-far_endpoint.x, -far_endpoint.y, far_endpoint.z));
+ if ((matrix[8] == 0) && (matrix[9] == 0)) {
+ near_endpoint_left = near_endpoint_right;
+ near_endpoint_left.x = -near_endpoint_left.x;
+
+ far_endpoint_left = far_endpoint_right;
+ far_endpoint_left.x = -far_endpoint_left.x;
+ } else {
+ ///////--- Left Plane ---///////
+ Plane left_plane = Plane(matrix[0] + matrix[3],
+ matrix[4] + matrix[7],
+ matrix[8] + matrix[11],
+ -matrix[15] - matrix[12]);
+ left_plane.normalize();
+
+ res = near_plane.intersect_3(left_plane, top_plane, &near_endpoint_left);
+ ERR_FAIL_COND_V(!res, false);
+
+ res = far_plane.intersect_3(left_plane, top_plane, &far_endpoint_left);
+ ERR_FAIL_COND_V(!res, false);
+ }
+
+ p_8points[0] = p_transform.xform(Vector3(near_endpoint_right.x, near_endpoint_right.y, near_endpoint_right.z));
+ p_8points[1] = p_transform.xform(Vector3(near_endpoint_right.x, -near_endpoint_right.y, near_endpoint_right.z));
+ p_8points[2] = p_transform.xform(Vector3(near_endpoint_left.x, near_endpoint_left.y, near_endpoint_left.z));
+ p_8points[3] = p_transform.xform(Vector3(near_endpoint_left.x, -near_endpoint_left.y, near_endpoint_left.z));
+ p_8points[4] = p_transform.xform(Vector3(far_endpoint_right.x, far_endpoint_right.y, far_endpoint_right.z));
+ p_8points[5] = p_transform.xform(Vector3(far_endpoint_right.x, -far_endpoint_right.y, far_endpoint_right.z));
+ p_8points[6] = p_transform.xform(Vector3(far_endpoint_left.x, far_endpoint_left.y, far_endpoint_left.z));
+ p_8points[7] = p_transform.xform(Vector3(far_endpoint_left.x, -far_endpoint_left.y, far_endpoint_left.z));
return true;
}
@@ -546,7 +633,18 @@ real_t CameraMatrix::get_fov() const {
-matrix[15] + matrix[12]);
right_plane.normalize();
- return Math::rad2deg(Math::acos(Math::abs(right_plane.normal.x))) * 2.0;
+ if ((matrix[8] == 0) && (matrix[9] == 0)) {
+ return Math::rad2deg(Math::acos(Math::abs(right_plane.normal.x))) * 2.0;
+ } else {
+ // our frustum is asymetrical need to calculate the left planes angle seperately..
+ Plane left_plane = Plane(matrix[3] + matrix[0],
+ matrix[7] + matrix[4],
+ matrix[11] + matrix[8],
+ matrix[15] + matrix[12]);
+ left_plane.normalize();
+
+ return Math::rad2deg(Math::acos(Math::abs(left_plane.normal.x))) + Math::rad2deg(Math::acos(Math::abs(right_plane.normal.x)));
+ }
}
void CameraMatrix::make_scale(const Vector3 &p_scale) {
diff --git a/core/math/camera_matrix.h b/core/math/camera_matrix.h
index af61e35993..4be8ffab8c 100644
--- a/core/math/camera_matrix.h
+++ b/core/math/camera_matrix.h
@@ -54,6 +54,8 @@ struct CameraMatrix {
void set_light_bias();
void set_light_atlas_rect(const Rect2 &p_rect);
void set_perspective(real_t p_fovy_degrees, real_t p_aspect, real_t p_z_near, real_t p_z_far, bool p_flip_fov = false);
+ void set_perspective(real_t p_fovy_degrees, real_t p_aspect, real_t p_z_near, real_t p_z_far, bool p_flip_fov, int p_eye, real_t p_intraocular_dist, real_t p_convergence_dist);
+ void set_for_hmd(int p_eye, real_t p_aspect, real_t p_intraocular_dist, real_t p_display_width, real_t p_display_to_lens, real_t p_oversample, real_t p_z_near, real_t p_z_far);
void set_orthogonal(real_t p_left, real_t p_right, real_t p_bottom, real_t p_top, real_t p_znear, real_t p_zfar);
void set_orthogonal(real_t p_size, real_t p_aspect, real_t p_znear, real_t p_zfar, bool p_flip_fov = false);
void set_frustum(real_t p_left, real_t p_right, real_t p_bottom, real_t p_top, real_t p_near, real_t p_far);
diff --git a/core/math/face3.cpp b/core/math/face3.cpp
index 5b66e1999a..0e292500bf 100644
--- a/core/math/face3.cpp
+++ b/core/math/face3.cpp
@@ -272,8 +272,8 @@ void Face3::project_range(const Vector3 &p_normal, const Transform &p_transform,
void Face3::get_support(const Vector3 &p_normal, const Transform &p_transform, Vector3 *p_vertices, int *p_count, int p_max) const {
-#define _FACE_IS_VALID_SUPPORT_TRESHOLD 0.98
-#define _EDGE_IS_VALID_SUPPORT_TRESHOLD 0.05
+#define _FACE_IS_VALID_SUPPORT_THRESHOLD 0.98
+#define _EDGE_IS_VALID_SUPPORT_THRESHOLD 0.05
if (p_max <= 0)
return;
@@ -281,7 +281,7 @@ void Face3::get_support(const Vector3 &p_normal, const Transform &p_transform, V
Vector3 n = p_transform.basis.xform_inv(p_normal);
/** TEST FACE AS SUPPORT **/
- if (get_plane().normal.dot(n) > _FACE_IS_VALID_SUPPORT_TRESHOLD) {
+ if (get_plane().normal.dot(n) > _FACE_IS_VALID_SUPPORT_THRESHOLD) {
*p_count = MIN(3, p_max);
@@ -318,7 +318,7 @@ void Face3::get_support(const Vector3 &p_normal, const Transform &p_transform, V
// check if edge is valid as a support
real_t dot = (vertex[i] - vertex[(i + 1) % 3]).normalized().dot(n);
dot = ABS(dot);
- if (dot < _EDGE_IS_VALID_SUPPORT_TRESHOLD) {
+ if (dot < _EDGE_IS_VALID_SUPPORT_THRESHOLD) {
*p_count = MIN(2, p_max);
diff --git a/core/math/face3.h b/core/math/face3.h
index 1cc94321c3..3d02ae4014 100644
--- a/core/math/face3.h
+++ b/core/math/face3.h
@@ -115,20 +115,20 @@ bool Face3::intersects_aabb2(const Rect3 &p_aabb) const {
if (dist_a * dist_b > 0)
return false; //does not intersect the plane
-#define TEST_AXIS(m_ax) \
- { \
+#define TEST_AXIS(m_ax) \
+ { \
real_t aabb_min = p_aabb.position.m_ax; \
real_t aabb_max = p_aabb.position.m_ax + p_aabb.size.m_ax; \
- real_t tri_min, tri_max; \
- for (int i = 0; i < 3; i++) { \
- if (i == 0 || vertex[i].m_ax > tri_max) \
- tri_max = vertex[i].m_ax; \
- if (i == 0 || vertex[i].m_ax < tri_min) \
- tri_min = vertex[i].m_ax; \
- } \
- \
- if (tri_max < aabb_min || aabb_max < tri_min) \
- return false; \
+ real_t tri_min, tri_max; \
+ for (int i = 0; i < 3; i++) { \
+ if (i == 0 || vertex[i].m_ax > tri_max) \
+ tri_max = vertex[i].m_ax; \
+ if (i == 0 || vertex[i].m_ax < tri_min) \
+ tri_min = vertex[i].m_ax; \
+ } \
+ \
+ if (tri_max < aabb_min || aabb_max < tri_min) \
+ return false; \
}
TEST_AXIS(x);
diff --git a/core/math/matrix3.cpp b/core/math/matrix3.cpp
index c733251c3c..b59fecc196 100644
--- a/core/math/matrix3.cpp
+++ b/core/math/matrix3.cpp
@@ -451,9 +451,10 @@ Basis::operator String() const {
}
Basis::operator Quat() const {
-#ifdef MATH_CHECKS
- ERR_FAIL_COND_V(is_rotation() == false, Quat());
-#endif
+ //commenting this check because precision issues cause it to fail when it shouldn't
+ //#ifdef MATH_CHECKS
+ //ERR_FAIL_COND_V(is_rotation() == false, Quat());
+ //#endif
real_t trace = elements[0][0] + elements[1][1] + elements[2][2];
real_t temp[4];
diff --git a/core/math/quick_hull.cpp b/core/math/quick_hull.cpp
index 9f594ba4fa..54b97ac38c 100644
--- a/core/math/quick_hull.cpp
+++ b/core/math/quick_hull.cpp
@@ -58,7 +58,7 @@ Error QuickHull::build(const Vector<Vector3> &p_points, Geometry::MeshData &r_me
for (int i = 0; i < p_points.size(); i++) {
- Vector3 sp = p_points[i].snapped(0.0001);
+ Vector3 sp = p_points[i].snapped(Vector3(0.0001, 0.0001, 0.0001));
if (valid_cache.has(sp)) {
valid_points[i] = false;
//print_line("INVALIDATED: "+itos(i));
diff --git a/core/math/triangle_mesh.cpp b/core/math/triangle_mesh.cpp
index 08ac08d776..1df3c8c298 100644
--- a/core/math/triangle_mesh.cpp
+++ b/core/math/triangle_mesh.cpp
@@ -117,7 +117,7 @@ void TriangleMesh::create(const PoolVector<Vector3> &p_faces) {
for (int j = 0; j < 3; j++) {
int vidx = -1;
- Vector3 vs = v[j].snapped(0.0001);
+ Vector3 vs = v[j].snapped(Vector3(0.0001, 0.0001, 0.0001));
Map<Vector3, int>::Element *E = db.find(vs);
if (E) {
vidx = E->get();
diff --git a/core/math/vector3.cpp b/core/math/vector3.cpp
index e413cc147d..efffacb36e 100644
--- a/core/math/vector3.cpp
+++ b/core/math/vector3.cpp
@@ -61,13 +61,13 @@ int Vector3::max_axis() const {
return x < y ? (y < z ? 2 : 1) : (x < z ? 2 : 0);
}
-void Vector3::snap(real_t p_val) {
+void Vector3::snap(Vector3 p_val) {
- x = Math::stepify(x, p_val);
- y = Math::stepify(y, p_val);
- z = Math::stepify(z, p_val);
+ x = Math::stepify(x, p_val.x);
+ y = Math::stepify(y, p_val.y);
+ z = Math::stepify(z, p_val.z);
}
-Vector3 Vector3::snapped(real_t p_val) const {
+Vector3 Vector3::snapped(Vector3 p_val) const {
Vector3 v = *this;
v.snap(p_val);
diff --git a/core/math/vector3.h b/core/math/vector3.h
index 5f4390fbd1..6a7974681e 100644
--- a/core/math/vector3.h
+++ b/core/math/vector3.h
@@ -81,8 +81,8 @@ struct Vector3 {
_FORCE_INLINE_ void zero();
- void snap(real_t p_val);
- Vector3 snapped(real_t p_val) const;
+ void snap(Vector3 p_val);
+ Vector3 snapped(Vector3 p_val) const;
void rotate(const Vector3 &p_axis, real_t p_phi);
Vector3 rotated(const Vector3 &p_axis, real_t p_phi) const;
@@ -100,6 +100,7 @@ struct Vector3 {
_FORCE_INLINE_ Vector3 abs() const;
_FORCE_INLINE_ Vector3 floor() const;
+ _FORCE_INLINE_ Vector3 sign() const;
_FORCE_INLINE_ Vector3 ceil() const;
_FORCE_INLINE_ real_t distance_to(const Vector3 &p_b) const;
@@ -187,6 +188,11 @@ Vector3 Vector3::abs() const {
return Vector3(Math::abs(x), Math::abs(y), Math::abs(z));
}
+Vector3 Vector3::sign() const {
+
+ return Vector3(SGN(x), SGN(y), SGN(z));
+}
+
Vector3 Vector3::floor() const {
return Vector3(Math::floor(x), Math::floor(y), Math::floor(z));
diff --git a/core/message_queue.cpp b/core/message_queue.cpp
index d7d31b6c1e..93d0b0730a 100644
--- a/core/message_queue.cpp
+++ b/core/message_queue.cpp
@@ -29,7 +29,7 @@
/*************************************************************************/
#include "message_queue.h"
-#include "global_config.h"
+#include "project_settings.h"
#include "script_language.h"
MessageQueue *MessageQueue::singleton = NULL;
@@ -382,7 +382,7 @@ MessageQueue::MessageQueue() {
buffer_end = 0;
buffer_max_used = 0;
- buffer_size = GLOBAL_DEF("memory/buffers/message_queue_max_size_kb", DEFAULT_QUEUE_SIZE_KB);
+ buffer_size = GLOBAL_DEF("memory/limits/message_queue/max_size_kb", DEFAULT_QUEUE_SIZE_KB);
buffer_size *= 1024;
buffer = memnew_arr(uint8_t, buffer_size);
}
diff --git a/core/method_ptrcall.h b/core/method_ptrcall.h
index c6dbfc2a7a..ead58c23c8 100644
--- a/core/method_ptrcall.h
+++ b/core/method_ptrcall.h
@@ -60,37 +60,37 @@ struct PtrToArg {
} \
}
-#define MAKE_PTRARGR(m_type, m_ret) \
- template <> \
- struct PtrToArg<m_type> { \
- _FORCE_INLINE_ static m_type convert(const void *p_ptr) { \
- return *reinterpret_cast<const m_type *>(p_ptr); \
- } \
- _FORCE_INLINE_ static void encode(m_type p_val, void *p_ptr) { \
- *((m_ret *)p_ptr) = p_val; \
- } \
- }; \
- template <> \
- struct PtrToArg<const m_type &> { \
- _FORCE_INLINE_ static m_type convert(const void *p_ptr) { \
- return *reinterpret_cast<const m_type *>(p_ptr); \
- } \
- _FORCE_INLINE_ static void encode(m_type p_val, void *p_ptr) { \
- *((m_ret *)p_ptr) = p_val; \
- } \
+#define MAKE_PTRARGCONV(m_type, m_conv) \
+ template <> \
+ struct PtrToArg<m_type> { \
+ _FORCE_INLINE_ static m_type convert(const void *p_ptr) { \
+ return static_cast<m_type>(*reinterpret_cast<const m_conv *>(p_ptr)); \
+ } \
+ _FORCE_INLINE_ static void encode(m_type p_val, void *p_ptr) { \
+ *((m_conv *)p_ptr) = static_cast<m_conv>(p_val); \
+ } \
+ }; \
+ template <> \
+ struct PtrToArg<const m_type &> { \
+ _FORCE_INLINE_ static m_type convert(const void *p_ptr) { \
+ return static_cast<m_type>(*reinterpret_cast<const m_conv *>(p_ptr)); \
+ } \
+ _FORCE_INLINE_ static void encode(m_type p_val, void *p_ptr) { \
+ *((m_conv *)p_ptr) = static_cast<m_conv>(p_val); \
+ } \
}
MAKE_PTRARG(bool);
-MAKE_PTRARGR(uint8_t, int);
-MAKE_PTRARGR(int8_t, int);
-MAKE_PTRARGR(uint16_t, int);
-MAKE_PTRARGR(int16_t, int);
-MAKE_PTRARGR(uint32_t, int);
-MAKE_PTRARGR(int32_t, int);
-MAKE_PTRARGR(int64_t, int);
-MAKE_PTRARGR(uint64_t, int);
-MAKE_PTRARG(float);
-MAKE_PTRARGR(double, float);
+MAKE_PTRARGCONV(uint8_t, int64_t);
+MAKE_PTRARGCONV(int8_t, int64_t);
+MAKE_PTRARGCONV(uint16_t, int64_t);
+MAKE_PTRARGCONV(int16_t, int64_t);
+MAKE_PTRARGCONV(uint32_t, int64_t);
+MAKE_PTRARGCONV(int32_t, int64_t);
+MAKE_PTRARG(int64_t);
+MAKE_PTRARG(uint64_t);
+MAKE_PTRARGCONV(float, double);
+MAKE_PTRARG(double);
MAKE_PTRARG(String);
MAKE_PTRARG(Vector2);
diff --git a/core/object.cpp b/core/object.cpp
index 3416cd8c5a..316c624268 100644
--- a/core/object.cpp
+++ b/core/object.cpp
@@ -993,6 +993,17 @@ void Object::cancel_delete() {
_predelete_ok = true;
}
+void Object::set_script_and_instance(const RefPtr &p_script, ScriptInstance *p_instance) {
+
+ //this function is not meant to be used in any of these ways
+ ERR_FAIL_COND(p_script.is_null());
+ ERR_FAIL_COND(!p_instance);
+ ERR_FAIL_COND(script_instance != NULL || !script.is_null());
+
+ script = p_script;
+ script_instance = p_instance;
+}
+
void Object::set_script(const RefPtr &p_script) {
if (script == p_script)
@@ -1655,7 +1666,7 @@ void Object::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_script:Script"), &Object::get_script);
ClassDB::bind_method(D_METHOD("set_meta", "name", "value"), &Object::set_meta);
- ClassDB::bind_method(D_METHOD("get_meta", "name", "value"), &Object::get_meta);
+ ClassDB::bind_method(D_METHOD("get_meta:Variant", "name", "value"), &Object::get_meta);
ClassDB::bind_method(D_METHOD("has_meta", "name"), &Object::has_meta);
ClassDB::bind_method(D_METHOD("get_meta_list"), &Object::_get_meta_list_bind);
@@ -1723,7 +1734,7 @@ void Object::_bind_methods() {
BIND_VMETHOD(MethodInfo("_set", PropertyInfo(Variant::STRING, "property"), PropertyInfo(Variant::NIL, "value")));
#ifdef TOOLS_ENABLED
MethodInfo miget("_get", PropertyInfo(Variant::STRING, "property"));
- miget.return_val.name = "var";
+ miget.return_val.name = "Variant";
BIND_VMETHOD(miget);
MethodInfo plget("_get_property_list");
@@ -1817,6 +1828,23 @@ uint32_t Object::get_edited_version() const {
}
#endif
+void *Object::get_script_instance_binding(int p_script_language_index) {
+#ifdef DEBUG_ENABLED
+ ERR_FAIL_INDEX_V(p_script_language_index, MAX_SCRIPT_INSTANCE_BINDINGS, NULL);
+#endif
+
+ //it's up to the script language to make this thread safe, if the function is called twice due to threads being out of syncro
+ //just return the same pointer.
+ //if you want to put a big lock in the entire function and keep allocated pointers in a map or something, feel free to do it
+ //as it should not really affect performance much (won't be called too often), as in far most caes the condition below will be false afterwards
+
+ if (!_script_instance_bindings[p_script_language_index]) {
+ _script_instance_bindings[p_script_language_index] = ScriptServer::get_language(p_script_language_index)->alloc_instance_binding_data(this);
+ }
+
+ return _script_instance_bindings[p_script_language_index];
+}
+
Object::Object() {
_class_ptr = NULL;
@@ -1826,6 +1854,7 @@ Object::Object() {
_instance_ID = ObjectDB::add_instance(this);
_can_translate = true;
_is_queued_for_deletion = false;
+ memset(_script_instance_bindings, 0, sizeof(void *) * MAX_SCRIPT_INSTANCE_BINDINGS);
script_instance = NULL;
#ifdef TOOLS_ENABLED
@@ -1877,6 +1906,12 @@ Object::~Object() {
ObjectDB::remove_instance(this);
_instance_ID = 0;
_predelete_ok = 2;
+
+ for (int i = 0; i < MAX_SCRIPT_INSTANCE_BINDINGS; i++) {
+ if (_script_instance_bindings[i]) {
+ ScriptServer::get_language(i)->free_instance_binding_data(_script_instance_bindings[i]);
+ }
+ }
}
bool predelete_handler(Object *p_object) {
diff --git a/core/object.h b/core/object.h
index dec4949c8d..148a73fbc4 100644
--- a/core/object.h
+++ b/core/object.h
@@ -381,6 +381,10 @@ public:
};
private:
+ enum {
+ MAX_SCRIPT_INSTANCE_BINDINGS = 8
+ };
+
#ifdef DEBUG_ENABLED
friend class _ObjectDebugLock;
#endif
@@ -447,6 +451,8 @@ private:
void _set_bind(const String &p_set, const Variant &p_value);
Variant _get_bind(const String &p_name) const;
+ void *_script_instance_bindings[MAX_SCRIPT_INSTANCE_BINDINGS];
+
void property_list_changed_notify();
protected:
@@ -533,6 +539,12 @@ public:
void add_change_receptor(Object *p_receptor);
void remove_change_receptor(Object *p_receptor);
+// TODO: ensure 'this' is never NULL since it's UB, but by now, avoid warning flood
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wundefined-bool-conversion"
+#endif
+
template <class T>
T *cast_to() {
@@ -563,6 +575,10 @@ public:
#endif
}
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
+
enum {
NOTIFICATION_POSTINITIALIZE = 0,
@@ -635,6 +651,8 @@ public:
void set_script_instance(ScriptInstance *p_instance);
_FORCE_INLINE_ ScriptInstance *get_script_instance() const { return script_instance; }
+ void set_script_and_instance(const RefPtr &p_script, ScriptInstance *p_instance); //some script languages can't control instance creation, so this function eases the process
+
void add_user_signal(const MethodInfo &p_signal);
void emit_signal(const StringName &p_name, VARIANT_ARG_LIST);
void emit_signal(const StringName &p_name, const Variant **p_args, int p_argcount);
@@ -673,6 +691,9 @@ public:
bool editor_is_section_unfolded(const String &p_section);
#endif
+ //used by script languages to store binding data
+ void *get_script_instance_binding(int p_script_language_index);
+
void clear_internal_resource_paths();
Object();
diff --git a/core/os/dir_access.cpp b/core/os/dir_access.cpp
index aa03b764ef..391ae78c85 100644
--- a/core/os/dir_access.cpp
+++ b/core/os/dir_access.cpp
@@ -28,16 +28,16 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "dir_access.h"
-#include "global_config.h"
#include "os/file_access.h"
#include "os/memory.h"
#include "os/os.h"
+#include "project_settings.h"
String DirAccess::_get_root_path() const {
switch (_access_type) {
- case ACCESS_RESOURCES: return GlobalConfig::get_singleton()->get_resource_path();
+ case ACCESS_RESOURCES: return ProjectSettings::get_singleton()->get_resource_path();
case ACCESS_USERDATA: return OS::get_singleton()->get_data_dir();
default: return "";
}
@@ -200,10 +200,10 @@ String DirAccess::fix_path(String p_path) const {
case ACCESS_RESOURCES: {
- if (GlobalConfig::get_singleton()) {
+ if (ProjectSettings::get_singleton()) {
if (p_path.begins_with("res://")) {
- String resource_path = GlobalConfig::get_singleton()->get_resource_path();
+ String resource_path = ProjectSettings::get_singleton()->get_resource_path();
if (resource_path != "") {
return p_path.replace_first("res:/", resource_path);
diff --git a/core/os/file_access.cpp b/core/os/file_access.cpp
index 805b66b983..3bd5ac3f41 100644
--- a/core/os/file_access.cpp
+++ b/core/os/file_access.cpp
@@ -31,8 +31,8 @@
#include "core/io/file_access_pack.h"
#include "core/io/marshalls.h"
-#include "global_config.h"
#include "os/os.h"
+#include "project_settings.h"
#include "thirdparty/misc/md5.h"
#include "thirdparty/misc/sha256.h"
@@ -135,10 +135,10 @@ String FileAccess::fix_path(const String &p_path) const {
case ACCESS_RESOURCES: {
- if (GlobalConfig::get_singleton()) {
+ if (ProjectSettings::get_singleton()) {
if (r_path.begins_with("res://")) {
- String resource_path = GlobalConfig::get_singleton()->get_resource_path();
+ String resource_path = ProjectSettings::get_singleton()->get_resource_path();
if (resource_path != "") {
return r_path.replace("res:/", resource_path);
@@ -300,6 +300,8 @@ Vector<String> FileAccess::get_csv_line(String delim) const {
String l;
int qc = 0;
do {
+ ERR_FAIL_COND_V(eof_reached(), Vector<String>());
+
l += get_line() + "\n";
qc = 0;
for (int i = 0; i < l.length(); i++) {
diff --git a/core/os/input.cpp b/core/os/input.cpp
index bc388d0bca..a90a552d1d 100644
--- a/core/os/input.cpp
+++ b/core/os/input.cpp
@@ -28,9 +28,9 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "input.h"
-#include "global_config.h"
#include "input_map.h"
#include "os/os.h"
+#include "project_settings.h"
Input *Input::singleton = NULL;
Input *Input::get_singleton() {
@@ -84,7 +84,7 @@ void Input::_bind_methods() {
ClassDB::bind_method(D_METHOD("action_press", "action"), &Input::action_press);
ClassDB::bind_method(D_METHOD("action_release", "action"), &Input::action_release);
ClassDB::bind_method(D_METHOD("set_custom_mouse_cursor", "image:Texture", "hotspot"), &Input::set_custom_mouse_cursor, DEFVAL(Vector2()));
- ClassDB::bind_method(D_METHOD("parse_input_event", "event"), &Input::parse_input_event);
+ ClassDB::bind_method(D_METHOD("parse_input_event", "event:InputEvent"), &Input::parse_input_event);
BIND_CONSTANT(MOUSE_MODE_VISIBLE);
BIND_CONSTANT(MOUSE_MODE_HIDDEN);
@@ -101,7 +101,7 @@ void Input::get_argument_options(const StringName &p_function, int p_idx, List<S
if (p_idx == 0 && (pf == "is_action_pressed" || pf == "action_press" || pf == "action_release" || pf == "is_action_just_pressed" || pf == "is_action_just_released")) {
List<PropertyInfo> pinfo;
- GlobalConfig::get_singleton()->get_property_list(&pinfo);
+ ProjectSettings::get_singleton()->get_property_list(&pinfo);
for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
const PropertyInfo &pi = E->get();
diff --git a/core/os/input_event.cpp b/core/os/input_event.cpp
index 1c575aa970..0a07b6b2b7 100644
--- a/core/os/input_event.cpp
+++ b/core/os/input_event.cpp
@@ -103,7 +103,7 @@ bool InputEvent::is_action_type() const {
if (String(p_method) == "is_action" && p_argidx == 0) {
List<PropertyInfo> pinfo;
- GlobalConfig::get_singleton()->get_property_list(&pinfo);
+ ProjectSettings::get_singleton()->get_property_list(&pinfo);
for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
const PropertyInfo &pi = E->get();
diff --git a/core/os/keyboard.cpp b/core/os/keyboard.cpp
index 2f5dc03614..e154b1934d 100644
--- a/core/os/keyboard.cpp
+++ b/core/os/keyboard.cpp
@@ -81,7 +81,6 @@ static const _KeyCodeText _keycodes[] = {
{KEY_F14 ,"F14"},
{KEY_F15 ,"F15"},
{KEY_F16 ,"F16"},
- {KEY_KP_ENTER ,"Kp Enter"},
{KEY_KP_MULTIPLY ,"Kp Multiply"},
{KEY_KP_DIVIDE ,"Kp Divide"},
{KEY_KP_SUBTRACT ,"Kp Subtract"},
@@ -334,7 +333,6 @@ bool keycode_has_unicode(uint32_t p_keycode) {
case KEY_F14:
case KEY_F15:
case KEY_F16:
- case KEY_KP_ENTER:
case KEY_SUPER_L:
case KEY_SUPER_R:
case KEY_MENU:
diff --git a/core/os/keyboard.h b/core/os/keyboard.h
index 0a72663867..c6985c887d 100644
--- a/core/os/keyboard.h
+++ b/core/os/keyboard.h
@@ -96,7 +96,6 @@ enum KeyList {
KEY_F14 = SPKEY | 0x29,
KEY_F15 = SPKEY | 0x2A,
KEY_F16 = SPKEY | 0x2B,
- KEY_KP_ENTER = SPKEY | 0x80,
KEY_KP_MULTIPLY = SPKEY | 0x81,
KEY_KP_DIVIDE = SPKEY | 0x82,
KEY_KP_SUBTRACT = SPKEY | 0x83,
diff --git a/core/os/main_loop.cpp b/core/os/main_loop.cpp
index 248f5537c6..93658c07c2 100644
--- a/core/os/main_loop.cpp
+++ b/core/os/main_loop.cpp
@@ -32,7 +32,7 @@
void MainLoop::_bind_methods() {
- ClassDB::bind_method(D_METHOD("input_event", "ev"), &MainLoop::input_event);
+ ClassDB::bind_method(D_METHOD("input_event", "ev:InputEvent"), &MainLoop::input_event);
ClassDB::bind_method(D_METHOD("input_text", "text"), &MainLoop::input_text);
ClassDB::bind_method(D_METHOD("init"), &MainLoop::init);
ClassDB::bind_method(D_METHOD("iteration", "delta"), &MainLoop::iteration);
diff --git a/core/os/os.cpp b/core/os/os.cpp
index 8bee725813..8e4c357195 100644
--- a/core/os/os.cpp
+++ b/core/os/os.cpp
@@ -30,9 +30,9 @@
#include "os.h"
#include "dir_access.h"
-#include "global_config.h"
#include "input.h"
#include "os/file_access.h"
+#include "project_settings.h"
#include <stdarg.h>
@@ -260,7 +260,7 @@ String OS::get_locale() const {
String OS::get_resource_dir() const {
- return GlobalConfig::get_singleton()->get_resource_path();
+ return ProjectSettings::get_singleton()->get_resource_path();
}
String OS::get_system_dir(SystemDir p_dir) const {
@@ -269,7 +269,7 @@ String OS::get_system_dir(SystemDir p_dir) const {
}
String OS::get_safe_application_name() const {
- String an = GlobalConfig::get_singleton()->get("application/name");
+ String an = ProjectSettings::get_singleton()->get("application/config/name");
Vector<String> invalid_char = String("\\ / : * ? \" < > |").split(" ");
for (int i = 0; i < invalid_char.size(); i++) {
an = an.replace(invalid_char[i], "-");
@@ -494,7 +494,31 @@ int OS::get_power_percent_left() {
return -1;
}
+bool OS::check_feature_support(const String &p_feature) {
+
+ if (p_feature == get_name())
+ return true;
+#ifdef DEBUG_ENABLED
+ if (p_feature == "debug")
+ return true;
+#else
+ if (p_feature == "release")
+ return true;
+#endif
+
+ if (_check_internal_feature_support(p_feature))
+ return true;
+
+ return false;
+}
+
+void *OS::get_stack_bottom() const {
+ return _stack_bottom;
+}
+
OS::OS() {
+ void *volatile stack_bottom;
+
last_error = NULL;
singleton = this;
_keep_screen_on = true; // set default value to true, because this had been true before godot 2.0.
@@ -507,6 +531,7 @@ OS::OS() {
_render_thread_mode = RENDER_THREAD_SAFE;
_allow_hidpi = true;
+ _stack_bottom = (void *)(&stack_bottom);
}
OS::~OS() {
diff --git a/core/os/os.h b/core/os/os.h
index 11fe8b44e3..703c6a6bcd 100644
--- a/core/os/os.h
+++ b/core/os/os.h
@@ -60,6 +60,8 @@ class OS {
char *last_error;
+ void *_stack_bottom;
+
public:
enum RenderThreadMode {
@@ -109,6 +111,7 @@ protected:
virtual void set_cmdline(const char *p_execpath, const List<String> &p_args);
void _ensure_data_dir();
+ virtual bool _check_internal_feature_support(const String &p_feature) = 0;
public:
typedef int64_t ProcessID;
@@ -179,9 +182,11 @@ public:
virtual void set_borderless_window(int p_borderless) {}
virtual bool get_borderless_window() { return 0; }
- virtual Error open_dynamic_library(const String p_path, void *&p_library_handle) { return ERR_UNAVAILABLE; };
- virtual Error close_dynamic_library(void *p_library_handle) { return ERR_UNAVAILABLE; };
- virtual Error get_dynamic_library_symbol_handle(void *p_library_handle, const String p_name, void *&p_symbol_handle) { return ERR_UNAVAILABLE; };
+ virtual void set_ime_position(const Point2 &p_pos) {}
+
+ virtual Error open_dynamic_library(const String p_path, void *&p_library_handle) { return ERR_UNAVAILABLE; }
+ virtual Error close_dynamic_library(void *p_library_handle) { return ERR_UNAVAILABLE; }
+ virtual Error get_dynamic_library_symbol_handle(void *p_library_handle, const String p_name, void *&p_symbol_handle, bool p_optional = false) { return ERR_UNAVAILABLE; }
virtual void set_keep_screen_on(bool p_enabled);
virtual bool is_keep_screen_on() const;
@@ -406,7 +411,14 @@ public:
virtual int get_power_seconds_left();
virtual int get_power_percent_left();
- virtual bool check_feature_support(const String &p_feature) = 0;
+ bool check_feature_support(const String &p_feature);
+
+ /**
+ * Returns the stack bottom of the main thread of the application.
+ * This may be of use when integrating languages with garbage collectors that
+ * need to check whether a pointer is on the stack.
+ */
+ virtual void *get_stack_bottom() const;
bool is_hidpi_allowed() const { return _allow_hidpi; }
OS();
diff --git a/core/global_config.cpp b/core/project_settings.cpp
index ba0a7f3e31..b31f78ec20 100644
--- a/core/global_config.cpp
+++ b/core/project_settings.cpp
@@ -27,9 +27,10 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "global_config.h"
+#include "project_settings.h"
#include "bind/core_bind.h"
+#include "core_string_names.h"
#include "io/file_access_network.h"
#include "io/file_access_pack.h"
#include "io/marshalls.h"
@@ -38,24 +39,23 @@
#include "os/keyboard.h"
#include "os/os.h"
#include "variant_parser.h"
-
#include <zlib.h>
#define FORMAT_VERSION 3
-GlobalConfig *GlobalConfig::singleton = NULL;
+ProjectSettings *ProjectSettings::singleton = NULL;
-GlobalConfig *GlobalConfig::get_singleton() {
+ProjectSettings *ProjectSettings::get_singleton() {
return singleton;
}
-String GlobalConfig::get_resource_path() const {
+String ProjectSettings::get_resource_path() const {
return resource_path;
};
-String GlobalConfig::localize_path(const String &p_path) const {
+String ProjectSettings::localize_path(const String &p_path) const {
if (resource_path == "")
return p_path; //not initialied yet
@@ -99,13 +99,13 @@ String GlobalConfig::localize_path(const String &p_path) const {
};
}
-void GlobalConfig::set_initial_value(const String &p_name, const Variant &p_value) {
+void ProjectSettings::set_initial_value(const String &p_name, const Variant &p_value) {
ERR_FAIL_COND(!props.has(p_name));
props[p_name].initial = p_value;
}
-String GlobalConfig::globalize_path(const String &p_path) const {
+String ProjectSettings::globalize_path(const String &p_path) const {
if (p_path.begins_with("res://")) {
@@ -119,58 +119,68 @@ String GlobalConfig::globalize_path(const String &p_path) const {
return p_path;
}
-bool GlobalConfig::_set(const StringName &p_name, const Variant &p_value) {
+bool ProjectSettings::_set(const StringName &p_name, const Variant &p_value) {
_THREAD_SAFE_METHOD_
if (p_value.get_type() == Variant::NIL)
props.erase(p_name);
else {
- if (props.has(p_name)) {
- if (!props[p_name].overrided)
- props[p_name].variant = p_value;
- if (props[p_name].order >= NO_ORDER_BASE && registering_order) {
- props[p_name].order = last_order++;
+ if (p_name == CoreStringNames::get_singleton()->_custom_features) {
+ Vector<String> custom_feature_array = p_value;
+ for (int i = 0; i < custom_feature_array.size(); i++) {
+
+ custom_features.insert(custom_feature_array[i]);
}
- } else {
- props[p_name] = VariantContainer(p_value, last_order++ + (registering_order ? 0 : NO_ORDER_BASE));
+ return true;
}
- }
-
- if (!disable_platform_override) {
- String s = String(p_name);
- int sl = s.find("/");
- int p = s.find(".");
- if (p != -1 && sl != -1 && p < sl) {
-
- Vector<String> ps = s.substr(0, sl).split(".");
- String prop = s.substr(sl, s.length() - sl);
- for (int i = 1; i < ps.size(); i++) {
-
- if (ps[i] == OS::get_singleton()->get_name()) {
+ if (!disable_feature_overrides) {
+ int dot = p_name.operator String().find(".");
+ if (dot != -1) {
+ Vector<String> s = p_name.operator String().split(".");
+
+ bool override_valid = false;
+ for (int i = 1; i < s.size(); i++) {
+ String feature = s[i].strip_edges();
+ if (OS::get_singleton()->check_feature_support(feature) || custom_features.has(feature)) {
+ override_valid = true;
+ break;
+ }
+ }
- String fullprop = ps[0] + prop;
+ if (override_valid) {
- set(fullprop, p_value);
- props[fullprop].overrided = true;
+ feature_overrides[s[0]] = p_name;
}
}
}
+
+ if (props.has(p_name)) {
+ if (!props[p_name].overrided)
+ props[p_name].variant = p_value;
+
+ } else {
+ props[p_name] = VariantContainer(p_value, last_order++);
+ }
}
return true;
}
-bool GlobalConfig::_get(const StringName &p_name, Variant &r_ret) const {
+bool ProjectSettings::_get(const StringName &p_name, Variant &r_ret) const {
_THREAD_SAFE_METHOD_
- if (!props.has(p_name)) {
- print_line("WARNING: not found: " + String(p_name));
+ StringName name = p_name;
+ if (!disable_feature_overrides && feature_overrides.has(name)) {
+ name = feature_overrides[name];
+ }
+ if (!props.has(name)) {
+ print_line("WARNING: not found: " + String(name));
return false;
}
- r_ret = props[p_name].variant;
+ r_ret = props[name].variant;
return true;
}
@@ -184,7 +194,7 @@ struct _VCSort {
bool operator<(const _VCSort &p_vcs) const { return order == p_vcs.order ? name < p_vcs.name : order < p_vcs.order; }
};
-void GlobalConfig::_get_property_list(List<PropertyInfo> *p_list) const {
+void ProjectSettings::_get_property_list(List<PropertyInfo> *p_list) const {
_THREAD_SAFE_METHOD_
@@ -211,8 +221,13 @@ void GlobalConfig::_get_property_list(List<PropertyInfo> *p_list) const {
for (Set<_VCSort>::Element *E = vclist.front(); E; E = E->next()) {
- if (custom_prop_info.has(E->get().name)) {
- PropertyInfo pi = custom_prop_info[E->get().name];
+ String prop_info_name = E->get().name;
+ int dot = prop_info_name.find(".");
+ if (dot != -1)
+ prop_info_name = prop_info_name.substr(0, dot);
+
+ if (custom_prop_info.has(prop_info_name)) {
+ PropertyInfo pi = custom_prop_info[prop_info_name];
pi.name = E->get().name;
pi.usage = E->get().flags;
p_list->push_back(pi);
@@ -221,7 +236,7 @@ void GlobalConfig::_get_property_list(List<PropertyInfo> *p_list) const {
}
}
-bool GlobalConfig::_load_resource_pack(const String &p_pack) {
+bool ProjectSettings::_load_resource_pack(const String &p_pack) {
if (PackedData::get_singleton()->is_disabled())
return false;
@@ -238,13 +253,13 @@ bool GlobalConfig::_load_resource_pack(const String &p_pack) {
return true;
}
-Error GlobalConfig::setup(const String &p_path, const String &p_main_pack) {
+Error ProjectSettings::setup(const String &p_path, const String &p_main_pack) {
//If looking for files in network, just use network!
if (FileAccessNetworkClient::get_singleton()) {
- if (_load_settings("res://project.godot") == OK || _load_settings_binary("res://godot.cfb") == OK) {
+ if (_load_settings("res://project.godot") == OK || _load_settings_binary("res://project.binary") == OK) {
_load_settings("res://override.cfg");
}
@@ -261,7 +276,7 @@ Error GlobalConfig::setup(const String &p_path, const String &p_main_pack) {
bool ok = _load_resource_pack(p_main_pack);
ERR_FAIL_COND_V(!ok, ERR_CANT_OPEN);
- if (_load_settings("res://project.godot") == OK || _load_settings_binary("res://godot.cfb") == OK) {
+ if (_load_settings("res://project.godot") == OK || _load_settings_binary("res://project.binary") == OK) {
//load override from location of the main pack
_load_settings(p_main_pack.get_base_dir().plus_file("override.cfg"));
}
@@ -274,7 +289,7 @@ Error GlobalConfig::setup(const String &p_path, const String &p_main_pack) {
if (_load_resource_pack(exec_path.get_basename() + ".pck")) {
- if (_load_settings("res://project.godot") == OK || _load_settings_binary("res://godot.cfb") == OK) {
+ if (_load_settings("res://project.godot") == OK || _load_settings_binary("res://project.binary") == OK) {
//load override from location of executable
_load_settings(exec_path.get_base_dir().plus_file("override.cfg"));
}
@@ -295,7 +310,7 @@ Error GlobalConfig::setup(const String &p_path, const String &p_main_pack) {
// data.pck and data.zip are deprecated and no longer supported, apologies.
// make sure this is loaded from the resource path
- if (_load_settings("res://project.godot") == OK || _load_settings_binary("res://godot.cfb") == OK) {
+ if (_load_settings("res://project.godot") == OK || _load_settings_binary("res://project.binary") == OK) {
_load_settings("res://override.cfg");
}
@@ -316,7 +331,7 @@ Error GlobalConfig::setup(const String &p_path, const String &p_main_pack) {
while (true) {
//try to load settings in ascending through dirs shape!
- if (_load_settings(current_dir + "/project.godot") == OK || _load_settings_binary(current_dir + "/godot.cfb") == OK) {
+ if (_load_settings(current_dir + "/project.godot") == OK || _load_settings_binary(current_dir + "/project.binary") == OK) {
_load_settings(current_dir + "/override.cfg");
candidate = current_dir;
@@ -343,19 +358,19 @@ Error GlobalConfig::setup(const String &p_path, const String &p_main_pack) {
return OK;
}
-bool GlobalConfig::has(String p_var) const {
+bool ProjectSettings::has(String p_var) const {
_THREAD_SAFE_METHOD_
return props.has(p_var);
}
-void GlobalConfig::set_registering_order(bool p_enable) {
+void ProjectSettings::set_registering_order(bool p_enable) {
registering_order = p_enable;
}
-Error GlobalConfig::_load_settings_binary(const String p_path) {
+Error ProjectSettings::_load_settings_binary(const String p_path) {
Error err;
FileAccess *f = FileAccess::open(p_path, FileAccess::READ, &err);
@@ -368,12 +383,10 @@ Error GlobalConfig::_load_settings_binary(const String p_path) {
if (hdr[0] != 'E' || hdr[1] != 'C' || hdr[2] != 'F' || hdr[3] != 'G') {
memdelete(f);
- ERR_EXPLAIN("Corrupted header in binary godot.cfb (not ECFG)");
+ ERR_EXPLAIN("Corrupted header in binary project.binary (not ECFG)");
ERR_FAIL_V(ERR_FILE_CORRUPT;)
}
- set_registering_order(false);
-
uint32_t count = f->get_32();
for (uint32_t i = 0; i < count; i++) {
@@ -397,11 +410,9 @@ Error GlobalConfig::_load_settings_binary(const String p_path) {
set(key, value);
}
- set_registering_order(true);
-
return OK;
}
-Error GlobalConfig::_load_settings(const String p_path) {
+Error ProjectSettings::_load_settings(const String p_path) {
Error err;
FileAccess *f = FileAccess::open(p_path, FileAccess::READ, &err);
@@ -432,7 +443,7 @@ Error GlobalConfig::_load_settings(const String p_path) {
memdelete(f);
return OK;
} else if (err != OK) {
- ERR_PRINTS("GlobalConfig::load - " + p_path + ":" + itos(lines) + " error: " + error_text);
+ ERR_PRINTS("ProjectSettings::load - " + p_path + ":" + itos(lines) + " error: " + error_text);
memdelete(f);
return err;
}
@@ -444,8 +455,10 @@ Error GlobalConfig::_load_settings(const String p_path) {
memdelete(f);
ERR_FAIL_COND_V(config_version > FORMAT_VERSION, ERR_FILE_CANT_OPEN);
}
+ } else {
+ // config_version is checked and dropped
+ set(section + "/" + assign, value);
}
- set(section + "/" + assign, value);
} else if (next_tag.name != String()) {
section = next_tag.name;
}
@@ -456,36 +469,44 @@ Error GlobalConfig::_load_settings(const String p_path) {
return OK;
}
-int GlobalConfig::get_order(const String &p_name) const {
+int ProjectSettings::get_order(const String &p_name) const {
ERR_FAIL_COND_V(!props.has(p_name), -1);
return props[p_name].order;
}
-void GlobalConfig::set_order(const String &p_name, int p_order) {
+void ProjectSettings::set_order(const String &p_name, int p_order) {
ERR_FAIL_COND(!props.has(p_name));
props[p_name].order = p_order;
}
-void GlobalConfig::clear(const String &p_name) {
+void ProjectSettings::set_builtin_order(const String &p_name) {
+
+ ERR_FAIL_COND(!props.has(p_name));
+ if (props[p_name].order >= NO_BUILTIN_ORDER_BASE) {
+ props[p_name].order = last_builtin_order++;
+ }
+}
+
+void ProjectSettings::clear(const String &p_name) {
ERR_FAIL_COND(!props.has(p_name));
props.erase(p_name);
}
-Error GlobalConfig::save() {
+Error ProjectSettings::save() {
return save_custom(get_resource_path() + "/project.godot");
}
-Error GlobalConfig::_save_settings_binary(const String &p_file, const Map<String, List<String> > &props, const CustomMap &p_custom) {
+Error ProjectSettings::_save_settings_binary(const String &p_file, const Map<String, List<String> > &props, const CustomMap &p_custom, const String &p_custom_features) {
Error err;
FileAccess *file = FileAccess::open(p_file, FileAccess::WRITE, &err);
if (err != OK) {
- ERR_EXPLAIN("Couldn't save godot.cfb at " + p_file);
+ ERR_EXPLAIN("Couldn't save project.binary at " + p_file);
ERR_FAIL_COND_V(err, err)
}
@@ -502,7 +523,34 @@ Error GlobalConfig::_save_settings_binary(const String &p_file, const Map<String
}
}
- file->store_32(count); //store how many properties are saved
+ if (p_custom_features != String()) {
+ file->store_32(count + 1);
+ //store how many properties are saved, add one for custom featuers, which must always go first
+ String key = CoreStringNames::get_singleton()->_custom_features;
+ file->store_32(key.length());
+ file->store_string(key);
+
+ int len;
+ Error err = encode_variant(p_custom_features, NULL, len);
+ if (err != OK) {
+ memdelete(file);
+ ERR_FAIL_V(err);
+ }
+
+ Vector<uint8_t> buff;
+ buff.resize(len);
+
+ err = encode_variant(p_custom_features, &buff[0], len);
+ if (err != OK) {
+ memdelete(file);
+ ERR_FAIL_V(err);
+ }
+ file->store_32(len);
+ file->store_buffer(buff.ptr(), buff.size());
+
+ } else {
+ file->store_32(count); //store how many properties are saved
+ }
for (Map<String, List<String> >::Element *E = props.front(); E; E = E->next()) {
@@ -544,7 +592,7 @@ Error GlobalConfig::_save_settings_binary(const String &p_file, const Map<String
return OK;
}
-Error GlobalConfig::_save_settings_text(const String &p_file, const Map<String, List<String> > &props, const CustomMap &p_custom) {
+Error ProjectSettings::_save_settings_text(const String &p_file, const Map<String, List<String> > &props, const CustomMap &p_custom, const String &p_custom_features) {
Error err;
FileAccess *file = FileAccess::open(p_file, FileAccess::WRITE, &err);
@@ -554,7 +602,19 @@ Error GlobalConfig::_save_settings_text(const String &p_file, const Map<String,
ERR_FAIL_COND_V(err, err)
}
+ file->store_line("; Engine configuration file.");
+ file->store_line("; It's best edited using the editor UI and not directly,");
+ file->store_line("; since the parameters that go here are not all obvious.");
+ file->store_line("; ");
+ file->store_line("; Format: ");
+ file->store_line("; [section] ; section goes between []");
+ file->store_line("; param=value ; assign values to parameters");
+ file->store_line("");
+
file->store_string("config_version=" + itos(FORMAT_VERSION) + "\n");
+ if (p_custom_features != String())
+ file->store_string("custom_features=\"" + p_custom_features + "\"\n");
+ file->store_string("\n");
for (Map<String, List<String> >::Element *E = props.front(); E; E = E->next()) {
@@ -586,56 +646,48 @@ Error GlobalConfig::_save_settings_text(const String &p_file, const Map<String,
return OK;
}
-Error GlobalConfig::_save_custom_bnd(const String &p_file) { // add other params as dictionary and array?
+Error ProjectSettings::_save_custom_bnd(const String &p_file) { // add other params as dictionary and array?
return save_custom(p_file);
};
-Error GlobalConfig::save_custom(const String &p_path, const CustomMap &p_custom, const Set<String> &p_ignore_masks) {
+Error ProjectSettings::save_custom(const String &p_path, const CustomMap &p_custom, const Vector<String> &p_custom_features, bool p_merge_with_current) {
ERR_FAIL_COND_V(p_path == "", ERR_INVALID_PARAMETER);
Set<_VCSort> vclist;
- for (Map<StringName, VariantContainer>::Element *G = props.front(); G; G = G->next()) {
+ if (p_merge_with_current) {
+ for (Map<StringName, VariantContainer>::Element *G = props.front(); G; G = G->next()) {
- const VariantContainer *v = &G->get();
+ const VariantContainer *v = &G->get();
- if (v->hide_from_editor)
- continue;
+ if (v->hide_from_editor)
+ continue;
- if (p_custom.has(G->key()))
- continue;
-
- bool discard = false;
+ if (p_custom.has(G->key()))
+ continue;
- for (const Set<String>::Element *E = p_ignore_masks.front(); E; E = E->next()) {
+ _VCSort vc;
+ vc.name = G->key(); //*k;
+ vc.order = v->order;
+ vc.type = v->variant.get_type();
+ vc.flags = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_STORAGE;
+ if (v->variant == v->initial)
+ continue;
- if (String(G->key()).match(E->get())) {
- discard = true;
- break;
- }
+ vclist.insert(vc);
}
-
- if (discard)
- continue;
-
- _VCSort vc;
- vc.name = G->key(); //*k;
- vc.order = v->order;
- vc.type = v->variant.get_type();
- vc.flags = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_STORAGE;
- if (v->variant == v->initial)
- continue;
-
- vclist.insert(vc);
}
for (const Map<String, Variant>::Element *E = p_custom.front(); E; E = E->next()) {
+ // Lookup global prop to store in the same order
+ Map<StringName, VariantContainer>::Element *global_prop = props.find(E->key());
+
_VCSort vc;
vc.name = E->key();
- vc.order = 0xFFFFFFF;
+ vc.order = global_prop ? global_prop->get().order : 0xFFFFFFF;
vc.type = E->get().get_type();
vc.flags = PROPERTY_USAGE_STORAGE;
vclist.insert(vc);
@@ -660,10 +712,20 @@ Error GlobalConfig::save_custom(const String &p_path, const CustomMap &p_custom,
props[category].push_back(name);
}
+ String custom_features;
+
+ for (int i = 0; i < p_custom_features.size(); i++) {
+ if (i > 0)
+ custom_features += ",";
+
+ String f = p_custom_features[i].strip_edges().replace("\"", "");
+ custom_features += f;
+ }
+
if (p_path.ends_with(".godot"))
- return _save_settings_text(p_path, props, p_custom);
- else if (p_path.ends_with(".cfb"))
- return _save_settings_binary(p_path, props, p_custom);
+ return _save_settings_text(p_path, props, p_custom, custom_features);
+ else if (p_path.ends_with(".binary"))
+ return _save_settings_binary(p_path, props, p_custom, custom_features);
else {
ERR_EXPLAIN("Unknown config file format: " + p_path);
@@ -715,22 +777,25 @@ Error GlobalConfig::save_custom(const String &p_path, const CustomMap &p_custom,
Variant _GLOBAL_DEF(const String &p_var, const Variant &p_default) {
- if (GlobalConfig::get_singleton()->has(p_var)) {
- GlobalConfig::get_singleton()->set_initial_value(p_var, p_default);
- return GlobalConfig::get_singleton()->get(p_var);
+ Variant ret;
+ if (ProjectSettings::get_singleton()->has(p_var)) {
+ ret = ProjectSettings::get_singleton()->get(p_var);
+ } else {
+ ProjectSettings::get_singleton()->set(p_var, p_default);
+ ret = p_default;
}
- GlobalConfig::get_singleton()->set(p_var, p_default);
- GlobalConfig::get_singleton()->set_initial_value(p_var, p_default);
- return p_default;
+ ProjectSettings::get_singleton()->set_initial_value(p_var, p_default);
+ ProjectSettings::get_singleton()->set_builtin_order(p_var);
+ return ret;
}
-void GlobalConfig::add_singleton(const Singleton &p_singleton) {
+void ProjectSettings::add_singleton(const Singleton &p_singleton) {
singletons.push_back(p_singleton);
singleton_ptrs[p_singleton.name] = p_singleton.ptr;
}
-Object *GlobalConfig::get_singleton_object(const String &p_name) const {
+Object *ProjectSettings::get_singleton_object(const String &p_name) const {
const Map<StringName, Object *>::Element *E = singleton_ptrs.find(p_name);
if (!E)
@@ -739,21 +804,21 @@ Object *GlobalConfig::get_singleton_object(const String &p_name) const {
return E->get();
};
-bool GlobalConfig::has_singleton(const String &p_name) const {
+bool ProjectSettings::has_singleton(const String &p_name) const {
return get_singleton_object(p_name) != NULL;
};
-void GlobalConfig::get_singletons(List<Singleton> *p_singletons) {
+void ProjectSettings::get_singletons(List<Singleton> *p_singletons) {
for (List<Singleton>::Element *E = singletons.front(); E; E = E->next())
p_singletons->push_back(E->get());
}
-Vector<String> GlobalConfig::get_optimizer_presets() const {
+Vector<String> ProjectSettings::get_optimizer_presets() const {
List<PropertyInfo> pi;
- GlobalConfig::get_singleton()->get_property_list(&pi);
+ ProjectSettings::get_singleton()->get_property_list(&pi);
Vector<String> names;
for (List<PropertyInfo>::Element *E = pi.front(); E; E = E->next()) {
@@ -768,7 +833,7 @@ Vector<String> GlobalConfig::get_optimizer_presets() const {
return names;
}
-void GlobalConfig::_add_property_info_bind(const Dictionary &p_info) {
+void ProjectSettings::_add_property_info_bind(const Dictionary &p_info) {
ERR_FAIL_COND(!p_info.has("name"));
ERR_FAIL_COND(!p_info.has("type"));
@@ -787,24 +852,24 @@ void GlobalConfig::_add_property_info_bind(const Dictionary &p_info) {
set_custom_property_info(pinfo.name, pinfo);
}
-void GlobalConfig::set_custom_property_info(const String &p_prop, const PropertyInfo &p_info) {
+void ProjectSettings::set_custom_property_info(const String &p_prop, const PropertyInfo &p_info) {
ERR_FAIL_COND(!props.has(p_prop));
custom_prop_info[p_prop] = p_info;
custom_prop_info[p_prop].name = p_prop;
}
-void GlobalConfig::set_disable_platform_override(bool p_disable) {
+void ProjectSettings::set_disable_feature_overrides(bool p_disable) {
- disable_platform_override = p_disable;
+ disable_feature_overrides = p_disable;
}
-bool GlobalConfig::is_using_datapack() const {
+bool ProjectSettings::is_using_datapack() const {
return using_datapack;
}
-bool GlobalConfig::property_can_revert(const String &p_name) {
+bool ProjectSettings::property_can_revert(const String &p_name) {
if (!props.has(p_name))
return false;
@@ -812,7 +877,7 @@ bool GlobalConfig::property_can_revert(const String &p_name) {
return props[p_name].initial != props[p_name].variant;
}
-Variant GlobalConfig::property_get_revert(const String &p_name) {
+Variant ProjectSettings::property_get_revert(const String &p_name) {
if (!props.has(p_name))
return Variant();
@@ -820,43 +885,44 @@ Variant GlobalConfig::property_get_revert(const String &p_name) {
return props[p_name].initial;
}
-void GlobalConfig::_bind_methods() {
-
- ClassDB::bind_method(D_METHOD("has", "name"), &GlobalConfig::has);
- ClassDB::bind_method(D_METHOD("set_order", "name", "pos"), &GlobalConfig::set_order);
- ClassDB::bind_method(D_METHOD("get_order", "name"), &GlobalConfig::get_order);
- ClassDB::bind_method(D_METHOD("set_initial_value", "name", "value"), &GlobalConfig::set_initial_value);
- ClassDB::bind_method(D_METHOD("add_property_info", "hint"), &GlobalConfig::_add_property_info_bind);
- ClassDB::bind_method(D_METHOD("clear", "name"), &GlobalConfig::clear);
- ClassDB::bind_method(D_METHOD("localize_path", "path"), &GlobalConfig::localize_path);
- ClassDB::bind_method(D_METHOD("globalize_path", "path"), &GlobalConfig::globalize_path);
- ClassDB::bind_method(D_METHOD("save"), &GlobalConfig::save);
- ClassDB::bind_method(D_METHOD("has_singleton", "name"), &GlobalConfig::has_singleton);
- ClassDB::bind_method(D_METHOD("get_singleton", "name"), &GlobalConfig::get_singleton_object);
- ClassDB::bind_method(D_METHOD("load_resource_pack", "pack"), &GlobalConfig::_load_resource_pack);
- ClassDB::bind_method(D_METHOD("property_can_revert", "name"), &GlobalConfig::property_can_revert);
- ClassDB::bind_method(D_METHOD("property_get_revert", "name"), &GlobalConfig::property_get_revert);
-
- ClassDB::bind_method(D_METHOD("save_custom", "file"), &GlobalConfig::_save_custom_bnd);
+void ProjectSettings::_bind_methods() {
+
+ ClassDB::bind_method(D_METHOD("has", "name"), &ProjectSettings::has);
+ ClassDB::bind_method(D_METHOD("set_order", "name", "pos"), &ProjectSettings::set_order);
+ ClassDB::bind_method(D_METHOD("get_order", "name"), &ProjectSettings::get_order);
+ ClassDB::bind_method(D_METHOD("set_initial_value", "name", "value"), &ProjectSettings::set_initial_value);
+ ClassDB::bind_method(D_METHOD("add_property_info", "hint"), &ProjectSettings::_add_property_info_bind);
+ ClassDB::bind_method(D_METHOD("clear", "name"), &ProjectSettings::clear);
+ ClassDB::bind_method(D_METHOD("localize_path", "path"), &ProjectSettings::localize_path);
+ ClassDB::bind_method(D_METHOD("globalize_path", "path"), &ProjectSettings::globalize_path);
+ ClassDB::bind_method(D_METHOD("save"), &ProjectSettings::save);
+ ClassDB::bind_method(D_METHOD("has_singleton", "name"), &ProjectSettings::has_singleton);
+ ClassDB::bind_method(D_METHOD("get_singleton", "name"), &ProjectSettings::get_singleton_object);
+ ClassDB::bind_method(D_METHOD("load_resource_pack", "pack"), &ProjectSettings::_load_resource_pack);
+ ClassDB::bind_method(D_METHOD("property_can_revert", "name"), &ProjectSettings::property_can_revert);
+ ClassDB::bind_method(D_METHOD("property_get_revert:Variant", "name"), &ProjectSettings::property_get_revert);
+
+ ClassDB::bind_method(D_METHOD("save_custom", "file"), &ProjectSettings::_save_custom_bnd);
}
-GlobalConfig::GlobalConfig() {
+ProjectSettings::ProjectSettings() {
singleton = this;
- last_order = 0;
- disable_platform_override = false;
+ last_order = NO_BUILTIN_ORDER_BASE;
+ last_builtin_order = 0;
+ disable_feature_overrides = false;
registering_order = true;
Array va;
Ref<InputEventKey> key;
Ref<InputEventJoypadButton> joyb;
- GLOBAL_DEF("application/name", "");
- GLOBAL_DEF("application/main_scene", "");
- custom_prop_info["application/main_scene"] = PropertyInfo(Variant::STRING, "application/main_scene", PROPERTY_HINT_FILE, "tscn,scn,xscn,xml,res");
- GLOBAL_DEF("application/disable_stdout", false);
- GLOBAL_DEF("application/disable_stderr", false);
- GLOBAL_DEF("application/use_shared_user_dir", true);
+ GLOBAL_DEF("application/config/name", "");
+ GLOBAL_DEF("application/run/main_scene", "");
+ custom_prop_info["application/run/main_scene"] = PropertyInfo(Variant::STRING, "application/run/main_scene", PROPERTY_HINT_FILE, "tscn,scn,res");
+ GLOBAL_DEF("application/run/disable_stdout", false);
+ GLOBAL_DEF("application/run/disable_stderr", false);
+ GLOBAL_DEF("application/config/use_shared_user_dir", true);
key.instance();
key->set_scancode(KEY_RETURN);
@@ -962,23 +1028,28 @@ GlobalConfig::GlobalConfig() {
GLOBAL_DEF("input/ui_page_down", va);
input_presets.push_back("input/ui_page_down");
- //GLOBAL_DEF("display/handheld/orientation", "landscape");
+ //GLOBAL_DEF("display/window/handheld/orientation", "landscape");
- custom_prop_info["display/handheld/orientation"] = PropertyInfo(Variant::STRING, "display/handheld/orientation", PROPERTY_HINT_ENUM, "landscape,portrait,reverse_landscape,reverse_portrait,sensor_landscape,sensor_portrait,sensor");
+ custom_prop_info["display/window/handheld/orientation"] = PropertyInfo(Variant::STRING, "display/window/handheld/orientation", PROPERTY_HINT_ENUM, "landscape,portrait,reverse_landscape,reverse_portrait,sensor_landscape,sensor_portrait,sensor");
custom_prop_info["rendering/threads/thread_model"] = PropertyInfo(Variant::INT, "rendering/threads/thread_model", PROPERTY_HINT_ENUM, "Single-Unsafe,Single-Safe,Multi-Threaded");
custom_prop_info["physics/2d/thread_model"] = PropertyInfo(Variant::INT, "physics/2d/thread_model", PROPERTY_HINT_ENUM, "Single-Unsafe,Single-Safe,Multi-Threaded");
+ custom_prop_info["rendering/quality/intended_usage/framebuffer_allocation"] = PropertyInfo(Variant::INT, "rendering/quality/intended_usage/framebuffer_allocation", PROPERTY_HINT_ENUM, "2D,2D Without Sampling,3D,3D Without Effects");
+ GLOBAL_DEF("rendering/quality/intended_usage/framebuffer_mode", 2);
- GLOBAL_DEF("debug/profiler/max_functions", 16384);
+ GLOBAL_DEF("debug/settings/profiler/max_functions", 16384);
- GLOBAL_DEF("compression/zstd/compression_level", 3);
- custom_prop_info["compression/zstd/compression_level"] = PropertyInfo(Variant::INT, "compression/zstd/compression_level", PROPERTY_HINT_RANGE, "1,22,1");
- GLOBAL_DEF("compression/zlib/compression_level", Z_DEFAULT_COMPRESSION);
- custom_prop_info["compression/zlib/compression_level"] = PropertyInfo(Variant::INT, "compression/zlib/compression_level", PROPERTY_HINT_RANGE, "-1,9,1");
+ //assigning here, because using GLOBAL_GET on every block for compressing can be slow
+ Compression::zstd_level = GLOBAL_DEF("compression/formats/zstd/compression_level", 3);
+ custom_prop_info["compression/formats/zstd/compression_level"] = PropertyInfo(Variant::INT, "compression/formats/zstd/compression_level", PROPERTY_HINT_RANGE, "1,22,1");
+ Compression::zlib_level = GLOBAL_DEF("compression/formats/zlib/compression_level", Z_DEFAULT_COMPRESSION);
+ custom_prop_info["compression/formats/zlib/compression_level"] = PropertyInfo(Variant::INT, "compression/formats/zlib/compression_level", PROPERTY_HINT_RANGE, "-1,9,1");
+ Compression::gzip_level = GLOBAL_DEF("compression/formats/gzip/compression_level", Z_DEFAULT_COMPRESSION);
+ custom_prop_info["compression/formats/gzip/compression_level"] = PropertyInfo(Variant::INT, "compression/formats/gzip/compression_level", PROPERTY_HINT_RANGE, "-1,9,1");
using_datapack = false;
}
-GlobalConfig::~GlobalConfig() {
+ProjectSettings::~ProjectSettings() {
singleton = NULL;
}
diff --git a/core/global_config.h b/core/project_settings.h
index d0f64dc23c..c58ac3ca49 100644
--- a/core/global_config.h
+++ b/core/project_settings.h
@@ -37,9 +37,9 @@
@author Juan Linietsky <reduzio@gmail.com>
*/
-class GlobalConfig : public Object {
+class ProjectSettings : public Object {
- GDCLASS(GlobalConfig, Object);
+ GDCLASS(ProjectSettings, Object);
_THREAD_SAFE_CLASS_
public:
@@ -53,12 +53,12 @@ public:
ptr = p_ptr;
}
};
-
-protected:
enum {
- NO_ORDER_BASE = 1 << 18
+ //properties that are not for built in values begin from this value, so builtin ones are displayed first
+ NO_BUILTIN_ORDER_BASE = 1 << 16
};
+protected:
struct VariantContainer {
int order;
bool persist;
@@ -83,24 +83,28 @@ protected:
bool registering_order;
int last_order;
+ int last_builtin_order;
Map<StringName, VariantContainer> props;
String resource_path;
Map<StringName, PropertyInfo> custom_prop_info;
- bool disable_platform_override;
+ bool disable_feature_overrides;
bool using_datapack;
List<String> input_presets;
+ Set<String> custom_features;
+ Map<StringName, StringName> feature_overrides;
+
bool _set(const StringName &p_name, const Variant &p_value);
bool _get(const StringName &p_name, Variant &r_ret) const;
void _get_property_list(List<PropertyInfo> *p_list) const;
- static GlobalConfig *singleton;
+ static ProjectSettings *singleton;
Error _load_settings(const String p_path);
Error _load_settings_binary(const String p_path);
- Error _save_settings_text(const String &p_file, const Map<String, List<String> > &props, const CustomMap &p_custom = CustomMap());
- Error _save_settings_binary(const String &p_file, const Map<String, List<String> > &props, const CustomMap &p_custom = CustomMap());
+ Error _save_settings_text(const String &p_file, const Map<String, List<String> > &props, const CustomMap &p_custom = CustomMap(), const String &p_custom_features = String());
+ Error _save_settings_binary(const String &p_file, const Map<String, List<String> > &props, const CustomMap &p_custom = CustomMap(), const String &p_custom_features = String());
List<Singleton> singletons;
Map<StringName, Object *> singleton_ptrs;
@@ -125,15 +129,16 @@ public:
String get_resource_path() const;
- static GlobalConfig *get_singleton();
+ static ProjectSettings *get_singleton();
void clear(const String &p_name);
int get_order(const String &p_name) const;
void set_order(const String &p_name, int p_order);
+ void set_builtin_order(const String &p_name);
Error setup(const String &p_path, const String &p_main_pack);
- Error save_custom(const String &p_path = "", const CustomMap &p_custom = CustomMap(), const Set<String> &p_ignore_masks = Set<String>());
+ Error save_custom(const String &p_path = "", const CustomMap &p_custom = CustomMap(), const Vector<String> &p_custom_features = Vector<String>(), bool p_merge_with_current = true);
Error save();
void set_custom_property_info(const String &p_prop, const PropertyInfo &p_info);
@@ -146,7 +151,7 @@ public:
List<String> get_input_presets() const { return input_presets; }
- void set_disable_platform_override(bool p_disable);
+ void set_disable_feature_overrides(bool p_disable);
Object *get_singleton_object(const String &p_name) const;
void register_global_defaults();
@@ -155,13 +160,13 @@ public:
void set_registering_order(bool p_registering);
- GlobalConfig();
- ~GlobalConfig();
+ ProjectSettings();
+ ~ProjectSettings();
};
//not a macro any longer
Variant _GLOBAL_DEF(const String &p_var, const Variant &p_default);
#define GLOBAL_DEF(m_var, m_value) _GLOBAL_DEF(m_var, m_value)
-#define GLOBAL_GET(m_var) GlobalConfig::get_singleton()->get(m_var)
+#define GLOBAL_GET(m_var) ProjectSettings::get_singleton()->get(m_var)
#endif
diff --git a/core/reference.cpp b/core/reference.cpp
index c55f8a7fe3..060608eacb 100644
--- a/core/reference.cpp
+++ b/core/reference.cpp
@@ -74,7 +74,8 @@ bool Reference::unreference() {
bool die = refcount.unref();
if (get_script_instance()) {
- die = die && get_script_instance()->refcount_decremented();
+ bool script_ret = get_script_instance()->refcount_decremented();
+ die = die && script_ret;
}
return die;
diff --git a/core/reference.h b/core/reference.h
index 4e2d6c36c0..90f2791f4b 100644
--- a/core/reference.h
+++ b/core/reference.h
@@ -330,7 +330,7 @@ struct PtrToArg<Ref<T> > {
_FORCE_INLINE_ static Ref<T> convert(const void *p_ptr) {
- return Ref<T>(reinterpret_cast<const T *>(p_ptr));
+ return Ref<T>(const_cast<T *>(reinterpret_cast<const T *>(p_ptr)));
}
_FORCE_INLINE_ static void encode(Ref<T> p_val, const void *p_ptr) {
@@ -355,7 +355,7 @@ struct PtrToArg<RefPtr> {
_FORCE_INLINE_ static RefPtr convert(const void *p_ptr) {
- return Ref<Reference>(reinterpret_cast<const Reference *>(p_ptr)).get_ref_ptr();
+ return Ref<Reference>(const_cast<Reference *>(reinterpret_cast<const Reference *>(p_ptr))).get_ref_ptr();
}
_FORCE_INLINE_ static void encode(RefPtr p_val, const void *p_ptr) {
@@ -370,7 +370,7 @@ struct PtrToArg<const RefPtr &> {
_FORCE_INLINE_ static RefPtr convert(const void *p_ptr) {
- return Ref<Reference>(reinterpret_cast<const Reference *>(p_ptr)).get_ref_ptr();
+ return Ref<Reference>(const_cast<Reference *>(reinterpret_cast<const Reference *>(p_ptr))).get_ref_ptr();
}
};
diff --git a/core/register_core_types.cpp b/core/register_core_types.cpp
index b089ba9129..43f781af55 100644
--- a/core/register_core_types.cpp
+++ b/core/register_core_types.cpp
@@ -36,7 +36,6 @@
#include "core_string_names.h"
#include "func_ref.h"
#include "geometry.h"
-#include "global_config.h"
#include "input_map.h"
#include "io/config_file.h"
#include "io/http_client.h"
@@ -54,6 +53,7 @@
#include "os/main_loop.h"
#include "packed_data_container.h"
#include "path_remap.h"
+#include "project_settings.h"
#include "translation.h"
#include "undo_redo.h"
@@ -172,23 +172,23 @@ void register_core_types() {
void register_core_settings() {
//since in register core types, globals may not e present
- GLOBAL_DEF("network/packets/packet_stream_peer_max_buffer_po2", (16));
+ GLOBAL_DEF("network/limits/packet_peer_stream/max_buffer_po2", (16));
}
void register_core_singletons() {
- GlobalConfig::get_singleton()->add_singleton(GlobalConfig::Singleton("GlobalConfig", GlobalConfig::get_singleton()));
- GlobalConfig::get_singleton()->add_singleton(GlobalConfig::Singleton("IP", IP::get_singleton()));
- GlobalConfig::get_singleton()->add_singleton(GlobalConfig::Singleton("Geometry", _Geometry::get_singleton()));
- GlobalConfig::get_singleton()->add_singleton(GlobalConfig::Singleton("ResourceLoader", _ResourceLoader::get_singleton()));
- GlobalConfig::get_singleton()->add_singleton(GlobalConfig::Singleton("ResourceSaver", _ResourceSaver::get_singleton()));
- GlobalConfig::get_singleton()->add_singleton(GlobalConfig::Singleton("OS", _OS::get_singleton()));
- GlobalConfig::get_singleton()->add_singleton(GlobalConfig::Singleton("Engine", _Engine::get_singleton()));
- GlobalConfig::get_singleton()->add_singleton(GlobalConfig::Singleton("ClassDB", _classdb));
- GlobalConfig::get_singleton()->add_singleton(GlobalConfig::Singleton("Marshalls", _Marshalls::get_singleton()));
- GlobalConfig::get_singleton()->add_singleton(GlobalConfig::Singleton("TranslationServer", TranslationServer::get_singleton()));
- GlobalConfig::get_singleton()->add_singleton(GlobalConfig::Singleton("Input", Input::get_singleton()));
- GlobalConfig::get_singleton()->add_singleton(GlobalConfig::Singleton("InputMap", InputMap::get_singleton()));
+ ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("ProjectSettings", ProjectSettings::get_singleton()));
+ ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("IP", IP::get_singleton()));
+ ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("Geometry", _Geometry::get_singleton()));
+ ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("ResourceLoader", _ResourceLoader::get_singleton()));
+ ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("ResourceSaver", _ResourceSaver::get_singleton()));
+ ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("OS", _OS::get_singleton()));
+ ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("Engine", _Engine::get_singleton()));
+ ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("ClassDB", _classdb));
+ ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("Marshalls", _Marshalls::get_singleton()));
+ ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("TranslationServer", TranslationServer::get_singleton()));
+ ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("Input", Input::get_singleton()));
+ ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("InputMap", InputMap::get_singleton()));
}
void unregister_core_types() {
diff --git a/core/resource.cpp b/core/resource.cpp
index a7a5498ef6..5625784396 100644
--- a/core/resource.cpp
+++ b/core/resource.cpp
@@ -31,7 +31,6 @@
#include "core_string_names.h"
#include "io/resource_loader.h"
-#include "io/resource_loader.h"
#include "os/file_access.h"
#include "script_language.h"
#include <stdio.h>
@@ -340,7 +339,7 @@ void Resource::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_local_scene:Node"), &Resource::get_local_scene);
ClassDB::bind_method(D_METHOD("setup_local_to_scene"), &Resource::setup_local_to_scene);
- ClassDB::bind_method(D_METHOD("duplicate", "subresources"), &Resource::duplicate, DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("duplicate:Resource", "subresources"), &Resource::duplicate, DEFVAL(false));
ADD_SIGNAL(MethodInfo("changed"));
ADD_GROUP("Resource", "resource_");
ADD_PROPERTYNZ(PropertyInfo(Variant::BOOL, "resource_local_to_scene"), "set_local_to_scene", "is_local_to_scene");
diff --git a/core/safe_refcount.cpp b/core/safe_refcount.cpp
index e4a5a994e6..971e9ad1d5 100644
--- a/core/safe_refcount.cpp
+++ b/core/safe_refcount.cpp
@@ -33,7 +33,10 @@
#ifdef NO_THREADS
-uint32_t atomic_conditional_increment(register uint32_t *pw) {
+/* Bogus implementation unaware of multiprocessing */
+
+template <class T>
+static _ALWAYS_INLINE_ T _atomic_conditional_increment_impl(register T *pw) {
if (*pw == 0)
return 0;
@@ -43,53 +46,59 @@ uint32_t atomic_conditional_increment(register uint32_t *pw) {
return *pw;
}
-uint32_t atomic_increment(register uint32_t *pw) {
+template <class T>
+static _ALWAYS_INLINE_ T _atomic_decrement_impl(register T *pw) {
- (*pw)++;
+ (*pw)--;
return *pw;
}
-uint32_t atomic_decrement(register uint32_t *pw) {
+template <class T>
+static _ALWAYS_INLINE_ T _atomic_increment_impl(register T *pw) {
- (*pw)--;
+ (*pw)++;
return *pw;
}
-#else
+template <class T>
+static _ALWAYS_INLINE_ T _atomic_sub_impl(register T *pw, register T val) {
-#ifdef _MSC_VER
+ (*pw) -= val;
-// don't pollute my namespace!
-#include <windows.h>
-uint32_t atomic_conditional_increment(register uint32_t *pw) {
+ return *pw;
+}
- /* try to increment until it actually works */
- // taken from boost
+template <class T>
+static _ALWAYS_INLINE_ T _atomic_add_impl(register T *pw, register T val) {
- while (true) {
- uint32_t tmp = static_cast<uint32_t const volatile &>(*pw);
- if (tmp == 0)
- return 0; // if zero, can't add to it anymore
- if (InterlockedCompareExchange((LONG volatile *)pw, tmp + 1, tmp) == tmp)
- return tmp + 1;
- }
-}
+ (*pw) += val;
-uint32_t atomic_decrement(register uint32_t *pw) {
- return InterlockedDecrement((LONG volatile *)pw);
+ return *pw;
}
-uint32_t atomic_increment(register uint32_t *pw) {
- return InterlockedIncrement((LONG volatile *)pw);
+template <class T>
+static _ALWAYS_INLINE_ T _atomic_exchange_if_greater_impl(register T *pw, register T val) {
+
+ if (val > *pw)
+ *pw = val;
+
+ return *pw;
}
+
#elif defined(__GNUC__)
-uint32_t atomic_conditional_increment(register uint32_t *pw) {
+/* Implementation for GCC & Clang */
+
+// GCC guarantees atomic intrinsics for sizes of 1, 2, 4 and 8 bytes.
+// Clang states it supports GCC atomic builtins.
+
+template <class T>
+static _ALWAYS_INLINE_ T _atomic_conditional_increment_impl(register T *pw) {
while (true) {
- uint32_t tmp = static_cast<uint32_t const volatile &>(*pw);
+ T tmp = static_cast<T const volatile &>(*pw);
if (tmp == 0)
return 0; // if zero, can't add to it anymore
if (__sync_val_compare_and_swap(pw, tmp, tmp + 1) == tmp)
@@ -97,20 +106,182 @@ uint32_t atomic_conditional_increment(register uint32_t *pw) {
}
}
-uint32_t atomic_decrement(register uint32_t *pw) {
+template <class T>
+static _ALWAYS_INLINE_ T _atomic_decrement_impl(register T *pw) {
return __sync_sub_and_fetch(pw, 1);
}
-uint32_t atomic_increment(register uint32_t *pw) {
+template <class T>
+static _ALWAYS_INLINE_ T _atomic_increment_impl(register T *pw) {
return __sync_add_and_fetch(pw, 1);
}
+template <class T>
+static _ALWAYS_INLINE_ T _atomic_sub_impl(register T *pw, register T val) {
+
+ return __sync_sub_and_fetch(pw, val);
+}
+
+template <class T>
+static _ALWAYS_INLINE_ T _atomic_add_impl(register T *pw, register T val) {
+
+ return __sync_add_and_fetch(pw, val);
+}
+
+template <class T>
+static _ALWAYS_INLINE_ T _atomic_exchange_if_greater_impl(register T *pw, register T val) {
+
+ while (true) {
+ T tmp = static_cast<T const volatile &>(*pw);
+ if (tmp >= val)
+ return tmp; // already greater, or equal
+ if (__sync_val_compare_and_swap(pw, tmp, val) == tmp)
+ return val;
+ }
+}
+
+#elif defined(_MSC_VER)
+
+/* Implementation for MSVC-Windows */
+
+// don't pollute my namespace!
+#include <windows.h>
+
+#define ATOMIC_CONDITIONAL_INCREMENT_BODY(m_pw, m_win_type, m_win_cmpxchg, m_cpp_type) \
+ /* try to increment until it actually works */ \
+ /* taken from boost */ \
+ while (true) { \
+ m_cpp_type tmp = static_cast<m_cpp_type const volatile &>(*(m_pw)); \
+ if (tmp == 0) \
+ return 0; /* if zero, can't add to it anymore */ \
+ if (m_win_cmpxchg((m_win_type volatile *)(m_pw), tmp + 1, tmp) == tmp) \
+ return tmp + 1; \
+ }
+
+#define ATOMIC_EXCHANGE_IF_GREATER_BODY(m_pw, m_val, m_win_type, m_win_cmpxchg, m_cpp_type) \
+ while (true) { \
+ m_cpp_type tmp = static_cast<m_cpp_type const volatile &>(*(m_pw)); \
+ if (tmp >= m_val) \
+ return tmp; /* already greater, or equal */ \
+ if (m_win_cmpxchg((m_win_type volatile *)(m_pw), m_val, tmp) == tmp) \
+ return m_val; \
+ }
+
+static _ALWAYS_INLINE_ uint32_t _atomic_conditional_increment_impl(register uint32_t *pw) {
+
+ ATOMIC_CONDITIONAL_INCREMENT_BODY(pw, LONG, InterlockedCompareExchange, uint32_t)
+}
+
+static _ALWAYS_INLINE_ uint32_t _atomic_decrement_impl(register uint32_t *pw) {
+
+ return InterlockedDecrement((LONG volatile *)pw);
+}
+
+static _ALWAYS_INLINE_ uint32_t _atomic_increment_impl(register uint32_t *pw) {
+
+ return InterlockedIncrement((LONG volatile *)pw);
+}
+
+static _ALWAYS_INLINE_ uint32_t _atomic_sub_impl(register uint32_t *pw, register uint32_t val) {
+
+ return InterlockedExchangeAdd((LONG volatile *)pw, -(int32_t)val) - val;
+}
+
+static _ALWAYS_INLINE_ uint32_t _atomic_add_impl(register uint32_t *pw, register uint32_t val) {
+
+ return InterlockedAdd((LONG volatile *)pw, val);
+}
+
+static _ALWAYS_INLINE_ uint32_t _atomic_exchange_if_greater_impl(register uint32_t *pw, register uint32_t val) {
+
+ ATOMIC_EXCHANGE_IF_GREATER_BODY(pw, val, LONG, InterlockedCompareExchange, uint32_t)
+}
+
+static _ALWAYS_INLINE_ uint64_t _atomic_conditional_increment_impl(register uint64_t *pw) {
+
+ ATOMIC_CONDITIONAL_INCREMENT_BODY(pw, LONGLONG, InterlockedCompareExchange64, uint64_t)
+}
+
+static _ALWAYS_INLINE_ uint64_t _atomic_decrement_impl(register uint64_t *pw) {
+
+ return InterlockedDecrement64((LONGLONG volatile *)pw);
+}
+
+static _ALWAYS_INLINE_ uint64_t _atomic_increment_impl(register uint64_t *pw) {
+
+ return InterlockedIncrement64((LONGLONG volatile *)pw);
+}
+
+static _ALWAYS_INLINE_ uint64_t _atomic_sub_impl(register uint64_t *pw, register uint64_t val) {
+
+ return InterlockedExchangeAdd64((LONGLONG volatile *)pw, -(int64_t)val) - val;
+}
+
+static _ALWAYS_INLINE_ uint64_t _atomic_add_impl(register uint64_t *pw, register uint64_t val) {
+
+ return InterlockedAdd64((LONGLONG volatile *)pw, val);
+}
+
+static _ALWAYS_INLINE_ uint64_t _atomic_exchange_if_greater_impl(register uint64_t *pw, register uint64_t val) {
+
+ ATOMIC_EXCHANGE_IF_GREATER_BODY(pw, val, LONGLONG, InterlockedCompareExchange64, uint64_t)
+}
+
#else
+
//no threads supported?
#error Must provide atomic functions for this platform or compiler!
#endif
-#endif
+// The actual advertised functions; they'll call the right implementation
+
+uint32_t atomic_conditional_increment(register uint32_t *counter) {
+ return _atomic_conditional_increment_impl(counter);
+}
+
+uint32_t atomic_decrement(register uint32_t *pw) {
+ return _atomic_decrement_impl(pw);
+}
+
+uint32_t atomic_increment(register uint32_t *pw) {
+ return _atomic_increment_impl(pw);
+}
+
+uint32_t atomic_sub(register uint32_t *pw, register uint32_t val) {
+ return _atomic_sub_impl(pw, val);
+}
+
+uint32_t atomic_add(register uint32_t *pw, register uint32_t val) {
+ return _atomic_add_impl(pw, val);
+}
+
+uint32_t atomic_exchange_if_greater(register uint32_t *pw, register uint32_t val) {
+ return _atomic_exchange_if_greater_impl(pw, val);
+}
+
+uint64_t atomic_conditional_increment(register uint64_t *counter) {
+ return _atomic_conditional_increment_impl(counter);
+}
+
+uint64_t atomic_decrement(register uint64_t *pw) {
+ return _atomic_decrement_impl(pw);
+}
+
+uint64_t atomic_increment(register uint64_t *pw) {
+ return _atomic_increment_impl(pw);
+}
+
+uint64_t atomic_sub(register uint64_t *pw, register uint64_t val) {
+ return _atomic_sub_impl(pw, val);
+}
+
+uint64_t atomic_add(register uint64_t *pw, register uint64_t val) {
+ return _atomic_add_impl(pw, val);
+}
+
+uint64_t atomic_exchange_if_greater(register uint64_t *pw, register uint64_t val) {
+ return _atomic_exchange_if_greater_impl(pw, val);
+}
diff --git a/core/safe_refcount.h b/core/safe_refcount.h
index d30f563b56..ed0620c777 100644
--- a/core/safe_refcount.h
+++ b/core/safe_refcount.h
@@ -39,6 +39,16 @@
uint32_t atomic_conditional_increment(register uint32_t *counter);
uint32_t atomic_decrement(register uint32_t *pw);
uint32_t atomic_increment(register uint32_t *pw);
+uint32_t atomic_sub(register uint32_t *pw, register uint32_t val);
+uint32_t atomic_add(register uint32_t *pw, register uint32_t val);
+uint32_t atomic_exchange_if_greater(register uint32_t *pw, register uint32_t val);
+
+uint64_t atomic_conditional_increment(register uint64_t *counter);
+uint64_t atomic_decrement(register uint64_t *pw);
+uint64_t atomic_increment(register uint64_t *pw);
+uint64_t atomic_sub(register uint64_t *pw, register uint64_t val);
+uint64_t atomic_add(register uint64_t *pw, register uint64_t val);
+uint64_t atomic_exchange_if_greater(register uint64_t *pw, register uint64_t val);
struct SafeRefCount {
diff --git a/core/script_debugger_remote.cpp b/core/script_debugger_remote.cpp
index f230a4bc95..d19fe213f6 100644
--- a/core/script_debugger_remote.cpp
+++ b/core/script_debugger_remote.cpp
@@ -29,10 +29,10 @@
/*************************************************************************/
#include "script_debugger_remote.h"
-#include "global_config.h"
#include "io/ip.h"
#include "os/input.h"
#include "os/os.h"
+#include "project_settings.h"
void ScriptDebuggerRemote::_send_video_memory() {
@@ -74,7 +74,7 @@ Error ScriptDebuggerRemote::connect_to_host(const String &p_host, uint16_t p_por
} else {
OS::get_singleton()->delay_usec(1000000);
- print_line("Remote Debugger: Connection failed with status: " + String::num(tcp_client->get_status()) + "'', retrying in 1 sec.");
+ print_line("Remote Debugger: Connection failed with status: '" + String::num(tcp_client->get_status()) + "', retrying in 1 sec.");
};
};
@@ -130,7 +130,7 @@ void ScriptDebuggerRemote::debug(ScriptLanguage *p_script, bool p_can_continue)
ERR_FAIL();
}
- OS::get_singleton()->enable_for_stealing_focus(GlobalConfig::get_singleton()->get("editor_pid"));
+ OS::get_singleton()->enable_for_stealing_focus(ProjectSettings::get_singleton()->get("editor_pid"));
packet_peer_stream->put_var("debug_enter");
packet_peer_stream->put_var(2);
@@ -952,12 +952,12 @@ ScriptDebuggerRemote::ScriptDebuggerRemote() {
phl.userdata = this;
add_print_handler(&phl);
requested_quit = false;
- performance = GlobalConfig::get_singleton()->get_singleton_object("Performance");
+ performance = ProjectSettings::get_singleton()->get_singleton_object("Performance");
last_perf_time = 0;
poll_every = 0;
request_scene_tree = NULL;
live_edit_funcs = NULL;
- max_cps = GLOBAL_DEF("network/debug/max_remote_stdout_chars_per_second", 2048);
+ max_cps = GLOBAL_GET("network/limits/debugger_stdout/max_chars_per_second");
char_count = 0;
msec_count = 0;
last_msec = 0;
@@ -967,7 +967,7 @@ ScriptDebuggerRemote::ScriptDebuggerRemote() {
eh.userdata = this;
add_error_handler(&eh);
- profile_info.resize(CLAMP(int(GlobalConfig::get_singleton()->get("debug/profiler/max_functions")), 128, 65535));
+ profile_info.resize(CLAMP(int(ProjectSettings::get_singleton()->get("debug/settings/profiler/max_functions")), 128, 65535));
profile_info_ptrs.resize(profile_info.size());
profiling = false;
max_frame_functions = 16;
diff --git a/core/script_language.cpp b/core/script_language.cpp
index 72f0acec3b..aeb1573840 100644
--- a/core/script_language.cpp
+++ b/core/script_language.cpp
@@ -66,11 +66,6 @@ bool ScriptServer::is_scripting_enabled() {
return scripting_enabled;
}
-int ScriptServer::get_language_count() {
-
- return _language_count;
-}
-
ScriptLanguage *ScriptServer::get_language(int p_idx) {
ERR_FAIL_INDEX_V(p_idx, _language_count, NULL);
@@ -104,6 +99,13 @@ void ScriptServer::init_languages() {
}
}
+void ScriptServer::finish_languages() {
+
+ for (int i = 0; i < _language_count; i++) {
+ _languages[i]->finish();
+ }
+}
+
void ScriptServer::set_reload_scripts_on_save(bool p_enable) {
reload_scripts_on_save = p_enable;
diff --git a/core/script_language.h b/core/script_language.h
index 6e39593a89..7aba3ec0f1 100644
--- a/core/script_language.h
+++ b/core/script_language.h
@@ -57,7 +57,7 @@ public:
static void set_scripting_enabled(bool p_enabled);
static bool is_scripting_enabled();
- static int get_language_count();
+ _FORCE_INLINE_ static int get_language_count() { return _language_count; }
static ScriptLanguage *get_language(int p_idx);
static void register_language(ScriptLanguage *p_language);
static void unregister_language(ScriptLanguage *p_language);
@@ -69,6 +69,7 @@ public:
static void thread_exit();
static void init_languages();
+ static void finish_languages();
};
class ScriptInstance;
@@ -274,6 +275,9 @@ public:
virtual int profiling_get_accumulated_data(ProfilingInfo *p_info_arr, int p_info_max) = 0;
virtual int profiling_get_frame_data(ProfilingInfo *p_info_arr, int p_info_max) = 0;
+ virtual void *alloc_instance_binding_data(Object *p_object) { return NULL; } //optional, not used by all languages
+ virtual void free_instance_binding_data(void *p_data) {} //optional, not used by all languages
+
virtual void frame();
virtual ~ScriptLanguage(){};
diff --git a/core/self_list.h b/core/self_list.h
index 9edf735f7b..e229d5bf8e 100644
--- a/core/self_list.h
+++ b/core/self_list.h
@@ -51,6 +51,25 @@ public:
_first->_prev = p_elem;
_first = p_elem;
}
+ void add_last(SelfList<T> *p_elem) {
+
+ ERR_FAIL_COND(p_elem->_root);
+
+ if (!_first) {
+ add(p_elem);
+ return;
+ }
+
+ SelfList<T> *e = _first;
+
+ while (e->next()) {
+ e = e->next();
+ }
+
+ e->_next = p_elem;
+ p_elem->_prev = e->_next;
+ p_elem->_root = this;
+ }
void remove(SelfList<T> *p_elem) {
diff --git a/core/sort.h b/core/sort.h
index a45eb8865a..06c427f61e 100644
--- a/core/sort.h
+++ b/core/sort.h
@@ -46,7 +46,7 @@ class SortArray {
enum {
- INTROSORT_TRESHOLD = 16
+ INTROSORT_THRESHOLD = 16
};
public:
@@ -180,7 +180,7 @@ public:
inline void introsort(int p_first, int p_last, T *p_array, int p_max_depth) const {
- while (p_last - p_first > INTROSORT_TRESHOLD) {
+ while (p_last - p_first > INTROSORT_THRESHOLD) {
if (p_max_depth == 0) {
partial_sort(p_first, p_last, p_last, p_array);
@@ -273,9 +273,9 @@ public:
inline void final_insertion_sort(int p_first, int p_last, T *p_array) const {
- if (p_last - p_first > INTROSORT_TRESHOLD) {
- insertion_sort(p_first, p_first + INTROSORT_TRESHOLD, p_array);
- unguarded_insertion_sort(p_first + INTROSORT_TRESHOLD, p_last, p_array);
+ if (p_last - p_first > INTROSORT_THRESHOLD) {
+ insertion_sort(p_first, p_first + INTROSORT_THRESHOLD, p_array);
+ unguarded_insertion_sort(p_first + INTROSORT_THRESHOLD, p_last, p_array);
} else {
insertion_sort(p_first, p_last, p_array);
diff --git a/core/translation.cpp b/core/translation.cpp
index 72231ef295..50694e4a2d 100644
--- a/core/translation.cpp
+++ b/core/translation.cpp
@@ -29,9 +29,9 @@
/*************************************************************************/
#include "translation.h"
-#include "global_config.h"
#include "io/resource_loader.h"
#include "os/os.h"
+#include "project_settings.h"
static const char *locale_list[] = {
"aa", // Afar
@@ -1053,8 +1053,8 @@ TranslationServer *TranslationServer::singleton = NULL;
bool TranslationServer::_load_translations(const String &p_from) {
- if (GlobalConfig::get_singleton()->has(p_from)) {
- PoolVector<String> translations = GlobalConfig::get_singleton()->get(p_from);
+ if (ProjectSettings::get_singleton()->has(p_from)) {
+ PoolVector<String> translations = ProjectSettings::get_singleton()->get(p_from);
int tcount = translations.size();
@@ -1095,7 +1095,7 @@ void TranslationServer::setup() {
options += locale_list[idx];
idx++;
}
- GlobalConfig::get_singleton()->set_custom_property_info("locale/fallback", PropertyInfo(Variant::STRING, "locale/fallback", PROPERTY_HINT_ENUM, options));
+ ProjectSettings::get_singleton()->set_custom_property_info("locale/fallback", PropertyInfo(Variant::STRING, "locale/fallback", PROPERTY_HINT_ENUM, options));
}
#endif
//load translations
diff --git a/core/variant_call.cpp b/core/variant_call.cpp
index 6936a362e1..4a806aec6c 100644
--- a/core/variant_call.cpp
+++ b/core/variant_call.cpp
@@ -516,7 +516,7 @@ struct _VariantCall {
PoolByteArray compressed;
Compression::Mode mode = (Compression::Mode)(int)(*p_args[0]);
- compressed.resize(Compression::get_max_compressed_buffer_size(ba->size()));
+ compressed.resize(Compression::get_max_compressed_buffer_size(ba->size(), mode));
int result = Compression::compress(compressed.write().ptr(), ba->read().ptr(), ba->size(), mode);
result = result >= 0 ? result : 0;
diff --git a/core/variant_op.cpp b/core/variant_op.cpp
index c4dee5c8a4..5fda6b1473 100644
--- a/core/variant_op.cpp
+++ b/core/variant_op.cpp
@@ -1109,11 +1109,11 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid)
const String *str = reinterpret_cast<const String *>(p_index._data._mem);
Vector2 *v = reinterpret_cast<Vector2 *>(_data._mem);
- if (*str == "x" || *str == "width") {
+ if (*str == "x") {
valid = true;
v->x = p_value;
return;
- } else if (*str == "y" || *str == "height") {
+ } else if (*str == "y") {
valid = true;
v->y = p_value;
return;
@@ -1177,7 +1177,7 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid)
valid = true;
v->elements[1] = p_value;
return;
- } else if (*str == "o") {
+ } else if (*str == "origin") {
valid = true;
v->elements[2] = p_value;
return;
@@ -1572,10 +1572,10 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const {
const String *str = reinterpret_cast<const String *>(p_index._data._mem);
const Vector2 *v = reinterpret_cast<const Vector2 *>(_data._mem);
- if (*str == "x" || *str == "width") {
+ if (*str == "x") {
valid = true;
return v->x;
- } else if (*str == "y" || *str == "height") {
+ } else if (*str == "y") {
valid = true;
return v->y;
}
@@ -1657,7 +1657,7 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const {
} else if (*str == "y") {
valid = true;
return v->elements[1];
- } else if (*str == "o") {
+ } else if (*str == "origin") {
valid = true;
return v->elements[2];
}
@@ -2105,8 +2105,6 @@ void Variant::get_property_list(List<PropertyInfo> *p_list) const {
p_list->push_back(PropertyInfo(Variant::REAL, "x"));
p_list->push_back(PropertyInfo(Variant::REAL, "y"));
- p_list->push_back(PropertyInfo(Variant::REAL, "width"));
- p_list->push_back(PropertyInfo(Variant::REAL, "height"));
} break; // 5
case RECT2: {
@@ -2127,7 +2125,7 @@ void Variant::get_property_list(List<PropertyInfo> *p_list) const {
p_list->push_back(PropertyInfo(Variant::VECTOR2, "x"));
p_list->push_back(PropertyInfo(Variant::VECTOR2, "y"));
- p_list->push_back(PropertyInfo(Variant::VECTOR2, "o"));
+ p_list->push_back(PropertyInfo(Variant::VECTOR2, "origin"));
} break;
case PLANE: {
diff --git a/core/variant_parser.cpp b/core/variant_parser.cpp
index 26a6a05a30..398f20caf3 100644
--- a/core/variant_parser.cpp
+++ b/core/variant_parser.cpp
@@ -1099,7 +1099,7 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
return OK;
- } else if (id == "PoolFloatArray" || id == "FloatArray") {
+ } else if (id == "PoolRealArray" || id == "FloatArray") {
Vector<float> args;
Error err = _parse_construct<float>(p_stream, args, line, r_err_str);
@@ -1855,7 +1855,7 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
} break;
case Variant::POOL_REAL_ARRAY: {
- p_store_string_func(p_store_string_ud, "PoolFloatArray( ");
+ p_store_string_func(p_store_string_ud, "PoolRealArray( ");
PoolVector<real_t> data = p_variant;
int len = data.size();
PoolVector<real_t>::Read r = data.read();
diff --git a/core/vector.h b/core/vector.h
index fe1c1b05dd..5eed8dce96 100644
--- a/core/vector.h
+++ b/core/vector.h
@@ -134,10 +134,7 @@ public:
inline T &operator[](int p_index) {
- if (p_index < 0 || p_index >= size()) {
- T &aux = *((T *)0); //nullreturn
- ERR_FAIL_COND_V(p_index < 0 || p_index >= size(), aux);
- }
+ CRASH_BAD_INDEX(p_index, size());
_copy_on_write(); // wants to write, so copy on write.
@@ -146,10 +143,8 @@ public:
inline const T &operator[](int p_index) const {
- if (p_index < 0 || p_index >= size()) {
- const T &aux = *((T *)0); //nullreturn
- ERR_FAIL_COND_V(p_index < 0 || p_index >= size(), aux);
- }
+ CRASH_BAD_INDEX(p_index, size());
+
// no cow needed, since it's reading
return _get_data()[p_index];
}
diff --git a/core/vmap.h b/core/vmap.h
index ad07973308..66f935f58d 100644
--- a/core/vmap.h
+++ b/core/vmap.h
@@ -180,10 +180,8 @@ public:
inline const V &operator[](const T &p_key) const {
int pos = _find_exact(p_key);
- if (pos < 0) {
- const T &aux = *((T *)0); //nullreturn
- ERR_FAIL_COND_V(pos < 1, aux);
- }
+
+ CRASH_COND(pos < 0);
return _data[pos].value;
}
diff --git a/doc/base/classes.xml b/doc/base/classes.xml
index af90b5cde0..70a7dcb651 100644
--- a/doc/base/classes.xml
+++ b/doc/base/classes.xml
@@ -39,7 +39,7 @@
<argument index="0" name="s" type="float">
</argument>
<description>
- Remove sign (works for integer and float).
+ Returns the absolute value of parameter s (i.e. unsigned value, works for integer and float).
</description>
</method>
<method name="acos">
@@ -48,7 +48,7 @@
<argument index="0" name="s" type="float">
</argument>
<description>
- Arc-cosine.
+ Returns the principal value of the arc cosine of s, expressed in radians. In trigonometrics, arc cosine is the inverse operation of cosine.
</description>
</method>
<method name="asin">
@@ -57,7 +57,7 @@
<argument index="0" name="s" type="float">
</argument>
<description>
- Arc-sine.
+ Returns the principal value of the arc sine of s, expressed in radians. In trigonometrics, arc sine is the inverse operation of sine.
</description>
</method>
<method name="assert">
@@ -75,7 +75,7 @@
<argument index="0" name="s" type="float">
</argument>
<description>
- Arc-tangent.
+ Returns the principal value of the arc tangent of s, expressed in radians. In trigonometrics, arc tangent is the inverse operation of tangent. Notice that because of the sign ambiguity, the function cannot determine with certainty in which quadrant the angle falls only by its tangent value. See [method atan2] for an alternative that takes a fractional argument instead.
</description>
</method>
<method name="atan2">
@@ -86,7 +86,7 @@
<argument index="1" name="y" type="float">
</argument>
<description>
- Arc-tangent that takes a 2D vector as argument, returns the full -pi to +pi range.
+ Returns the principal value of the arc tangent of y/x, expressed in radians. To compute the value, the function takes into account the sign of both arguments in order to determine the quadrant.
</description>
</method>
<method name="bytes2var">
@@ -104,7 +104,7 @@
<argument index="0" name="s" type="float">
</argument>
<description>
- Ceiling (rounds up to nearest integer).
+ Rounds s upward, returning the smallest integral value that is not less than s.
</description>
</method>
<method name="char">
@@ -125,7 +125,7 @@
<argument index="2" name="max" type="float">
</argument>
<description>
- Clamp both values to a range.
+ Clamps a value between a minimum and maximum value.
</description>
</method>
<method name="convert">
@@ -145,7 +145,7 @@
<argument index="0" name="s" type="float">
</argument>
<description>
- Standard cosine function.
+ Returns the cosine of an angle of s radians.
</description>
</method>
<method name="cosh">
@@ -154,7 +154,7 @@
<argument index="0" name="s" type="float">
</argument>
<description>
- Hyperbolic cosine.
+ Returns the hyperbolic cosine of s.
</description>
</method>
<method name="db2linear">
@@ -223,7 +223,7 @@
<argument index="0" name="s" type="float">
</argument>
<description>
- Exponential logarithm.
+ Returns the base-e exponential function of s, which is e raised to the power s: e^s.
</description>
</method>
<method name="floor">
@@ -232,7 +232,7 @@
<argument index="0" name="s" type="float">
</argument>
<description>
- Floor (rounds down to nearest integer).
+ Rounds s downward, returning the largest integral value that is not greater than s.
</description>
</method>
<method name="fmod">
@@ -243,7 +243,11 @@
<argument index="1" name="y" type="float">
</argument>
<description>
- Module (remainder of x/y).
+ Returns the floating-point remainder of x/y (rounded towards zero):
+ [codeblock]
+ fmod = x - tquot * y
+ [/codeblock]
+ Where tquot is the truncated (i.e., rounded towards zero) result of: x/y.
</description>
</method>
<method name="fposmod">
@@ -301,6 +305,7 @@
<argument index="0" name="s" type="float">
</argument>
<description>
+ Returns whether s is an infinity value (either positive infinity or negative infinity).
</description>
</method>
<method name="is_nan">
@@ -309,6 +314,7 @@
<argument index="0" name="s" type="float">
</argument>
<description>
+ Returns whether s is a NaN (Not-A-Number) value.
</description>
</method>
<method name="lerp">
@@ -388,7 +394,8 @@
<argument index="0" name="json" type="String">
</argument>
<description>
- Parse json text to a Variant (use [method typeof] to check if it is what you expect).
+ Parse JSON text to a Variant (use [method typeof] to check if it is what you expect).
+ Be aware that the JSON specification does not define integer or float types, but only a number type. Therefore, parsing a JSON text will convert every numerical values to [float] types.
</description>
</method>
<method name="pow">
@@ -538,7 +545,7 @@
<argument index="0" name="s" type="float">
</argument>
<description>
- Round to nearest integer.
+ Returns the integral value that is nearest to s, with halfway cases rounded away from zero.
</description>
</method>
<method name="seed">
@@ -565,7 +572,7 @@
<argument index="0" name="s" type="float">
</argument>
<description>
- Standard sine function.
+ Returns the sine of an angle of s radians.
</description>
</method>
<method name="sinh">
@@ -574,7 +581,7 @@
<argument index="0" name="s" type="float">
</argument>
<description>
- Hyperbolic sine.
+ Returns the hyperbolic sine of s.
</description>
</method>
<method name="sqrt">
@@ -583,7 +590,7 @@
<argument index="0" name="s" type="float">
</argument>
<description>
- Square root.
+ Returns the square root of s.
</description>
</method>
<method name="stepify">
@@ -605,7 +612,7 @@
<argument index="1" name="..." type="Variant">
</argument>
<description>
- Convert one or more arguments to strings in the best way possible.
+ Convert one or more arguments to string in the best way possible.
</description>
</method>
<method name="str2var">
@@ -623,7 +630,7 @@
<argument index="0" name="s" type="float">
</argument>
<description>
- Standard tangent function.
+ Returns the tangent of an angle of s radians.
</description>
</method>
<method name="tanh">
@@ -632,7 +639,7 @@
<argument index="0" name="s" type="float">
</argument>
<description>
- Hyperbolic tangent.
+ Returns the hyperbolic tangent of s.
</description>
</method>
<method name="to_json">
@@ -667,6 +674,7 @@
<argument index="0" name="json" type="String">
</argument>
<description>
+ This method is used to validate the structure and data types of a piece of JSON, similar to XML Schema for XML.
</description>
</method>
<method name="var2bytes">
@@ -694,6 +702,7 @@
</argument>
<description>
Return a weak reference to an object.
+ A weak reference to an object is not enough to keep the object alive: when the only remaining references to a referent are weak references, garbage collection is free to destroy the referent and reuse its memory for something else. However, until the object is actually destroyed the weak reference may return the object even if there are no strong references to it.
</description>
</method>
<method name="yield">
@@ -714,8 +723,11 @@
Constant that represents how many times the diameter of a circumference fits around its perimeter.
</constant>
<constant name="INF" value="inf">
+ A positive infinity. (For negative infinity, use -INF).
</constant>
<constant name="NAN" value="nan">
+ Macro constant that expands to an expression of type float that represents a NaN.
+ The NaN values are used to identify undefined or non-representable values for floating-point elements, such as the square root of negative numbers or the result of 0/0.
</constant>
</constants>
</class>
@@ -740,7 +752,7 @@
<member name="Geometry" type="Geometry" setter="" getter="" brief="">
[Geometry] singleton
</member>
- <member name="GlobalConfig" type="GlobalConfig" setter="" getter="" brief="">
+ <member name="ProjectSettings" type="ProjectSettings" setter="" getter="" brief="">
</member>
<member name="IP" type="IP" setter="" getter="" brief="">
[IP] singleton
@@ -945,9 +957,6 @@
<constant name="KEY_F16" value="16777259">
F16 Key
</constant>
- <constant name="KEY_KP_ENTER" value="16777344">
- Enter Key on Numpad
- </constant>
<constant name="KEY_KP_MULTIPLY" value="16777345">
Multiply Key on Numpad
</constant>
@@ -1959,8 +1968,11 @@
</class>
<class name="AStar" inherits="Reference" category="Core">
<brief_description>
+ AStar class representation that uses vectors as edges.
</brief_description>
<description>
+ A* (A star) is a computer algorithm that is widely used in pathfinding and graph traversal, the process of plotting an efficiently directed path between multiple points. It enjoys widespread use due to its performance and accuracy. Godot's A* implementation make use of vectors as points.
+ You must add points manually with [method AStar.add_point] and create segments manually with [method AStar.connect_points]. So you can test if there is a path between two points with the [method AStar.are_points_connected] function, get the list of existing ids in the found path with [method AStar.get_id_path], or the points list with [method AStar.get_point_path].
</description>
<methods>
<method name="_compute_cost" qualifiers="virtual">
@@ -1987,7 +1999,7 @@
<argument index="2" name="weight_scale" type="float" default="1">
</argument>
<description>
- Add a new point at the given position. The [code]weight_scale[/code] has to be 1 or larger.
+ Add a new point at the given position [code]pos[/code] with the given identifier [code]id[/code]. The [code]weight_scale[/code] has to be 1 or larger.
</description>
</method>
<method name="are_points_connected" qualifiers="const">
@@ -1998,10 +2010,12 @@
<argument index="1" name="to_id" type="int">
</argument>
<description>
+ Returns if there is a connection/segment between points [code]id[/code] and [code]from_id[/code]
</description>
</method>
<method name="clear">
<description>
+ Clear all the points and segments from AStar instance.
</description>
</method>
<method name="connect_points">
@@ -2012,6 +2026,7 @@
<argument index="2" name="bidirectional" type="bool" default="true">
</argument>
<description>
+ Create a segment between points [code]id[/code] and [code]to_id[/code].
</description>
</method>
<method name="disconnect_points">
@@ -2020,6 +2035,7 @@
<argument index="1" name="to_id" type="int">
</argument>
<description>
+ Deletes a segment between points [code]id[/code] and [code]to_id[/code].
</description>
</method>
<method name="get_available_point_id" qualifiers="const">
@@ -2034,6 +2050,7 @@
<argument index="0" name="to_pos" type="Vector3">
</argument>
<description>
+ Returns the id of closest point of given point. -1 is returned if there are no points on AStar.
</description>
</method>
<method name="get_closest_pos_in_segment" qualifiers="const">
@@ -2042,6 +2059,7 @@
<argument index="0" name="to_pos" type="Vector3">
</argument>
<description>
+ Returns the position of closest point that has segments.
</description>
</method>
<method name="get_id_path">
@@ -2052,6 +2070,7 @@
<argument index="1" name="to_id" type="int">
</argument>
<description>
+ Returns an array with the point ids of path found by AStar between two given points.
</description>
</method>
<method name="get_point_path">
@@ -2062,6 +2081,7 @@
<argument index="1" name="to_id" type="int">
</argument>
<description>
+ Returns an array with the points of path found by AStar between two given points.
</description>
</method>
<method name="get_point_pos" qualifiers="const">
@@ -2070,6 +2090,7 @@
<argument index="0" name="id" type="int">
</argument>
<description>
+ Returns the position of point with given id.
</description>
</method>
<method name="get_point_weight_scale" qualifiers="const">
@@ -2078,12 +2099,23 @@
<argument index="0" name="id" type="int">
</argument>
<description>
+ Returns the weight scale of point with given id.
+ </description>
+ </method>
+ <method name="has_point" qualifiers="const">
+ <return type="bool">
+ </return>
+ <argument index="0" name="id" type="int">
+ </argument>
+ <description>
+ Returns if the point with given id exists on AStar;
</description>
</method>
<method name="remove_point">
<argument index="0" name="id" type="int">
</argument>
<description>
+ Removes the point with given id.
</description>
</method>
</methods>
@@ -3753,6 +3785,12 @@
Return the angular damp rate.
</description>
</method>
+ <method name="get_audio_bus" qualifiers="const">
+ <return type="String">
+ </return>
+ <description>
+ </description>
+ </method>
<method name="get_collision_layer" qualifiers="const">
<return type="int">
</return>
@@ -3834,6 +3872,24 @@
Return the processing order of this area.
</description>
</method>
+ <method name="get_reverb_amount" qualifiers="const">
+ <return type="float">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="get_reverb_bus" qualifiers="const">
+ <return type="String">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="get_reverb_uniformity" qualifiers="const">
+ <return type="float">
+ </return>
+ <description>
+ </description>
+ </method>
<method name="get_space_override_mode" qualifiers="const">
<return type="int">
</return>
@@ -3862,6 +3918,18 @@
Return whether this area detects bodies/areas entering/exiting it.
</description>
</method>
+ <method name="is_overriding_audio_bus" qualifiers="const">
+ <return type="bool">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="is_using_reverb_bus" qualifiers="const">
+ <return type="bool">
+ </return>
+ <description>
+ </description>
+ </method>
<method name="overlaps_area" qualifiers="const">
<return type="bool">
</return>
@@ -3888,6 +3956,18 @@
In practice, as the fraction of speed lost gets smaller with each frame, a value of 1.0 does not mean the object will stop in exactly one second. Only when the physics calculations are done at 1 frame per second, it does stop in a second.
</description>
</method>
+ <method name="set_audio_bus">
+ <argument index="0" name="name" type="String">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="set_audio_bus_override">
+ <argument index="0" name="enable" type="bool">
+ </argument>
+ <description>
+ </description>
+ </method>
<method name="set_collision_layer">
<argument index="0" name="collision_layer" type="int">
</argument>
@@ -3982,6 +4062,24 @@
Areas with the same priority value get evaluated in an unpredictable order, and should be differentiated if evaluation order is to be important.
</description>
</method>
+ <method name="set_reverb_amount">
+ <argument index="0" name="amount" type="float">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="set_reverb_bus">
+ <argument index="0" name="name" type="String">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="set_reverb_uniformity">
+ <argument index="0" name="amount" type="float">
+ </argument>
+ <description>
+ </description>
+ </method>
<method name="set_space_override_mode">
<argument index="0" name="enable" type="int">
</argument>
@@ -3994,10 +4092,20 @@
AREA_SPACE_OVERRIDE_REPLACE_COMBINE: This area replaces any gravity/damp calculated so far, but keeps calculating the rest of the areas, down to the default one.
</description>
</method>
+ <method name="set_use_reverb_bus">
+ <argument index="0" name="enable" type="bool">
+ </argument>
+ <description>
+ </description>
+ </method>
</methods>
<members>
<member name="angular_damp" type="float" setter="set_angular_damp" getter="get_angular_damp" brief="">
</member>
+ <member name="audio_bus_name" type="String" setter="set_audio_bus" getter="get_audio_bus" brief="">
+ </member>
+ <member name="audio_bus_override" type="bool" setter="set_audio_bus_override" getter="is_overriding_audio_bus" brief="">
+ </member>
<member name="collision_layer" type="int" setter="set_collision_layer" getter="get_collision_layer" brief="">
</member>
<member name="collision_mask" type="int" setter="set_collision_mask" getter="get_collision_mask" brief="">
@@ -4018,6 +4126,14 @@
</member>
<member name="priority" type="int" setter="set_priority" getter="get_priority" brief="">
</member>
+ <member name="reverb_bus_amount" type="float" setter="set_reverb_amount" getter="get_reverb_amount" brief="">
+ </member>
+ <member name="reverb_bus_enable" type="bool" setter="set_use_reverb_bus" getter="is_using_reverb_bus" brief="">
+ </member>
+ <member name="reverb_bus_name" type="String" setter="set_reverb_bus" getter="get_reverb_bus" brief="">
+ </member>
+ <member name="reverb_bus_uniformity" type="float" setter="set_reverb_uniformity" getter="get_reverb_uniformity" brief="">
+ </member>
<member name="space_override" type="int" setter="set_space_override_mode" getter="get_space_override_mode" brief="">
</member>
</members>
@@ -4121,6 +4237,12 @@
Return the angular damp rate.
</description>
</method>
+ <method name="get_audio_bus" qualifiers="const">
+ <return type="String">
+ </return>
+ <description>
+ </description>
+ </method>
<method name="get_collision_layer" qualifiers="const">
<return type="int">
</return>
@@ -4230,6 +4352,12 @@
Return whether this area detects bodies/areas entering/exiting it.
</description>
</method>
+ <method name="is_overriding_audio_bus" qualifiers="const">
+ <return type="bool">
+ </return>
+ <description>
+ </description>
+ </method>
<method name="overlaps_area" qualifiers="const">
<return type="bool">
</return>
@@ -4256,6 +4384,18 @@
In practice, as the fraction of speed lost gets smaller with each frame, a value of 1.0 does not mean the object will stop in exactly one second. Only when the physics calculations are done at 1 frame per second, it does stop in a second.
</description>
</method>
+ <method name="set_audio_bus">
+ <argument index="0" name="name" type="String">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="set_audio_bus_override">
+ <argument index="0" name="enable" type="bool">
+ </argument>
+ <description>
+ </description>
+ </method>
<method name="set_collision_layer">
<argument index="0" name="collision_layer" type="int">
</argument>
@@ -4366,6 +4506,10 @@
<members>
<member name="angular_damp" type="float" setter="set_angular_damp" getter="get_angular_damp" brief="">
</member>
+ <member name="audio_bus_name" type="String" setter="set_audio_bus" getter="get_audio_bus" brief="">
+ </member>
+ <member name="audio_bus_override" type="bool" setter="set_audio_bus_override" getter="is_overriding_audio_bus" brief="">
+ </member>
<member name="collision_layer" type="int" setter="set_collision_layer" getter="get_collision_layer" brief="">
</member>
<member name="collision_mask" type="int" setter="set_collision_mask" getter="get_collision_mask" brief="">
@@ -4616,7 +4760,13 @@
<argument index="0" name="value" type="var">
</argument>
<description>
- Return true if the array contains given value. [code][ "inside", 7 ].has("inside") == true, [ "inside", 7 ].has("outside") == false, [ "inside", 7 ].has(7) == true, [ "inside", 7 ].has("7") == false[/code]
+ Return true if the array contains given value.
+ [codeblock]
+ [ "inside", 7 ].has("inside") == true
+ [ "inside", 7 ].has("outside") == false
+ [ "inside", 7 ].has(7) == true
+ [ "inside", 7 ].has("7") == false
+ [/codeblock]
</description>
</method>
<method name="hash">
@@ -4936,27 +5086,6 @@
<constant name="ARRAY_FORMAT_INDEX" value="256">
Index array will be used.
</constant>
- <constant name="PRIMITIVE_POINTS" value="0">
- Render array as points (one vertex equals one point).
- </constant>
- <constant name="PRIMITIVE_LINES" value="1">
- Render array as lines (every two vertices a line is created).
- </constant>
- <constant name="PRIMITIVE_LINE_STRIP" value="2">
- Render array as line strip.
- </constant>
- <constant name="PRIMITIVE_LINE_LOOP" value="3">
- Render array as line loop (like line strip, but closed).
- </constant>
- <constant name="PRIMITIVE_TRIANGLES" value="4">
- Render array as triangles (every three vertices a triangle is created).
- </constant>
- <constant name="PRIMITIVE_TRIANGLE_STRIP" value="5">
- Render array as triangle strips.
- </constant>
- <constant name="PRIMITIVE_TRIANGLE_FAN" value="6">
- Render array as triangle fans.
- </constant>
</constants>
</class>
<class name="AtlasTexture" inherits="Texture" category="Core">
@@ -5325,7 +5454,7 @@
<description>
</description>
</method>
- <method name="get_treshold" qualifiers="const">
+ <method name="get_threshold" qualifiers="const">
<return type="float">
</return>
<description>
@@ -5367,8 +5496,8 @@
<description>
</description>
</method>
- <method name="set_treshold">
- <argument index="0" name="treshold" type="float">
+ <method name="set_threshold">
+ <argument index="0" name="threshold" type="float">
</argument>
<description>
</description>
@@ -5387,7 +5516,7 @@
</member>
<member name="sidechain" type="float" setter="set_sidechain" getter="get_sidechain" brief="">
</member>
- <member name="treshold" type="float" setter="set_treshold" getter="get_treshold" brief="">
+ <member name="threshold" type="float" setter="set_threshold" getter="get_threshold" brief="">
</member>
</members>
<constants>
@@ -5843,7 +5972,7 @@
<description>
</description>
</method>
- <method name="get_treshold_db" qualifiers="const">
+ <method name="get_threshold_db" qualifiers="const">
<return type="float">
</return>
<description>
@@ -5867,8 +5996,8 @@
<description>
</description>
</method>
- <method name="set_treshold_db">
- <argument index="0" name="treshold" type="float">
+ <method name="set_threshold_db">
+ <argument index="0" name="threshold" type="float">
</argument>
<description>
</description>
@@ -5881,7 +6010,7 @@
</member>
<member name="soft_clip_ratio" type="float" setter="set_soft_clip_ratio" getter="get_soft_clip_ratio" brief="">
</member>
- <member name="treshold_db" type="float" setter="set_treshold_db" getter="get_treshold_db" brief="">
+ <member name="threshold_db" type="float" setter="set_threshold_db" getter="get_threshold_db" brief="">
</member>
</members>
<constants>
@@ -6229,118 +6358,6 @@
<constants>
</constants>
</class>
-<class name="AudioPlayer" inherits="Node" category="Core">
- <brief_description>
- </brief_description>
- <description>
- </description>
- <methods>
- <method name="get_bus" qualifiers="const">
- <return type="String">
- </return>
- <description>
- </description>
- </method>
- <method name="get_mix_target" qualifiers="const">
- <return type="int">
- </return>
- <description>
- </description>
- </method>
- <method name="get_pos">
- <return type="float">
- </return>
- <description>
- </description>
- </method>
- <method name="get_stream" qualifiers="const">
- <return type="Object">
- </return>
- <description>
- </description>
- </method>
- <method name="get_volume_db" qualifiers="const">
- <return type="float">
- </return>
- <description>
- </description>
- </method>
- <method name="is_autoplay_enabled">
- <return type="bool">
- </return>
- <description>
- </description>
- </method>
- <method name="is_playing" qualifiers="const">
- <return type="bool">
- </return>
- <description>
- </description>
- </method>
- <method name="play">
- <argument index="0" name="from_pos" type="float" default="0">
- </argument>
- <description>
- </description>
- </method>
- <method name="seek">
- <argument index="0" name="to_pos" type="float">
- </argument>
- <description>
- </description>
- </method>
- <method name="set_autoplay">
- <argument index="0" name="enable" type="bool">
- </argument>
- <description>
- </description>
- </method>
- <method name="set_bus">
- <argument index="0" name="bus" type="String">
- </argument>
- <description>
- </description>
- </method>
- <method name="set_mix_target">
- <argument index="0" name="mix_target" type="int">
- </argument>
- <description>
- </description>
- </method>
- <method name="set_stream">
- <argument index="0" name="stream" type="AudioStream">
- </argument>
- <description>
- </description>
- </method>
- <method name="set_volume_db">
- <argument index="0" name="volume_db" type="float">
- </argument>
- <description>
- </description>
- </method>
- <method name="stop">
- <description>
- </description>
- </method>
- </methods>
- <members>
- <member name="autoplay" type="bool" setter="set_autoplay" getter="is_autoplay_enabled" brief="">
- </member>
- <member name="bus" type="String" setter="set_bus" getter="get_bus" brief="">
- </member>
- <member name="mix_target" type="int" setter="set_mix_target" getter="get_mix_target" brief="">
- </member>
- <member name="playing" type="bool" setter="_set_playing" getter="_is_active" brief="">
- </member>
- <member name="stream" type="AudioStream" setter="set_stream" getter="get_stream" brief="">
- </member>
- <member name="volume_db" type="float" setter="set_volume_db" getter="get_volume_db" brief="">
- </member>
- </members>
- <constants>
- </constants>
-</class>
<class name="AudioServer" inherits="Object" category="Core">
<brief_description>
Server interface for low level audio access.
@@ -6397,6 +6414,14 @@
<description>
</description>
</method>
+ <method name="get_bus_index" qualifiers="const">
+ <return type="int">
+ </return>
+ <argument index="0" name="bus_name" type="String">
+ </argument>
+ <description>
+ </description>
+ </method>
<method name="get_bus_name" qualifiers="const">
<return type="String">
</return>
@@ -6671,6 +6696,580 @@
<constants>
</constants>
</class>
+<class name="AudioStreamPlayer" inherits="Node" category="Core">
+ <brief_description>
+ </brief_description>
+ <description>
+ </description>
+ <methods>
+ <method name="get_bus" qualifiers="const">
+ <return type="String">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="get_mix_target" qualifiers="const">
+ <return type="int">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="get_pos">
+ <return type="float">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="get_stream" qualifiers="const">
+ <return type="Object">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="get_volume_db" qualifiers="const">
+ <return type="float">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="is_autoplay_enabled">
+ <return type="bool">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="is_playing" qualifiers="const">
+ <return type="bool">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="play">
+ <argument index="0" name="from_pos" type="float" default="0">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="seek">
+ <argument index="0" name="to_pos" type="float">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="set_autoplay">
+ <argument index="0" name="enable" type="bool">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="set_bus">
+ <argument index="0" name="bus" type="String">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="set_mix_target">
+ <argument index="0" name="mix_target" type="int">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="set_stream">
+ <argument index="0" name="stream" type="AudioStream">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="set_volume_db">
+ <argument index="0" name="volume_db" type="float">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="stop">
+ <description>
+ </description>
+ </method>
+ </methods>
+ <members>
+ <member name="autoplay" type="bool" setter="set_autoplay" getter="is_autoplay_enabled" brief="">
+ </member>
+ <member name="bus" type="String" setter="set_bus" getter="get_bus" brief="">
+ </member>
+ <member name="mix_target" type="int" setter="set_mix_target" getter="get_mix_target" brief="">
+ </member>
+ <member name="playing" type="bool" setter="_set_playing" getter="_is_active" brief="">
+ </member>
+ <member name="stream" type="AudioStream" setter="set_stream" getter="get_stream" brief="">
+ </member>
+ <member name="volume_db" type="float" setter="set_volume_db" getter="get_volume_db" brief="">
+ </member>
+ </members>
+ <constants>
+ </constants>
+</class>
+<class name="AudioStreamPlayer2D" inherits="Node2D" category="Core">
+ <brief_description>
+ </brief_description>
+ <description>
+ </description>
+ <methods>
+ <method name="get_area_mask" qualifiers="const">
+ <return type="int">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="get_attenuation" qualifiers="const">
+ <return type="float">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="get_bus" qualifiers="const">
+ <return type="String">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="get_max_distance" qualifiers="const">
+ <return type="float">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="get_pos">
+ <return type="float">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="get_stream" qualifiers="const">
+ <return type="Object">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="get_volume_db" qualifiers="const">
+ <return type="float">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="is_autoplay_enabled">
+ <return type="bool">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="is_playing" qualifiers="const">
+ <return type="bool">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="play">
+ <argument index="0" name="from_pos" type="float" default="0">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="seek">
+ <argument index="0" name="to_pos" type="float">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="set_area_mask">
+ <argument index="0" name="mask" type="int">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="set_attenuation">
+ <argument index="0" name="curve" type="float">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="set_autoplay">
+ <argument index="0" name="enable" type="bool">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="set_bus">
+ <argument index="0" name="bus" type="String">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="set_max_distance">
+ <argument index="0" name="pixels" type="float">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="set_stream">
+ <argument index="0" name="stream" type="AudioStream">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="set_volume_db">
+ <argument index="0" name="volume_db" type="float">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="stop">
+ <description>
+ </description>
+ </method>
+ </methods>
+ <members>
+ <member name="area_mask" type="int" setter="set_area_mask" getter="get_area_mask" brief="">
+ </member>
+ <member name="attenuation" type="float" setter="set_attenuation" getter="get_attenuation" brief="">
+ </member>
+ <member name="autoplay" type="bool" setter="set_autoplay" getter="is_autoplay_enabled" brief="">
+ </member>
+ <member name="bus" type="String" setter="set_bus" getter="get_bus" brief="">
+ </member>
+ <member name="max_distance" type="float" setter="set_max_distance" getter="get_max_distance" brief="">
+ </member>
+ <member name="playing" type="bool" setter="_set_playing" getter="_is_active" brief="">
+ </member>
+ <member name="stream" type="AudioStream" setter="set_stream" getter="get_stream" brief="">
+ </member>
+ <member name="volume_db" type="float" setter="set_volume_db" getter="get_volume_db" brief="">
+ </member>
+ </members>
+ <constants>
+ </constants>
+</class>
+<class name="AudioStreamPlayer3D" inherits="Spatial" category="Core">
+ <brief_description>
+ </brief_description>
+ <description>
+ </description>
+ <methods>
+ <method name="get_area_mask" qualifiers="const">
+ <return type="int">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="get_attenuation_filter_cutoff_hz" qualifiers="const">
+ <return type="float">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="get_attenuation_filter_db" qualifiers="const">
+ <return type="float">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="get_attenuation_model" qualifiers="const">
+ <return type="int">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="get_bus" qualifiers="const">
+ <return type="String">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="get_doppler_tracking" qualifiers="const">
+ <return type="int">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="get_emission_angle" qualifiers="const">
+ <return type="float">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="get_emission_angle_filter_attenuation_db" qualifiers="const">
+ <return type="float">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="get_max_db" qualifiers="const">
+ <return type="float">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="get_max_distance" qualifiers="const">
+ <return type="float">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="get_out_of_range_mode" qualifiers="const">
+ <return type="int">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="get_pos">
+ <return type="float">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="get_stream" qualifiers="const">
+ <return type="Object">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="get_unit_db" qualifiers="const">
+ <return type="float">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="get_unit_size" qualifiers="const">
+ <return type="float">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="is_autoplay_enabled">
+ <return type="bool">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="is_emission_angle_enabled" qualifiers="const">
+ <return type="bool">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="is_playing" qualifiers="const">
+ <return type="bool">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="play">
+ <argument index="0" name="from_pos" type="float" default="0">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="seek">
+ <argument index="0" name="to_pos" type="float">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="set_area_mask">
+ <argument index="0" name="mask" type="int">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="set_attenuation_filter_cutoff_hz">
+ <argument index="0" name="degrees" type="float">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="set_attenuation_filter_db">
+ <argument index="0" name="db" type="float">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="set_attenuation_model">
+ <argument index="0" name="model" type="int">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="set_autoplay">
+ <argument index="0" name="enable" type="bool">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="set_bus">
+ <argument index="0" name="bus" type="String">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="set_doppler_tracking">
+ <argument index="0" name="mode" type="int">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="set_emission_angle">
+ <argument index="0" name="degrees" type="float">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="set_emission_angle_enabled">
+ <argument index="0" name="enabled" type="bool">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="set_emission_angle_filter_attenuation_db">
+ <argument index="0" name="db" type="float">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="set_max_db">
+ <argument index="0" name="max_db" type="float">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="set_max_distance">
+ <argument index="0" name="metres" type="float">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="set_out_of_range_mode">
+ <argument index="0" name="mode" type="int">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="set_stream">
+ <argument index="0" name="stream" type="AudioStream">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="set_unit_db">
+ <argument index="0" name="unit_db" type="float">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="set_unit_size">
+ <argument index="0" name="unit_size" type="float">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="stop">
+ <description>
+ </description>
+ </method>
+ </methods>
+ <members>
+ <member name="area_mask" type="int" setter="set_area_mask" getter="get_area_mask" brief="">
+ </member>
+ <member name="attenuation_filter_cutoff_hz" type="float" setter="set_attenuation_filter_cutoff_hz" getter="get_attenuation_filter_cutoff_hz" brief="">
+ </member>
+ <member name="attenuation_filter_db" type="float" setter="set_attenuation_filter_db" getter="get_attenuation_filter_db" brief="">
+ </member>
+ <member name="attenuation_model" type="int" setter="set_attenuation_model" getter="get_attenuation_model" brief="">
+ </member>
+ <member name="autoplay" type="bool" setter="set_autoplay" getter="is_autoplay_enabled" brief="">
+ </member>
+ <member name="bus" type="String" setter="set_bus" getter="get_bus" brief="">
+ </member>
+ <member name="doppler_tracking" type="int" setter="set_doppler_tracking" getter="get_doppler_tracking" brief="">
+ </member>
+ <member name="emission_angle_degrees" type="float" setter="set_emission_angle" getter="get_emission_angle" brief="">
+ </member>
+ <member name="emission_angle_enabled" type="bool" setter="set_emission_angle_enabled" getter="is_emission_angle_enabled" brief="">
+ </member>
+ <member name="emission_angle_filter_attenuation_db" type="float" setter="set_emission_angle_filter_attenuation_db" getter="get_emission_angle_filter_attenuation_db" brief="">
+ </member>
+ <member name="max_db" type="float" setter="set_max_db" getter="get_max_db" brief="">
+ </member>
+ <member name="max_distance" type="float" setter="set_max_distance" getter="get_max_distance" brief="">
+ </member>
+ <member name="out_of_range_mode" type="int" setter="set_out_of_range_mode" getter="get_out_of_range_mode" brief="">
+ </member>
+ <member name="playing" type="bool" setter="_set_playing" getter="_is_active" brief="">
+ </member>
+ <member name="stream" type="AudioStream" setter="set_stream" getter="get_stream" brief="">
+ </member>
+ <member name="unit_db" type="float" setter="set_unit_db" getter="get_unit_db" brief="">
+ </member>
+ <member name="unit_size" type="float" setter="set_unit_size" getter="get_unit_size" brief="">
+ </member>
+ </members>
+ <constants>
+ <constant name="ATTENUATION_INVERSE_DISTANCE" value="0">
+ </constant>
+ <constant name="ATTENUATION_INVERSE_SQUARE_DISTANCE" value="1">
+ </constant>
+ <constant name="ATTENUATION_LOGARITHMIC" value="2">
+ </constant>
+ <constant name="OUT_OF_RANGE_MIX" value="0">
+ </constant>
+ <constant name="OUT_OF_RANGE_PAUSE" value="1">
+ </constant>
+ <constant name="DOPPLER_TRACKING_DISABLED" value="0">
+ </constant>
+ <constant name="DOPPLER_TRACKING_IDLE_STEP" value="1">
+ </constant>
+ <constant name="DOPPLER_TRACKING_FIXED_STEP" value="2">
+ </constant>
+ </constants>
+</class>
+<class name="AudioStreamRandomPitch" inherits="AudioStream" category="Core">
+ <brief_description>
+ </brief_description>
+ <description>
+ </description>
+ <methods>
+ <method name="get_audio_stream" qualifiers="const">
+ <return type="Object">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="get_random_pitch" qualifiers="const">
+ <return type="float">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="set_audio_stream">
+ <argument index="0" name="stream" type="Object">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="set_random_pitch">
+ <argument index="0" name="scale" type="float">
+ </argument>
+ <description>
+ </description>
+ </method>
+ </methods>
+ <members>
+ <member name="audio_stream" type="AudioStream" setter="set_audio_stream" getter="get_audio_stream" brief="">
+ </member>
+ <member name="random_pitch" type="float" setter="set_random_pitch" getter="get_random_pitch" brief="">
+ </member>
+ </members>
+ <constants>
+ </constants>
+</class>
<class name="AudioStreamSample" inherits="AudioStream" category="Core">
<brief_description>
</brief_description>
@@ -7704,6 +8303,12 @@
<description>
</description>
</method>
+ <method name="get_doppler_tracking" qualifiers="const">
+ <return type="int">
+ </return>
+ <description>
+ </description>
+ </method>
<method name="get_environment" qualifiers="const">
<return type="Environment">
</return>
@@ -7818,6 +8423,12 @@
<description>
</description>
</method>
+ <method name="set_doppler_tracking">
+ <argument index="0" name="mode" type="int">
+ </argument>
+ <description>
+ </description>
+ </method>
<method name="set_environment">
<argument index="0" name="env" type="Environment">
</argument>
@@ -7885,6 +8496,12 @@
</constant>
<constant name="KEEP_HEIGHT" value="1">
</constant>
+ <constant name="DOPPLER_TRACKING_DISABLED" value="0">
+ </constant>
+ <constant name="DOPPLER_TRACKING_IDLE_STEP" value="1">
+ </constant>
+ <constant name="DOPPLER_TRACKING_FIXED_STEP" value="2">
+ </constant>
</constants>
</class>
<class name="Camera2D" inherits="Node2D" category="Core">
@@ -8003,18 +8620,36 @@
<description>
</description>
</method>
+ <method name="is_limit_drawing_enabled" qualifiers="const">
+ <return type="bool">
+ </return>
+ <description>
+ </description>
+ </method>
<method name="is_limit_smoothing_enabled" qualifiers="const">
<return type="bool">
</return>
<description>
</description>
</method>
+ <method name="is_margin_drawing_enabled" qualifiers="const">
+ <return type="bool">
+ </return>
+ <description>
+ </description>
+ </method>
<method name="is_rotating" qualifiers="const">
<return type="bool">
</return>
<description>
</description>
</method>
+ <method name="is_screen_drawing_enabled" qualifiers="const">
+ <return type="bool">
+ </return>
+ <description>
+ </description>
+ </method>
<method name="is_v_drag_enabled" qualifiers="const">
<return type="bool">
</return>
@@ -8086,6 +8721,12 @@
Set the scrolling limit in pixels.
</description>
</method>
+ <method name="set_limit_drawing_enabled">
+ <argument index="0" name="limit_drawing_enabled" type="bool">
+ </argument>
+ <description>
+ </description>
+ </method>
<method name="set_limit_smoothing_enabled">
<argument index="0" name="limit_smoothing_enabled" type="bool">
</argument>
@@ -8094,6 +8735,12 @@
This requires camera smoothing being enabled to have a noticeable effect.
</description>
</method>
+ <method name="set_margin_drawing_enabled">
+ <argument index="0" name="margin_drawing_enabled" type="bool">
+ </argument>
+ <description>
+ </description>
+ </method>
<method name="set_offset">
<argument index="0" name="offset" type="Vector2">
</argument>
@@ -8107,6 +8754,12 @@
<description>
</description>
</method>
+ <method name="set_screen_drawing_enabled">
+ <argument index="0" name="screen_drawing_enabled" type="bool">
+ </argument>
+ <description>
+ </description>
+ </method>
<method name="set_v_drag_enabled">
<argument index="0" name="enabled" type="bool">
</argument>
@@ -8143,6 +8796,12 @@
</member>
<member name="drag_margin_v_enabled" type="bool" setter="set_v_drag_enabled" getter="is_v_drag_enabled" brief="">
</member>
+ <member name="editor_draw_drag_margin" type="bool" setter="set_margin_drawing_enabled" getter="is_margin_drawing_enabled" brief="">
+ </member>
+ <member name="editor_draw_limits" type="bool" setter="set_limit_drawing_enabled" getter="is_limit_drawing_enabled" brief="">
+ </member>
+ <member name="editor_draw_screen" type="bool" setter="set_screen_drawing_enabled" getter="is_screen_drawing_enabled" brief="">
+ </member>
<member name="limit_bottom" type="int" setter="set_limit" getter="get_limit" brief="">
</member>
<member name="limit_left" type="int" setter="set_limit" getter="get_limit" brief="">
@@ -8225,6 +8884,8 @@
</argument>
<argument index="3" name="texture" type="Texture" default="NULL">
</argument>
+ <argument index="4" name="normal_map" type="Texture" default="NULL">
+ </argument>
<description>
Draw a colored polygon of any amount of points, convex or concave.
</description>
@@ -8253,10 +8914,36 @@
</argument>
<argument index="3" name="texture" type="Texture" default="NULL">
</argument>
+ <argument index="4" name="normal_map" type="Texture" default="NULL">
+ </argument>
<description>
Draw a polygon of any amount of points, convex or concave.
</description>
</method>
+ <method name="draw_polyline">
+ <argument index="0" name="points" type="PoolVector2Array">
+ </argument>
+ <argument index="1" name="color" type="Color">
+ </argument>
+ <argument index="2" name="width" type="float" default="1">
+ </argument>
+ <argument index="3" name="antialiased" type="bool" default="false">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="draw_polyline_colors">
+ <argument index="0" name="points" type="PoolVector2Array">
+ </argument>
+ <argument index="1" name="colors" type="PoolColorArray">
+ </argument>
+ <argument index="2" name="width" type="float" default="1">
+ </argument>
+ <argument index="3" name="antialiased" type="bool" default="false">
+ </argument>
+ <description>
+ </description>
+ </method>
<method name="draw_primitive">
<argument index="0" name="points" type="PoolVector2Array">
</argument>
@@ -8268,6 +8955,8 @@
</argument>
<argument index="4" name="width" type="float" default="1">
</argument>
+ <argument index="5" name="normal_map" type="Texture" default="NULL">
+ </argument>
<description>
Draw a custom primitive, 1 point for a point, 2 points for a line, 3 points for a triangle and 4 points for a quad.
</description>
@@ -8277,6 +8966,8 @@
</argument>
<argument index="1" name="color" type="Color">
</argument>
+ <argument index="2" name="filled" type="bool" default="true">
+ </argument>
<description>
Draw a colored rectangle.
</description>
@@ -8329,6 +9020,8 @@
</argument>
<argument index="2" name="modulate" type="Color" default="Color(1,1,1,1)">
</argument>
+ <argument index="3" name="normal_map" type="Texture" default="NULL">
+ </argument>
<description>
Draw a texture at a given position.
</description>
@@ -8344,6 +9037,8 @@
</argument>
<argument index="4" name="transpose" type="bool" default="false">
</argument>
+ <argument index="5" name="normal_map" type="Texture" default="NULL">
+ </argument>
<description>
Draw a textured rectangle at a given position, optionally modulated by a color. Transpose swaps the x and y coordinates when reading the texture.
</description>
@@ -8359,6 +9054,10 @@
</argument>
<argument index="4" name="transpose" type="bool" default="false">
</argument>
+ <argument index="5" name="normal_map" type="Texture" default="NULL">
+ </argument>
+ <argument index="6" name="clip_uv" type="bool" default="true">
+ </argument>
<description>
Draw a textured rectangle region at a given position, optionally modulated by a color. Transpose swaps the x and y coordinates when reading the texture.
</description>
@@ -8461,7 +9160,7 @@
</description>
</method>
<method name="get_material" qualifiers="const">
- <return type="ShaderMaterial">
+ <return type="Material">
</return>
<description>
Get the material of this item.
@@ -8598,7 +9297,7 @@
</description>
</method>
<method name="set_material">
- <argument index="0" name="material" type="ShaderMaterial">
+ <argument index="0" name="material" type="Material">
</argument>
<description>
Set the material of this item.
@@ -8659,7 +9358,7 @@
<members>
<member name="light_mask" type="int" setter="set_light_mask" getter="get_light_mask" brief="">
</member>
- <member name="material" type="ShaderMaterial" setter="set_material" getter="get_material" brief="">
+ <member name="material" type="ShaderMaterial,CanvasItemMaterial" setter="set_material" getter="get_material" brief="">
</member>
<member name="modulate" type="Color" setter="set_modulate" getter="get_modulate" brief="">
</member>
@@ -8729,6 +9428,62 @@
</constant>
</constants>
</class>
+<class name="CanvasItemMaterial" inherits="Material" category="Core">
+ <brief_description>
+ </brief_description>
+ <description>
+ </description>
+ <methods>
+ <method name="get_blend_mode" qualifiers="const">
+ <return type="int">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="get_light_mode" qualifiers="const">
+ <return type="int">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="set_blend_mode">
+ <argument index="0" name="blend_mode" type="int">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="set_light_mode">
+ <argument index="0" name="light_mode" type="int">
+ </argument>
+ <description>
+ </description>
+ </method>
+ </methods>
+ <members>
+ <member name="blend_mode" type="int" setter="set_blend_mode" getter="get_blend_mode" brief="">
+ </member>
+ <member name="light_mode" type="int" setter="set_light_mode" getter="get_light_mode" brief="">
+ </member>
+ </members>
+ <constants>
+ <constant name="BLEND_MODE_MIX" value="0">
+ </constant>
+ <constant name="BLEND_MODE_ADD" value="1">
+ </constant>
+ <constant name="BLEND_MODE_SUB" value="2">
+ </constant>
+ <constant name="BLEND_MODE_MUL" value="3">
+ </constant>
+ <constant name="BLEND_MODE_PREMULT_ALPHA" value="4">
+ </constant>
+ <constant name="LIGHT_MODE_NORMAL" value="0">
+ </constant>
+ <constant name="LIGHT_MODE_UNSHADED" value="1">
+ </constant>
+ <constant name="LIGHT_MODE_LIGHT_ONLY" value="2">
+ </constant>
+ </constants>
+</class>
<class name="CanvasLayer" inherits="Node" category="Core">
<brief_description>
Canvas Item layer.
@@ -9408,104 +10163,93 @@
<description>
</description>
</method>
- <method name="add_shape">
- <argument index="0" name="shape" type="Shape">
- </argument>
- <argument index="1" name="transform" type="Transform" default="Transform()">
- </argument>
- <description>
- </description>
- </method>
- <method name="clear_shapes">
- <description>
- </description>
- </method>
<method name="get_capture_input_on_drag" qualifiers="const">
<return type="bool">
</return>
<description>
</description>
</method>
- <method name="get_rid" qualifiers="const">
- <return type="RID">
+ <method name="create_shape_owner">
+ <return type="int">
</return>
+ <argument index="0" name="owner" type="Object">
+ </argument>
<description>
+ Creates new holder for the shapes. Argument is a [CollisionShape] node. It will return owner_id which usually you will want to save for later use.
</description>
</method>
- <method name="get_shape" qualifiers="const">
- <return type="Shape">
+ <method name="get_rid" qualifiers="const">
+ <return type="RID">
</return>
- <argument index="0" name="shape_idx" type="int">
- </argument>
<description>
</description>
</method>
- <method name="get_shape_count" qualifiers="const">
- <return type="int">
+ <method name="get_shape_owners">
+ <return type="Array">
</return>
<description>
+ Shape owner is a node which is holding concrete shape resources. This method will return an array which is holding an integer numbers that are representing unique ID of each owner. You can use those ids when you are using others shape_owner methods.
</description>
</method>
- <method name="get_shape_transform" qualifiers="const">
- <return type="Transform">
- </return>
- <argument index="0" name="shape_idx" type="int">
+ <method name="shape_owner_clear_shapes">
+ <argument index="0" name="owner_id" type="int">
</argument>
<description>
+ Will remove all the shapes associated with given owner.
</description>
</method>
- <method name="is_ray_pickable" qualifiers="const">
- <return type="bool">
+ <method name="shape_owner_get_shape">
+ <return type="Shape">
</return>
+ <argument index="0" name="owner_id" type="int">
+ </argument>
+ <argument index="1" name="shape_id" type="int">
+ </argument>
<description>
+ Will return a [Shape]. First argument owner_id is an integer that can be obtained from [method get_shape_owners]. Shape_id is a position of the shape inside owner; it's a value in range from 0 to [method shape_owner_get_shape_count].
</description>
</method>
- <method name="is_shape_set_as_trigger" qualifiers="const">
- <return type="bool">
+ <method name="shape_owner_get_shape_count">
+ <return type="int">
</return>
- <argument index="0" name="shape_idx" type="int">
+ <argument index="0" name="owner_id" type="int">
</argument>
<description>
+ Returns number of shapes to which given owner is associated to.
</description>
</method>
- <method name="remove_shape">
- <argument index="0" name="shape_idx" type="int">
+ <method name="shape_owner_get_transform">
+ <return type="Transform">
+ </return>
+ <argument index="0" name="owner_id" type="int">
</argument>
<description>
+ Will return [Transform] of an owner node.
</description>
</method>
- <method name="set_capture_input_on_drag">
- <argument index="0" name="enable" type="bool">
+ <method name="shape_owner_remove_shape">
+ <argument index="0" name="owner_id" type="int">
</argument>
- <description>
- </description>
- </method>
- <method name="set_ray_pickable">
- <argument index="0" name="ray_pickable" type="bool">
+ <argument index="1" name="shape_id" type="int">
</argument>
<description>
+ Removes related shape from the owner.
</description>
</method>
- <method name="set_shape">
- <argument index="0" name="shape_idx" type="int">
- </argument>
- <argument index="1" name="shape" type="Shape">
- </argument>
+ <method name="is_ray_pickable" qualifiers="const">
+ <return type="bool">
+ </return>
<description>
</description>
</method>
- <method name="set_shape_as_trigger">
- <argument index="0" name="shape_idx" type="int">
- </argument>
- <argument index="1" name="enable" type="bool">
+ <method name="set_capture_input_on_drag">
+ <argument index="0" name="enable" type="bool">
</argument>
<description>
</description>
</method>
- <method name="set_shape_transform">
- <argument index="0" name="shape_idx" type="int">
- </argument>
- <argument index="1" name="transform" type="Transform">
+ <method name="set_ray_pickable">
+ <argument index="0" name="ray_pickable" type="bool">
</argument>
<description>
</description>
@@ -9562,18 +10306,13 @@
<description>
</description>
</method>
- <method name="add_shape">
- <argument index="0" name="shape" type="Shape2D">
- </argument>
- <argument index="1" name="transform" type="Transform2D" default="((1, 0), (0, 1), (0, 0))">
+ <method name="create_shape_owner">
+ <return type="int">
+ </return>
+ <argument index="0" name="owner" type="Object">
</argument>
<description>
- Add a [Shape2D] to the collision body, with a given custom transform.
- </description>
- </method>
- <method name="clear_shapes">
- <description>
- Remove all shapes.
+ Creates new holder for the shapes. Argument is a [CollisionShape2D] node. It will return owner_id which usually you will want to save for later use.
</description>
</method>
<method name="get_rid" qualifiers="const">
@@ -9583,86 +10322,70 @@
Return the RID of this object.
</description>
</method>
- <method name="get_shape" qualifiers="const">
- <return type="Shape2D">
- </return>
- <argument index="0" name="shape_idx" type="int">
- </argument>
- <description>
- Return the shape in the given index.
- </description>
- </method>
- <method name="get_shape_count" qualifiers="const">
- <return type="int">
+ <method name="get_shape_owners">
+ <return type="Array">
</return>
<description>
- Return the amount of shapes in the collision body. Because a [CollisionPolygon2D] can generate more than one [Shape2D], the amount returned does not have to match the sum of [CollisionShape2D] and [CollisionPolygon2D].
+ Shape owner is a node which is holding concrete shape resources. This method will return an array which is holding an integer numbers that are representing unique ID of each owner. You can use those ids when you are using others shape_owner methods.
</description>
</method>
- <method name="get_shape_transform" qualifiers="const">
- <return type="Transform2D">
- </return>
- <argument index="0" name="shape_idx" type="int">
+ <method name="shape_owner_clear_shapes">
+ <argument index="0" name="owner_id" type="int">
</argument>
<description>
- Return the shape transform in the given index.
+ Will remove all the shapes associated with given owner.
</description>
</method>
- <method name="is_pickable" qualifiers="const">
- <return type="bool">
- </return>
- <description>
- Return whether this object is pickable.
- </description>
- </method>
- <method name="is_shape_set_as_trigger" qualifiers="const">
- <return type="bool">
+ <method name="shape_owner_get_shape">
+ <return type="Shape2D">
</return>
- <argument index="0" name="shape_idx" type="int">
+ <argument index="0" name="owner_id" type="int">
+ </argument>
+ <argument index="1" name="shape_id" type="int">
</argument>
<description>
- Return whether a shape is a trigger. A trigger shape detects collisions, but is otherwise unaffected by physics (i.e. colliding objects will not get blocked).
+ Will return a [Shape2D]. First argument owner_id is an integer that can be obtained from [method get_shape_owners]. Shape_id is a position of the shape inside owner; it's a value in range from 0 to [method shape_owner_get_shape_count].
</description>
</method>
- <method name="remove_shape">
- <argument index="0" name="shape_idx" type="int">
+ <method name="shape_owner_get_shape_count">
+ <return type="int">
+ </return>
+ <argument index="0" name="owner_id" type="int">
</argument>
<description>
- Remove the shape in the given index.
+ Returns number of shapes to which given owner is associated to.
</description>
</method>
- <method name="set_pickable">
- <argument index="0" name="enabled" type="bool">
+ <method name="shape_owner_get_transform">
+ <return type="Transform2D">
+ </return>
+ <argument index="0" name="owner_id" type="int">
</argument>
<description>
- Set whether this object is pickable. A pickable object can detect the mouse pointer enter/leave it and, if the mouse is inside it, report input events.
+ Will return [Transform2D] of an owner node.
</description>
</method>
- <method name="set_shape">
- <argument index="0" name="shape_idx" type="int">
+ <method name="shape_owner_remove_shape">
+ <argument index="0" name="owner_id" type="int">
</argument>
- <argument index="1" name="shape" type="Shape">
+ <argument index="1" name="shape_id" type="int">
</argument>
<description>
- Change a shape in the collision body.
+ Removes related shape from the owner.
</description>
</method>
- <method name="set_shape_as_trigger">
- <argument index="0" name="shape_idx" type="int">
- </argument>
- <argument index="1" name="enable" type="bool">
- </argument>
+ <method name="is_pickable" qualifiers="const">
+ <return type="bool">
+ </return>
<description>
- Set whether a shape is a trigger. A trigger shape detects collisions, but is otherwise unaffected by physics (i.e. colliding objects will not get blocked).
+ Return whether this object is pickable.
</description>
</method>
- <method name="set_shape_transform">
- <argument index="0" name="shape_idx" type="int">
- </argument>
- <argument index="1" name="transform" type="Transform2D">
+ <method name="set_pickable">
+ <argument index="0" name="enabled" type="bool">
</argument>
<description>
- Change the shape transform in the collision body.
+ Set whether this object is pickable. A pickable object can detect the mouse pointer enter/leave it and, if the mouse is inside it, report input events.
</description>
</method>
</methods>
@@ -9701,24 +10424,6 @@
<description>
</description>
<methods>
- <method name="get_build_mode" qualifiers="const">
- <return type="int">
- </return>
- <description>
- </description>
- </method>
- <method name="get_collision_object_first_shape" qualifiers="const">
- <return type="int">
- </return>
- <description>
- </description>
- </method>
- <method name="get_collision_object_last_shape" qualifiers="const">
- <return type="int">
- </return>
- <description>
- </description>
- </method>
<method name="get_depth" qualifiers="const">
<return type="float">
</return>
@@ -9731,9 +10436,9 @@
<description>
</description>
</method>
- <method name="set_build_mode">
- <argument index="0" name="build_mode" type="int">
- </argument>
+ <method name="is_disabled" qualifiers="const">
+ <return type="bool">
+ </return>
<description>
</description>
</method>
@@ -9743,6 +10448,12 @@
<description>
</description>
</method>
+ <method name="set_disabled">
+ <argument index="0" name="disabled" type="bool">
+ </argument>
+ <description>
+ </description>
+ </method>
<method name="set_polygon">
<argument index="0" name="polygon" type="PoolVector2Array">
</argument>
@@ -9751,13 +10462,11 @@
</method>
</methods>
<members>
- <member name="build_mode" type="int" setter="set_build_mode" getter="get_build_mode" brief="">
- </member>
<member name="depth" type="float" setter="set_depth" getter="get_depth" brief="">
</member>
- <member name="polygon" type="PoolVector2Array" setter="set_polygon" getter="get_polygon" brief="">
+ <member name="disabled" type="bool" setter="set_disabled" getter="is_disabled" brief="">
</member>
- <member name="shape_range" type="Vector2" setter="_set_shape_range" getter="_get_shape_range" brief="">
+ <member name="polygon" type="PoolVector2Array" setter="set_polygon" getter="get_polygon" brief="">
</member>
</members>
<constants>
@@ -9778,34 +10487,23 @@
Return whether the polygon is a [ConvexPolygonShape2D] ([code]build_mode==0[/code]), or a [ConcavePolygonShape2D] ([code]build_mode==1[/code]).
</description>
</method>
- <method name="get_collision_object_first_shape" qualifiers="const">
- <return type="int">
- </return>
- <description>
- Return the index of the first shape generated by the editor.
- When [code]build_mode[/code] is set to generate convex polygons, the shape shown in the editor may be decomposed into many convex polygons. In that case, a range of indexes is needed to directly access the [Shape2D].
- When [code]build_mode[/code] is set to generate concave polygons, there is only one [Shape2D] generated, so the start index and the end index are the same.
- </description>
- </method>
- <method name="get_collision_object_last_shape" qualifiers="const">
- <return type="int">
+ <method name="get_polygon" qualifiers="const">
+ <return type="PoolVector2Array">
</return>
<description>
- Return the index of the last shape generated by the editor.
+ Return the list of points that define the polygon.
</description>
</method>
- <method name="get_polygon" qualifiers="const">
- <return type="PoolVector2Array">
+ <method name="is_disabled" qualifiers="const">
+ <return type="bool">
</return>
<description>
- Return the list of points that define the polygon.
</description>
</method>
- <method name="is_trigger" qualifiers="const">
+ <method name="is_one_way_collision_enabled" qualifiers="const">
<return type="bool">
</return>
<description>
- Return whether this polygon is a trigger.
</description>
</method>
<method name="set_build_mode">
@@ -9815,30 +10513,35 @@
Set whether the polygon is to be a [ConvexPolygonShape2D] ([code]build_mode==0[/code]), or a [ConcavePolygonShape2D] ([code]build_mode==1[/code]).
</description>
</method>
- <method name="set_polygon">
- <argument index="0" name="polygon" type="PoolVector2Array">
+ <method name="set_disabled">
+ <argument index="0" name="disabled" type="bool">
</argument>
<description>
- Set the array of points forming the polygon.
- When editing the point list via the editor, depending on [method get_build_mode], it has to be a list of points (for [code]build_mode==0[/code]), or a list of lines (for [code]build_mode==1[/code]). In the second case, the even elements of the array define the start point of the line, and the odd elements the end point.
</description>
</method>
- <method name="set_trigger">
- <argument index="0" name="trigger" type="bool">
+ <method name="set_one_way_collision">
+ <argument index="0" name="enabled" type="bool">
</argument>
<description>
- Set whether this polygon is a trigger. A trigger polygon detects collisions, but is otherwise unaffected by physics (i.e. colliding objects will not get blocked).
+ </description>
+ </method>
+ <method name="set_polygon">
+ <argument index="0" name="polygon" type="PoolVector2Array">
+ </argument>
+ <description>
+ Set the array of points forming the polygon.
+ When editing the point list via the editor, depending on [method get_build_mode], it has to be a list of points (for [code]build_mode==0[/code]), or a list of lines (for [code]build_mode==1[/code]). In the second case, the even elements of the array define the start point of the line, and the odd elements the end point.
</description>
</method>
</methods>
<members>
<member name="build_mode" type="int" setter="set_build_mode" getter="get_build_mode" brief="">
</member>
- <member name="polygon" type="PoolVector2Array" setter="set_polygon" getter="get_polygon" brief="">
+ <member name="disabled" type="bool" setter="set_disabled" getter="is_disabled" brief="">
</member>
- <member name="shape_range" type="Vector2" setter="_set_shape_range" getter="_get_shape_range" brief="">
+ <member name="one_way_collision" type="bool" setter="set_one_way_collision" getter="is_one_way_collision_enabled" brief="">
</member>
- <member name="trigger" type="bool" setter="set_trigger" getter="is_trigger" brief="">
+ <member name="polygon" type="PoolVector2Array" setter="set_polygon" getter="get_polygon" brief="">
</member>
</members>
<constants>
@@ -9850,19 +10553,13 @@
<description>
</description>
<methods>
- <method name="get_collision_object_shape_index" qualifiers="const">
- <return type="int">
- </return>
- <description>
- </description>
- </method>
<method name="get_shape" qualifiers="const">
<return type="Object">
</return>
<description>
</description>
</method>
- <method name="is_trigger" qualifiers="const">
+ <method name="is_disabled" qualifiers="const">
<return type="bool">
</return>
<description>
@@ -9878,26 +10575,24 @@
<description>
</description>
</method>
- <method name="set_shape">
- <argument index="0" name="shape" type="Object">
+ <method name="set_disabled">
+ <argument index="0" name="enable" type="bool">
</argument>
<description>
</description>
</method>
- <method name="set_trigger">
- <argument index="0" name="enable" type="bool">
+ <method name="set_shape">
+ <argument index="0" name="shape" type="Object">
</argument>
<description>
</description>
</method>
</methods>
<members>
- <member name="_update_shape_index" type="int" setter="_set_update_shape_index" getter="_get_update_shape_index" brief="">
+ <member name="disabled" type="bool" setter="set_disabled" getter="is_disabled" brief="">
</member>
<member name="shape" type="Shape" setter="set_shape" getter="get_shape" brief="">
</member>
- <member name="trigger" type="bool" setter="set_trigger" getter="is_trigger" brief="">
- </member>
</members>
<constants>
</constants>
@@ -9910,48 +10605,51 @@
Editor-only class. This is not present when running the game. It's used in the editor to properly edit and position collision shapes in [CollisionObject2D]. This is not accessible from regular code.
</description>
<methods>
- <method name="get_collision_object_shape_index" qualifiers="const">
- <return type="int">
+ <method name="get_shape" qualifiers="const">
+ <return type="Object">
</return>
<description>
- Return the index of this shape inside its container [CollisionObject2D]. This can be used to directly access the underlying [Shape2D].
+ Return this shape's [Shape2D].
</description>
</method>
- <method name="get_shape" qualifiers="const">
- <return type="Object">
+ <method name="is_disabled" qualifiers="const">
+ <return type="bool">
</return>
<description>
- Return this shape's [Shape2D].
</description>
</method>
- <method name="is_trigger" qualifiers="const">
+ <method name="is_one_way_collision_enabled" qualifiers="const">
<return type="bool">
</return>
<description>
- Return whether this shape is a trigger.
</description>
</method>
- <method name="set_shape">
- <argument index="0" name="shape" type="Object">
+ <method name="set_disabled">
+ <argument index="0" name="disabled" type="bool">
</argument>
<description>
- Set this shape's [Shape2D]. This will not appear as a node, but can be directly edited as a property.
</description>
</method>
- <method name="set_trigger">
- <argument index="0" name="enable" type="bool">
+ <method name="set_one_way_collision">
+ <argument index="0" name="enabled" type="bool">
</argument>
<description>
- Set whether this shape is a trigger. A trigger shape detects collisions, but is otherwise unaffected by physics (i.e. will not block movement of colliding objects).
+ </description>
+ </method>
+ <method name="set_shape">
+ <argument index="0" name="shape" type="Object">
+ </argument>
+ <description>
+ Set this shape's [Shape2D]. This will not appear as a node, but can be directly edited as a property.
</description>
</method>
</methods>
<members>
- <member name="_update_shape_index" type="int" setter="_set_update_shape_index" getter="_get_update_shape_index" brief="">
+ <member name="disabled" type="bool" setter="set_disabled" getter="is_disabled" brief="">
</member>
- <member name="shape" type="Shape2D" setter="set_shape" getter="get_shape" brief="">
+ <member name="one_way_collision" type="bool" setter="set_one_way_collision" getter="is_one_way_collision_enabled" brief="">
</member>
- <member name="trigger" type="bool" setter="set_trigger" getter="is_trigger" brief="">
+ <member name="shape" type="Shape2D" setter="set_shape" getter="get_shape" brief="">
</member>
</members>
<constants>
@@ -10190,17 +10888,17 @@
</theme_item>
<theme_item name="color_sample" type="Texture">
</theme_item>
- <theme_item name="color_width" type="int">
- </theme_item>
- <theme_item name="hseparator" type="int">
+ <theme_item name="h_width" type="int">
</theme_item>
<theme_item name="label_width" type="int">
</theme_item>
+ <theme_item name="margin" type="int">
+ </theme_item>
<theme_item name="screen_picker" type="Texture">
</theme_item>
- <theme_item name="value_height" type="int">
+ <theme_item name="sv_height" type="int">
</theme_item>
- <theme_item name="value_width" type="int">
+ <theme_item name="sv_width" type="int">
</theme_item>
</theme_items>
</class>
@@ -10821,6 +11519,12 @@
Return position and size of the Control, relative to the top-left corner of the [i]window[/i] Control. This is a helper (see [method get_global_pos], [method get_size]).
</description>
</method>
+ <method name="get_h_grow_direction" qualifiers="const">
+ <return type="int">
+ </return>
+ <description>
+ </description>
+ </method>
<method name="get_h_size_flags" qualifiers="const">
<return type="int">
</return>
@@ -10873,6 +11577,12 @@
<description>
</description>
</method>
+ <method name="get_pivot_offset" qualifiers="const">
+ <return type="Vector2">
+ </return>
+ <description>
+ </description>
+ </method>
<method name="get_position" qualifiers="const">
<return type="Vector2">
</return>
@@ -10911,7 +11621,7 @@
<return type="Vector2">
</return>
<description>
- Returns the size of the Control, computed from all margins, however the size returned will [b]never be smaller than the minimum size reported by [method get_minimum_size][/b]. This means that even if end position of the Control rectangle is smaller than the begin position, the Control will still display and interact correctly. (see description, [method get_minimum_size], [method set_margin], [method set_anchor]).
+ Returns the size of the Control, computed from all margins, however the size returned will [b]never be smaller than the minimum size reported by[/b] [method get_minimum_size]. This means that even if end position of the Control rectangle is smaller than the begin position, the Control will still display and interact correctly. (see description, [method get_minimum_size], [method set_margin], [method set_anchor]).
</description>
</method>
<method name="get_stretch_ratio" qualifiers="const">
@@ -10947,6 +11657,12 @@
Return the tooltip, which will appear when the cursor is resting over this control.
</description>
</method>
+ <method name="get_v_grow_direction" qualifiers="const">
+ <return type="int">
+ </return>
+ <description>
+ </description>
+ </method>
<method name="get_v_size_flags" qualifiers="const">
<return type="int">
</return>
@@ -11179,6 +11895,12 @@
Move the Control to a new position, relative to the top-left corner of the [i]window[/i] Control, and without changing current anchor mode. (see [method set_margin]).
</description>
</method>
+ <method name="set_h_grow_direction">
+ <argument index="0" name="direction" type="int">
+ </argument>
+ <description>
+ </description>
+ </method>
<method name="set_h_size_flags">
<argument index="0" name="flags" type="int">
</argument>
@@ -11202,6 +11924,12 @@
Set when the control is ignoring mouse events (even touchpad events send mouse events). (see the MOUSE_FILTER_* constants)
</description>
</method>
+ <method name="set_pivot_offset">
+ <argument index="0" name="pivot_offset" type="Vector2">
+ </argument>
+ <description>
+ </description>
+ </method>
<method name="set_position">
<argument index="0" name="pos" type="Vector2">
</argument>
@@ -11257,6 +11985,12 @@
Set a tooltip, which will appear when the cursor is resting over this control.
</description>
</method>
+ <method name="set_v_grow_direction">
+ <argument index="0" name="direction" type="int">
+ </argument>
+ <description>
+ </description>
+ </method>
<method name="set_v_size_flags">
<argument index="0" name="flags" type="int">
</argument>
@@ -11295,6 +12029,10 @@
</member>
<member name="focus_neighbour_top" type="NodePath" setter="set_focus_neighbour" getter="get_focus_neighbour" brief="">
</member>
+ <member name="grow_horizontal" type="int" setter="set_h_grow_direction" getter="get_h_grow_direction" brief="">
+ </member>
+ <member name="grow_vertical" type="int" setter="set_v_grow_direction" getter="get_v_grow_direction" brief="">
+ </member>
<member name="hint_tooltip" type="String" setter="set_tooltip" getter="_get_tooltip" brief="">
</member>
<member name="margin_bottom" type="int" setter="set_margin" getter="get_margin" brief="">
@@ -11311,6 +12049,8 @@
</member>
<member name="rect_min_size" type="Vector2" setter="set_custom_minimum_size" getter="get_custom_minimum_size" brief="">
</member>
+ <member name="rect_pivot_offset" type="Vector2" setter="set_pivot_offset" getter="get_pivot_offset" brief="">
+ </member>
<member name="rect_position" type="Vector2" setter="set_position" getter="get_position" brief="">
</member>
<member name="rect_rotation" type="float" setter="set_rotation_deg" getter="get_rotation_deg" brief="">
@@ -11454,12 +12194,20 @@
</constant>
<constant name="SIZE_EXPAND_FILL" value="3">
</constant>
+ <constant name="SIZE_SHRINK_CENTER" value="4">
+ </constant>
+ <constant name="SIZE_SHRINK_END" value="8">
+ </constant>
<constant name="MOUSE_FILTER_STOP" value="0">
</constant>
<constant name="MOUSE_FILTER_PASS" value="1">
</constant>
<constant name="MOUSE_FILTER_IGNORE" value="2">
</constant>
+ <constant name="GROW_DIRECTION_BEGIN" value="0">
+ </constant>
+ <constant name="GROW_DIRECTION_END" value="1">
+ </constant>
</constants>
</class>
<class name="ConvexPolygonShape" inherits="Shape" category="Core">
@@ -11696,6 +12444,206 @@
<constants>
</constants>
</class>
+<class name="Curve" inherits="Resource" category="Core">
+ <brief_description>
+ </brief_description>
+ <description>
+ </description>
+ <methods>
+ <method name="add_point">
+ <return type="int">
+ </return>
+ <argument index="0" name="pos" type="Vector2">
+ </argument>
+ <argument index="1" name="left_tangent" type="float" default="0">
+ </argument>
+ <argument index="2" name="right_tangent" type="float" default="0">
+ </argument>
+ <argument index="3" name="left_mode" type="int" default="0">
+ </argument>
+ <argument index="4" name="right_mode" type="int" default="0">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="bake">
+ <description>
+ </description>
+ </method>
+ <method name="clean_dupes">
+ <description>
+ </description>
+ </method>
+ <method name="clear_points">
+ <description>
+ </description>
+ </method>
+ <method name="get_bake_resolution" qualifiers="const">
+ <return type="int">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="get_max_value" qualifiers="const">
+ <return type="float">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="get_min_value" qualifiers="const">
+ <return type="float">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="get_point_left_mode" qualifiers="const">
+ <return type="int">
+ </return>
+ <argument index="0" name="index" type="int">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="get_point_left_tangent" qualifiers="const">
+ <return type="float">
+ </return>
+ <argument index="0" name="index" type="int">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="get_point_pos" qualifiers="const">
+ <return type="Vector2">
+ </return>
+ <argument index="0" name="index" type="int">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="get_point_right_mode" qualifiers="const">
+ <return type="int">
+ </return>
+ <argument index="0" name="index" type="int">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="get_point_right_tangent" qualifiers="const">
+ <return type="float">
+ </return>
+ <argument index="0" name="index" type="int">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="interpolate" qualifiers="const">
+ <return type="float">
+ </return>
+ <argument index="0" name="offset" type="float">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="interpolate_baked">
+ <return type="float">
+ </return>
+ <argument index="0" name="offset" type="float">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="remove_point">
+ <argument index="0" name="index" type="int">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="set_bake_resolution">
+ <argument index="0" name="resolution" type="int">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="set_max_value">
+ <argument index="0" name="max" type="float">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="set_min_value">
+ <argument index="0" name="min" type="float">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="set_point_left_mode">
+ <argument index="0" name="index" type="int">
+ </argument>
+ <argument index="1" name="mode" type="int">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="set_point_left_tangent">
+ <argument index="0" name="index" type="int">
+ </argument>
+ <argument index="1" name="tangent" type="float">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="set_point_offset">
+ <argument index="0" name="index" type="int">
+ </argument>
+ <argument index="1" name="offset" type="float">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="set_point_right_mode">
+ <argument index="0" name="index" type="int">
+ </argument>
+ <argument index="1" name="mode" type="int">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="set_point_right_tangent">
+ <argument index="0" name="index" type="int">
+ </argument>
+ <argument index="1" name="tangent" type="float">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="set_point_value">
+ <argument index="0" name="index" type="int">
+ </argument>
+ <argument index="1" name="y" type="float">
+ </argument>
+ <description>
+ </description>
+ </method>
+ </methods>
+ <members>
+ <member name="_data" type="int" setter="_set_data" getter="_get_data" brief="">
+ </member>
+ <member name="bake_resolution" type="int" setter="set_bake_resolution" getter="get_bake_resolution" brief="">
+ </member>
+ <member name="max_value" type="float" setter="set_max_value" getter="get_max_value" brief="">
+ </member>
+ <member name="min_value" type="float" setter="set_min_value" getter="get_min_value" brief="">
+ </member>
+ </members>
+ <signals>
+ <signal name="range_changed">
+ <description>
+ </description>
+ </signal>
+ </signals>
+ <constants>
+ </constants>
+</class>
<class name="Curve2D" inherits="Resource" category="Core">
<brief_description>
Describes a Bezier curve in 2D space.
@@ -12090,38 +13038,14 @@
<description>
</description>
<methods>
- <method name="get_max" qualifiers="const">
- <return type="float">
- </return>
- <description>
- </description>
- </method>
- <method name="get_min" qualifiers="const">
- <return type="float">
- </return>
- <description>
- </description>
- </method>
- <method name="get_points" qualifiers="const">
- <return type="PoolVector2Array">
+ <method name="get_curve" qualifiers="const">
+ <return type="Curve">
</return>
<description>
</description>
</method>
- <method name="set_max">
- <argument index="0" name="max" type="float">
- </argument>
- <description>
- </description>
- </method>
- <method name="set_min">
- <argument index="0" name="min" type="float">
- </argument>
- <description>
- </description>
- </method>
- <method name="set_points">
- <argument index="0" name="points" type="PoolVector2Array">
+ <method name="set_curve">
+ <argument index="0" name="curve" type="Curve">
</argument>
<description>
</description>
@@ -12134,11 +13058,7 @@
</method>
</methods>
<members>
- <member name="max" type="float" setter="set_max" getter="get_max" brief="">
- </member>
- <member name="min" type="float" setter="set_min" getter="get_min" brief="">
- </member>
- <member name="points" type="PoolVector2Array" setter="set_points" getter="get_points" brief="">
+ <member name="curve" type="Curve" setter="set_curve" getter="get_curve" brief="">
</member>
<member name="width" type="int" setter="set_width" getter="get_width" brief="">
</member>
@@ -13261,7 +14181,7 @@
<description>
Add a custom type, which will appear in the list of nodes or resources. An icon can be optionally passed.
When given node or resource is selected, the base type will be instanced (ie, "Spatial", "Control", "Resource"), then the script will be loaded and set to this object.
- You can use the [method EditorPlugin.handles] to check if your custom object is being edited by checking the script or using 'extends' keyword.
+ You can use the [method EditorPlugin.handles] to check if your custom object is being edited by checking the script or using 'is' keyword.
During run-time, this will be a simple object with a script so this function does not need to be called then.
</description>
</method>
@@ -13339,6 +14259,8 @@
<argument index="1" name="event" type="InputEvent">
</argument>
<description>
+ Implement this function if you are interested in 3D view screen input events. It will be called only if currently selected node is handled by your plugin.
+ If you would like to always gets those input events then additionally use [method set_input_forwarding_always_enabled].
</description>
</method>
<method name="get_base_control">
@@ -13362,6 +14284,13 @@
Get the general settings for the editor (the same window that appears in the Settings menu).
</description>
</method>
+ <method name="get_edited_scene_root">
+ <return type="Node">
+ </return>
+ <description>
+ Returns root node of currently edited scene.
+ </description>
+ </method>
<method name="get_editor_viewport">
<return type="Control">
</return>
@@ -13376,6 +14305,13 @@
Get the name of the editor plugin. For main scren plugins this is what will appear in the selector (which by default is 2D, 3D, Script).
</description>
</method>
+ <method name="get_open_scenes">
+ <return type="Array">
+ </return>
+ <description>
+ Will return an Array of Strings which represent file paths to currently open scenes.
+ </description>
+ </method>
<method name="get_resource_filesystem">
<return type="EditorFileSystem">
</return>
@@ -13390,6 +14326,13 @@
Get tool for generating resource previews.
</description>
</method>
+ <method name="get_script_editor">
+ <return type="ScriptEditor">
+ </return>
+ <description>
+ Will return ScriptEditor object which contains informations about state of the scripts which are currently open by the editor.
+ </description>
+ </method>
<method name="get_selection">
<return type="EditorSelection">
</return>
@@ -13461,11 +14404,25 @@
Remember that you have to manage the visibility of all your editor controls manually.
</description>
</method>
+ <method name="open_scene_from_path">
+ <argument index="0" name="scene_filepath" type="String">
+ </argument>
+ <description>
+ Opens scene in editor. Do not use during plugin initialization. If you need, then use it together with [method Object.call_deferred].
+ </description>
+ </method>
<method name="queue_save_layout" qualifiers="const">
<description>
Queue save the project's editor layout.
</description>
</method>
+ <method name="reload_scene_from_path">
+ <argument index="0" name="scene_filepath" type="String">
+ </argument>
+ <description>
+ Reloads already loaded editor scene.
+ </description>
+ </method>
<method name="remove_control_from_bottom_panel">
<argument index="0" name="control" type="Control">
</argument>
@@ -13498,6 +14455,11 @@
This method is called after the editor saves the project or when it's closed. It asks the plugin to save edited external scenes/resources.
</description>
</method>
+ <method name="set_input_event_forwarding_always_enabled">
+ <description>
+ Use this method if you always want to receive inputs from 3D view screen inside [method forward_spatial_gui_input]. It might be especially usable if your plugin will want to use raycast in the scene.
+ </description>
+ </method>
<method name="set_state" qualifiers="virtual">
<argument index="0" name="state" type="Dictionary">
</argument>
@@ -13552,6 +14514,29 @@
<constant name="DOCK_SLOT_MAX" value="8">
</constant>
</constants>
+ <signals>
+ <signal name="main_screen_changed">
+ <argument index="0" name="screen_name" type="String">
+ </argument>
+ <description>
+ Emitted when user change main screen view (2D, 3D, Script, AssetLib). Works also with screens which are defined by plugins.
+ </description>
+ </signal>
+ <signal name="scene_changed">
+ <argument index="0" name="scene_root" type="Node">
+ </argument>
+ <description>
+ Emitted when user change scene. The argument is a root node of freshly opened scene.
+ </description>
+ </signal>
+ <signal name="scene_closed">
+ <argument index="0" name="filepath" type="String">
+ </argument>
+ <description>
+ Emitted when user close scene. The argument is file path to a closed scene.
+ </description>
+ </signal>
+ </signals>
</class>
<class name="EditorResourcePreview" inherits="Node" category="Core">
<brief_description>
@@ -14254,7 +15239,7 @@
<description>
</description>
</method>
- <method name="get_glow_hdr_bleed_treshold" qualifiers="const">
+ <method name="get_glow_hdr_bleed_threshold" qualifiers="const">
<return type="float">
</return>
<description>
@@ -14724,8 +15709,8 @@
<description>
</description>
</method>
- <method name="set_glow_hdr_bleed_treshold">
- <argument index="0" name="treshold" type="float">
+ <method name="set_glow_hdr_bleed_threshold">
+ <argument index="0" name="threshold" type="float">
</argument>
<description>
</description>
@@ -14751,7 +15736,7 @@
</description>
</method>
<method name="set_sky">
- <argument index="0" name="sky" type="CubeMap">
+ <argument index="0" name="sky" type="Sky">
</argument>
<description>
</description>
@@ -14996,7 +15981,7 @@
</member>
<member name="glow_hdr_scale" type="float" setter="set_glow_hdr_bleed_scale" getter="get_glow_hdr_bleed_scale" brief="">
</member>
- <member name="glow_hdr_treshold" type="float" setter="set_glow_hdr_bleed_treshold" getter="get_glow_hdr_bleed_treshold" brief="">
+ <member name="glow_hdr_threshold" type="float" setter="set_glow_hdr_bleed_threshold" getter="get_glow_hdr_bleed_threshold" brief="">
</member>
<member name="glow_intensity" type="float" setter="set_glow_intensity" getter="get_glow_intensity" brief="">
</member>
@@ -15467,6 +16452,8 @@
<constant name="COMPRESSION_ZSTD" value="2">
Use the Zstd compression method.
</constant>
+ <constant name="COMPRESSION_GZIP" value="3">
+ </constant>
</constants>
</class>
<class name="FileDialog" inherits="ConfirmationDialog" category="Core">
@@ -15814,6 +16801,14 @@
</description>
</method>
</methods>
+ <signals>
+ <signal name="completed">
+ <argument index="0" name="result" type="Nil">
+ </argument>
+ <description>
+ </description>
+ </signal>
+ </signals>
<constants>
</constants>
</class>
@@ -15967,6 +16962,12 @@
<description>
</description>
</method>
+ <method name="get_normal_bias" qualifiers="const">
+ <return type="float">
+ </return>
+ <description>
+ </description>
+ </method>
<method name="get_probe_data" qualifiers="const">
<return type="Object">
</return>
@@ -16033,6 +17034,12 @@
<description>
</description>
</method>
+ <method name="set_normal_bias">
+ <argument index="0" name="max" type="float">
+ </argument>
+ <description>
+ </description>
+ </method>
<method name="set_probe_data">
<argument index="0" name="data" type="Object">
</argument>
@@ -16067,6 +17074,8 @@
</member>
<member name="interior" type="bool" setter="set_interior" getter="is_interior" brief="">
</member>
+ <member name="normal_bias" type="float" setter="set_normal_bias" getter="get_normal_bias" brief="">
+ </member>
<member name="propagation" type="float" setter="set_propagation" getter="get_propagation" brief="">
</member>
<member name="subdiv" type="int" setter="set_subdiv" getter="get_subdiv" brief="">
@@ -16125,6 +17134,12 @@
<description>
</description>
</method>
+ <method name="get_normal_bias" qualifiers="const">
+ <return type="float">
+ </return>
+ <description>
+ </description>
+ </method>
<method name="get_propagation" qualifiers="const">
<return type="float">
</return>
@@ -16197,6 +17212,12 @@
<description>
</description>
</method>
+ <method name="set_normal_bias">
+ <argument index="0" name="bias" type="float">
+ </argument>
+ <description>
+ </description>
+ </method>
<method name="set_propagation">
<argument index="0" name="propagation" type="float">
</argument>
@@ -16227,6 +17248,8 @@
</member>
<member name="interior" type="bool" setter="set_interior" getter="is_interior" brief="">
</member>
+ <member name="normal_bias" type="float" setter="set_normal_bias" getter="get_normal_bias" brief="">
+ </member>
<member name="propagation" type="float" setter="set_propagation" getter="get_propagation" brief="">
</member>
<member name="to_cell_xform" type="Transform" setter="set_to_cell_xform" getter="get_to_cell_xform" brief="">
@@ -16863,7 +17886,7 @@
</member>
<member name="lod_min_hysteresis" type="int" setter="set_lod_min_hysteresis" getter="get_lod_min_hysteresis" brief="">
</member>
- <member name="material_override" type="Material" setter="set_material_override" getter="get_material_override" brief="">
+ <member name="material_override" type="ShaderMaterial,SpatialMaterial" setter="set_material_override" getter="get_material_override" brief="">
</member>
<member name="use_in_baked_light" type="bool" setter="set_flag" getter="get_flag" brief="">
</member>
@@ -16887,7 +17910,7 @@
</constant>
</constants>
</class>
-<class name="GlobalConfig" inherits="Object" category="Core">
+<class name="ProjectSettings" inherits="Object" category="Core">
<brief_description>
Contains global variables accessible from everywhere.
</brief_description>
@@ -16991,6 +18014,8 @@
</description>
</method>
<method name="property_get_revert">
+ <return type="Variant">
+ </return>
<argument index="0" name="name" type="String">
</argument>
<description>
@@ -17151,86 +18176,14 @@
<description>
</description>
<methods>
- <method name="add_point">
- <argument index="0" name="offset" type="float">
- </argument>
- <argument index="1" name="color" type="Color">
- </argument>
- <description>
- </description>
- </method>
- <method name="get_color" qualifiers="const">
- <return type="Color">
- </return>
- <argument index="0" name="point" type="int">
- </argument>
- <description>
- </description>
- </method>
- <method name="get_colors" qualifiers="const">
- <return type="PoolColorArray">
- </return>
- <description>
- </description>
- </method>
- <method name="get_offset" qualifiers="const">
- <return type="float">
- </return>
- <argument index="0" name="point" type="int">
- </argument>
- <description>
- </description>
- </method>
- <method name="get_offsets" qualifiers="const">
- <return type="PoolRealArray">
- </return>
- <description>
- </description>
- </method>
- <method name="get_point_count" qualifiers="const">
- <return type="int">
- </return>
- <description>
- </description>
- </method>
- <method name="interpolate">
- <return type="Color">
+ <method name="get_gradient" qualifiers="const">
+ <return type="Gradient">
</return>
- <argument index="0" name="offset" type="float">
- </argument>
- <description>
- </description>
- </method>
- <method name="remove_point">
- <argument index="0" name="offset" type="int">
- </argument>
- <description>
- </description>
- </method>
- <method name="set_color">
- <argument index="0" name="point" type="int">
- </argument>
- <argument index="1" name="color" type="Color">
- </argument>
- <description>
- </description>
- </method>
- <method name="set_colors">
- <argument index="0" name="colors" type="PoolColorArray">
- </argument>
- <description>
- </description>
- </method>
- <method name="set_offset">
- <argument index="0" name="point" type="int">
- </argument>
- <argument index="1" name="offset" type="float">
- </argument>
<description>
</description>
</method>
- <method name="set_offsets">
- <argument index="0" name="offsets" type="PoolRealArray">
+ <method name="set_gradient">
+ <argument index="0" name="gradient" type="Gradient">
</argument>
<description>
</description>
@@ -17243,9 +18196,7 @@
</method>
</methods>
<members>
- <member name="colors" type="float" setter="set_colors" getter="get_colors" brief="">
- </member>
- <member name="offsets" type="float" setter="set_offsets" getter="get_offsets" brief="">
+ <member name="gradient" type="Gradient" setter="set_gradient" getter="get_gradient" brief="">
</member>
<member name="width" type="int" setter="set_width" getter="get_width" brief="">
</member>
@@ -18230,6 +19181,10 @@
</theme_item>
<theme_item name="grabber" type="Texture">
</theme_item>
+ <theme_item name="grabber_disabled" type="Texture">
+ </theme_item>
+ <theme_item name="grabber_disabled" type="StyleBox">
+ </theme_item>
<theme_item name="grabber_highlight" type="Texture">
</theme_item>
<theme_item name="grabber_highlight" type="StyleBox">
@@ -19006,6 +19961,19 @@
Copy a "src_rect" [Rect2] from "src" [Image] to this [Image] on coordinates "dest".
</description>
</method>
+ <method name="blit_rect_mask">
+ <argument index="0" name="src" type="Image">
+ </argument>
+ <argument index="1" name="mask" type="Image">
+ </argument>
+ <argument index="2" name="src_rect" type="Rect2">
+ </argument>
+ <argument index="3" name="dst" type="Vector2">
+ </argument>
+ <description>
+ Blits a "src_rect" [Rect2] from "src" [Image] to this [Image] using a "mask" [Image] on coordinates "dest". Alpha channel is required for "mask", will copy src pixel onto dest if the corresponding mask pixel's alpha value is not 0. "src" [Image] and "mask" [Image] *must* have the same size (width and height) but they can have different formats
+ </description>
+ </method>
<method name="clear_mipmaps">
<description>
</description>
@@ -19217,16 +20185,6 @@
<description>
</description>
</method>
- <method name="put_pixel">
- <argument index="0" name="x" type="int">
- </argument>
- <argument index="1" name="y" type="int">
- </argument>
- <argument index="2" name="color" type="Color">
- </argument>
- <description>
- </description>
- </method>
<method name="resize">
<argument index="0" name="width" type="int">
</argument>
@@ -19238,7 +20196,7 @@
</description>
</method>
<method name="resize_to_po2">
- <argument index="0" name="square" type="bool" default="&quot;false&quot;">
+ <argument index="0" name="square" type="bool" default="false">
</argument>
<description>
</description>
@@ -19252,6 +20210,16 @@
Save this [Image] as a png.
</description>
</method>
+ <method name="set_pixel">
+ <argument index="0" name="x" type="int">
+ </argument>
+ <argument index="1" name="y" type="int">
+ </argument>
+ <argument index="2" name="color" type="Color">
+ </argument>
+ <description>
+ </description>
+ </method>
<method name="shrink_x2">
<description>
</description>
@@ -19983,6 +20951,14 @@
<description>
</description>
</method>
+ <method name="shortcut_match" qualifiers="const">
+ <return type="bool">
+ </return>
+ <argument index="0" name="event" type="InputEvent">
+ </argument>
+ <description>
+ </description>
+ </method>
<method name="xformed_by" qualifiers="const">
<return type="InputEvent">
</return>
@@ -19994,6 +20970,10 @@
</description>
</method>
</methods>
+ <members>
+ <member name="device" type="int" setter="set_device" getter="get_device" brief="">
+ </member>
+ </members>
<constants>
</constants>
</class>
@@ -20881,6 +21861,8 @@
</description>
</method>
<method name="get_item_metadata" qualifiers="const">
+ <return type="Variant">
+ </return>
<argument index="0" name="idx" type="int">
</argument>
<description>
@@ -21150,6 +22132,26 @@
</description>
</method>
</methods>
+ <members>
+ <member name="allow_rmb_select" type="bool" setter="set_allow_rmb_select" getter="get_allow_rmb_select" brief="">
+ </member>
+ <member name="fixed_column_width" type="int" setter="set_fixed_column_width" getter="get_fixed_column_width" brief="">
+ </member>
+ <member name="icon_mode" type="int" setter="set_icon_mode" getter="get_icon_mode" brief="">
+ </member>
+ <member name="icon_scale" type="float" setter="set_icon_scale" getter="get_icon_scale" brief="">
+ </member>
+ <member name="items" type="Array" setter="_set_items" getter="_get_items" brief="">
+ </member>
+ <member name="max_columns" type="int" setter="set_max_columns" getter="get_max_columns" brief="">
+ </member>
+ <member name="max_text_lines" type="int" setter="set_max_text_lines" getter="get_max_text_lines" brief="">
+ </member>
+ <member name="same_column_width" type="bool" setter="set_same_column_width" getter="is_same_column_width" brief="">
+ </member>
+ <member name="select_mode" type="int" setter="set_select_mode" getter="get_select_mode" brief="">
+ </member>
+ </members>
<signals>
<signal name="item_activated">
<argument index="0" name="index" type="int">
@@ -21379,129 +22381,144 @@
Kinematic Characters: KinematicBody also has an api for moving objects (the [method move] method) while performing collision tests. This makes them really useful to implement characters that collide against a world, but that don't require advanced physics.
</description>
<methods>
- <method name="can_collide_with_character_bodies" qualifiers="const">
- <return type="bool">
+ <method name="get_collision_collider" qualifiers="const">
+ <return type="Object">
</return>
+ <argument index="0" name="collision" type="int">
+ </argument>
<description>
- Return if this body can collide with character bodies.
</description>
</method>
- <method name="can_collide_with_kinematic_bodies" qualifiers="const">
- <return type="bool">
+ <method name="get_collision_collider_id" qualifiers="const">
+ <return type="int">
</return>
+ <argument index="0" name="collision" type="int">
+ </argument>
<description>
- Return if this body can collide with kinematic bodies.
</description>
</method>
- <method name="can_collide_with_rigid_bodies" qualifiers="const">
- <return type="bool">
- </return>
+ <method name="get_collision_collider_metadata" qualifiers="const">
+ <argument index="0" name="collision" type="int">
+ </argument>
<description>
- Return if this body can collide with rigid bodies.
</description>
</method>
- <method name="can_collide_with_static_bodies" qualifiers="const">
- <return type="bool">
+ <method name="get_collision_collider_shape" qualifiers="const">
+ <return type="Object">
</return>
+ <argument index="0" name="collision" type="int">
+ </argument>
<description>
- Return if this body can collide with static bodies.
</description>
</method>
- <method name="can_teleport_to">
- <return type="bool">
+ <method name="get_collision_collider_shape_index" qualifiers="const">
+ <return type="int">
</return>
- <argument index="0" name="position" type="Vector3">
+ <argument index="0" name="collision" type="int">
</argument>
<description>
- Returns whether the KinematicBody can be teleported to the destination given as an argument, checking all collision shapes of the body against potential colliders at the destination.
</description>
</method>
- <method name="get_collider" qualifiers="const">
- <return type="Variant">
+ <method name="get_collision_collider_velocity" qualifiers="const">
+ <return type="Vector3">
</return>
+ <argument index="0" name="collision" type="int">
+ </argument>
<description>
- Return the body that collided with this one.
</description>
</method>
- <method name="get_collider_shape" qualifiers="const">
+ <method name="get_collision_count" qualifiers="const">
<return type="int">
</return>
<description>
- Return the shape index from the body that collided with this one. If there is no collision, this method will return 0, so collisions must be checked first with [method is_colliding].
</description>
</method>
- <method name="get_collider_velocity" qualifiers="const">
- <return type="Vector3">
+ <method name="get_collision_local_shape" qualifiers="const">
+ <return type="Object">
</return>
+ <argument index="0" name="collision" type="int">
+ </argument>
<description>
- Return the velocity of the body that collided with this one.
</description>
</method>
- <method name="get_collision_margin" qualifiers="const">
- <return type="float">
+ <method name="get_collision_normal" qualifiers="const">
+ <return type="Vector3">
</return>
+ <argument index="0" name="collision" type="int">
+ </argument>
<description>
- Return the collision margin for this object.
</description>
</method>
- <method name="get_collision_normal" qualifiers="const">
+ <method name="get_collision_position" qualifiers="const">
<return type="Vector3">
</return>
+ <argument index="0" name="collision" type="int">
+ </argument>
<description>
- Return the normal of the surface the body collided with. This is useful to implement sliding along a surface.
</description>
</method>
- <method name="get_collision_pos" qualifiers="const">
+ <method name="get_collision_remainder" qualifiers="const">
<return type="Vector3">
</return>
+ <argument index="0" name="collision" type="int">
+ </argument>
<description>
- Return the point in space where the body is touching another. If there is no collision, this method will return (0,0,0), so collisions must be checked first with [method is_colliding].
</description>
</method>
- <method name="get_move_and_slide_colliders" qualifiers="const">
- <return type="Array">
+ <method name="get_collision_travel" qualifiers="const">
+ <return type="Vector3">
</return>
+ <argument index="0" name="collision" type="int">
+ </argument>
<description>
</description>
</method>
- <method name="get_travel" qualifiers="const">
+ <method name="get_floor_velocity" qualifiers="const">
<return type="Vector3">
</return>
<description>
</description>
</method>
- <method name="is_colliding" qualifiers="const">
- <return type="bool">
+ <method name="get_safe_margin" qualifiers="const">
+ <return type="float">
</return>
<description>
- Return whether the body is colliding with another.
</description>
</method>
- <method name="is_move_and_slide_on_ceiling" qualifiers="const">
+ <method name="is_on_ceiling" qualifiers="const">
<return type="bool">
</return>
<description>
</description>
</method>
- <method name="is_move_and_slide_on_floor" qualifiers="const">
+ <method name="is_on_floor" qualifiers="const">
<return type="bool">
</return>
<description>
</description>
</method>
- <method name="is_move_and_slide_on_wall" qualifiers="const">
+ <method name="is_on_wall" qualifiers="const">
<return type="bool">
</return>
<description>
</description>
</method>
<method name="move">
- <return type="Vector3">
+ <return type="Dictionary">
</return>
<argument index="0" name="rel_vec" type="Vector3">
</argument>
<description>
- Move the body in the given direction, stopping if there is an obstacle. The returned vector is how much movement was remaining before being stopped.
+ Move the body in the given direction, stopping if there is an obstacle. If as a result of a movement there will be any collision then informations about this collision will be in returned dictionary. Dictionary will contains those keys:
+ - "position" - collision position
+ - "normal" - collision normal
+ - "local_shape" - id of this kinematic body shape that took part in a collision
+ - "travel" - traveled movement before being stopped
+ - "remainder" - remaining movement before being stopped
+ - "collider_id" - id of the collider, it can be used when dealing with [PhysicsServer]
+ - "collider" - colliding body
+ - "collider_shape_index" - index of the colliding shape, inside collider body "collider_metadata"
+ If the body did not intersect anything, then an empty dictionary (dir.empty()==true) is returned instead. Please note that this method is less user friendly than [method move_and_slide]. If you don't want to program each edge case manually, then it's recommended to use [method move_and_slide] instead.
</description>
</method>
<method name="move_and_slide">
@@ -21511,78 +22528,34 @@
</argument>
<argument index="1" name="floor_normal" type="Vector3" default="Vector3(0, 0, 0)">
</argument>
- <argument index="2" name="ceil_normal" type="Vector3" default="Vector3(0, 0, 0)">
+ <argument index="2" name="slope_stop_min_velocity" type="float" default="0.05">
</argument>
- <argument index="3" name="slope_stop_min_velocity" type="float" default="5">
- </argument>
- <argument index="4" name="max_bounces" type="int" default="4">
- </argument>
- <argument index="5" name="floor_max_angle" type="float" default="0.785398">
- </argument>
- <argument index="6" name="ceil_max_angle" type="float" default="0.785398">
- </argument>
- <description>
- </description>
- </method>
- <method name="move_to">
- <return type="Vector3">
- </return>
- <argument index="0" name="position" type="Vector3">
- </argument>
- <description>
- Move the body to the given position. This is not a teleport, and the body will stop if there is an obstacle. The returned vector is how much movement was remaining before being stopped.
- </description>
- </method>
- <method name="revert_motion">
- <description>
- </description>
- </method>
- <method name="set_collide_with_character_bodies">
- <argument index="0" name="enable" type="bool">
+ <argument index="3" name="max_bounces" type="int" default="4">
</argument>
- <description>
- Set if this body should collide with character bodies.
- </description>
- </method>
- <method name="set_collide_with_kinematic_bodies">
- <argument index="0" name="enable" type="bool">
+ <argument index="4" name="floor_max_angle" type="float" default="0.785398">
</argument>
<description>
- Set if this body should collide with kinematic bodies.
</description>
</method>
- <method name="set_collide_with_rigid_bodies">
- <argument index="0" name="enable" type="bool">
+ <method name="set_safe_margin">
+ <argument index="0" name="pixels" type="float">
</argument>
<description>
- Set if this body should collide with rigid bodies.
</description>
</method>
- <method name="set_collide_with_static_bodies">
- <argument index="0" name="enable" type="bool">
+ <method name="test_move">
+ <return type="bool">
+ </return>
+ <argument index="0" name="from" type="Transform">
</argument>
- <description>
- Set if this body should collide with static bodies.
- </description>
- </method>
- <method name="set_collision_margin">
- <argument index="0" name="pixels" type="float">
+ <argument index="1" name="rel_vec" type="Vector3">
</argument>
<description>
- Set the collision margin for this object. A collision margin is an amount that all shapes will grow when computing collisions, to account for numerical imprecision.
</description>
</method>
</methods>
<members>
- <member name="collide_with/character" type="bool" setter="set_collide_with_character_bodies" getter="can_collide_with_character_bodies" brief="">
- </member>
- <member name="collide_with/kinematic" type="bool" setter="set_collide_with_kinematic_bodies" getter="can_collide_with_kinematic_bodies" brief="">
- </member>
- <member name="collide_with/rigid" type="bool" setter="set_collide_with_rigid_bodies" getter="can_collide_with_rigid_bodies" brief="">
- </member>
- <member name="collide_with/static" type="bool" setter="set_collide_with_static_bodies" getter="can_collide_with_static_bodies" brief="">
- </member>
- <member name="collision/margin" type="float" setter="set_collision_margin" getter="get_collision_margin" brief="">
+ <member name="collision/safe_margin" type="float" setter="set_safe_margin" getter="get_safe_margin" brief="">
</member>
</members>
<constants>
@@ -21598,100 +22571,145 @@
Kinematic Characters: KinematicBody2D also has an api for moving objects (the [method move] method) while performing collision tests. This makes them really useful to implement characters that collide against a world, but that don't require advanced physics.
</description>
<methods>
- <method name="get_collider" qualifiers="const">
- <return type="Variant">
+ <method name="get_collision_collider" qualifiers="const">
+ <return type="Object">
</return>
+ <argument index="0" name="collision" type="int">
+ </argument>
<description>
- Return the body that collided with this one.
</description>
</method>
- <method name="get_collider_metadata" qualifiers="const">
- <return type="Variant">
+ <method name="get_collision_collider_id" qualifiers="const">
+ <return type="int">
</return>
+ <argument index="0" name="collision" type="int">
+ </argument>
<description>
- Return the metadata of the shape that collided with this body. If there is no collision, it will return 0, so collisions must be checked first with [method is_colliding]. Additionally, this metadata can not be set with [method Object.set_meta], it must be set with [method Physics2DServer.body_set_shape_metadata].
</description>
</method>
- <method name="get_collider_shape" qualifiers="const">
+ <method name="get_collision_collider_metadata" qualifiers="const">
+ <argument index="0" name="collision" type="int">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="get_collision_collider_shape" qualifiers="const">
+ <return type="Object">
+ </return>
+ <argument index="0" name="collision" type="int">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="get_collision_collider_shape_index" qualifiers="const">
<return type="int">
</return>
+ <argument index="0" name="collision" type="int">
+ </argument>
<description>
- Return the shape index from the body that collided with this one. If there is no collision, this method will return 0, so collisions must be checked first with [method is_colliding].
</description>
</method>
- <method name="get_collider_velocity" qualifiers="const">
+ <method name="get_collision_collider_velocity" qualifiers="const">
<return type="Vector2">
</return>
+ <argument index="0" name="collision" type="int">
+ </argument>
<description>
Return the velocity of the body that collided with this one.
</description>
</method>
- <method name="get_collision_margin" qualifiers="const">
- <return type="float">
+ <method name="get_collision_count" qualifiers="const">
+ <return type="int">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="get_collision_local_shape" qualifiers="const">
+ <return type="Object">
</return>
+ <argument index="0" name="collision" type="int">
+ </argument>
<description>
- Return the collision margin for this object.
</description>
</method>
<method name="get_collision_normal" qualifiers="const">
<return type="Vector2">
</return>
+ <argument index="0" name="collision" type="int">
+ </argument>
<description>
- Return the normal of the surface the body collided with. This is useful to implement sliding along a surface.
</description>
</method>
- <method name="get_collision_pos" qualifiers="const">
+ <method name="get_collision_position" qualifiers="const">
<return type="Vector2">
</return>
+ <argument index="0" name="collision" type="int">
+ </argument>
<description>
- Return the point in space where the body is touching another. If there is no collision, this method will return (0,0), so collisions must be checked first with [method is_colliding].
</description>
</method>
- <method name="get_move_and_slide_colliders" qualifiers="const">
- <return type="Array">
+ <method name="get_collision_remainder" qualifiers="const">
+ <return type="Vector2">
</return>
+ <argument index="0" name="collision" type="int">
+ </argument>
<description>
</description>
</method>
- <method name="get_travel" qualifiers="const">
+ <method name="get_collision_travel" qualifiers="const">
<return type="Vector2">
</return>
+ <argument index="0" name="collision" type="int">
+ </argument>
<description>
- Return the last movement done by the body.
</description>
</method>
- <method name="is_colliding" qualifiers="const">
- <return type="bool">
+ <method name="get_floor_velocity" qualifiers="const">
+ <return type="Vector2">
</return>
<description>
- Return whether the body is colliding with another.
</description>
</method>
- <method name="is_move_and_slide_on_ceiling" qualifiers="const">
+ <method name="get_safe_margin" qualifiers="const">
+ <return type="float">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="is_on_ceiling" qualifiers="const">
<return type="bool">
</return>
<description>
</description>
</method>
- <method name="is_move_and_slide_on_floor" qualifiers="const">
+ <method name="is_on_floor" qualifiers="const">
<return type="bool">
</return>
<description>
</description>
</method>
- <method name="is_move_and_slide_on_wall" qualifiers="const">
+ <method name="is_on_wall" qualifiers="const">
<return type="bool">
</return>
<description>
</description>
</method>
<method name="move">
- <return type="Vector2">
+ <return type="Dictionary">
</return>
<argument index="0" name="rel_vec" type="Vector2">
</argument>
<description>
- Move the body in the given direction, stopping if there is an obstacle. The returned vector is how much movement was remaining before being stopped.
+ Move the body in the given direction, stopping if there is an obstacle. If as a result of a movement there will be any collision then informations about this collision will be in returned dictionary. Dictionary will contains those keys:
+ - "position" - collision position
+ - "normal" - collision normal
+ - "local_shape" - id of this kinematic body shape that took part in a collision
+ - "travel" - traveled movement before being stopped
+ - "remainder" - remaining movement before being stopped
+ - "collider_id" - id of the collider, it can be used when dealing with [Physics2DServer]
+ - "collider" - colliding body
+ - "collider_shape_index" - index of the colliding shape, inside collider body "collider_metadata"
+ If the body did not intersect anything, then an empty dictionary (dir.empty()==true) is returned instead. Please note that this method is less user friendly than [method move_and_slide]. If you don't want to program each edge case manually, then it's recommended to use [method move_and_slide] instead.
</description>
</method>
<method name="move_and_slide">
@@ -21710,26 +22728,10 @@
<description>
</description>
</method>
- <method name="move_to">
- <return type="Vector2">
- </return>
- <argument index="0" name="position" type="Vector2">
- </argument>
- <description>
- Move the body to the given position. This is not a teleport, and the body will stop if there is an obstacle. The returned vector is how much movement was remaining before being stopped.
- [code]floor_max_angle[/code] is in radians (default is pi/4), and filters which obstacles should be considered as floors/cellings instead of walls.
- </description>
- </method>
- <method name="revert_motion">
- <description>
- Undo the last movement done by the body.
- </description>
- </method>
- <method name="set_collision_margin">
+ <method name="set_safe_margin">
<argument index="0" name="pixels" type="float">
</argument>
<description>
- Set the collision margin for this object. A collision margin is an amount (in pixels) that all shapes will grow when computing collisions, to account for numerical imprecision.
</description>
</method>
<method name="test_move">
@@ -21745,7 +22747,7 @@
</method>
</methods>
<members>
- <member name="collision/margin" type="float" setter="set_collision_margin" getter="get_collision_margin" brief="">
+ <member name="collision/safe_margin" type="float" setter="set_safe_margin" getter="get_safe_margin" brief="">
</member>
</members>
<constants>
@@ -23449,7 +24451,23 @@
Material is a base [Resource] used for coloring and shading geometry. All materials inherit from it and almost all [VisualInstance] derived nodes carry a Material. A few flags and parameters are shared between all material types and are configured here.
</description>
<methods>
+ <method name="get_next_pass" qualifiers="const">
+ <return type="Material">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="set_next_pass">
+ <argument index="0" name="next_pass" type="Material">
+ </argument>
+ <description>
+ </description>
+ </method>
</methods>
+ <members>
+ <member name="next_pass" type="Material" setter="set_next_pass" getter="get_next_pass" brief="">
+ </member>
+ </members>
<constants>
</constants>
</class>
@@ -23548,6 +24566,27 @@
</method>
</methods>
<constants>
+ <constant name="PRIMITIVE_POINTS" value="0">
+ Render array as points (one vertex equals one point).
+ </constant>
+ <constant name="PRIMITIVE_LINES" value="1">
+ Render array as lines (every two vertices a line is created).
+ </constant>
+ <constant name="PRIMITIVE_LINE_STRIP" value="2">
+ Render array as line strip.
+ </constant>
+ <constant name="PRIMITIVE_LINE_LOOP" value="3">
+ Render array as line loop (like line strip, but closed).
+ </constant>
+ <constant name="PRIMITIVE_TRIANGLES" value="4">
+ Render array as triangles (every three vertices a triangle is created).
+ </constant>
+ <constant name="PRIMITIVE_TRIANGLE_STRIP" value="5">
+ Render array as triangle strips.
+ </constant>
+ <constant name="PRIMITIVE_TRIANGLE_FAN" value="6">
+ Render array as triangle fans.
+ </constant>
</constants>
</class>
<class name="MeshDataTool" inherits="Reference" category="Core">
@@ -23593,6 +24632,8 @@
</description>
</method>
<method name="get_edge_meta" qualifiers="const">
+ <return type="Variant">
+ </return>
<argument index="0" name="idx" type="int">
</argument>
<description>
@@ -23625,6 +24666,8 @@
</description>
</method>
<method name="get_face_meta" qualifiers="const">
+ <return type="Variant">
+ </return>
<argument index="0" name="idx" type="int">
</argument>
<description>
@@ -23707,6 +24750,8 @@
</description>
</method>
<method name="get_vertex_meta" qualifiers="const">
+ <return type="Variant">
+ </return>
<argument index="0" name="idx" type="int">
</argument>
<description>
@@ -23862,6 +24907,10 @@
<description>
</description>
</method>
+ <method name="create_debug_tangents">
+ <description>
+ </description>
+ </method>
<method name="create_trimesh_collision">
<description>
This helper creates a [StaticBody] child [Node] using the mesh geometry as collision. It's mainly used for testing.
@@ -23880,6 +24929,14 @@
<description>
</description>
</method>
+ <method name="get_surface_material" qualifiers="const">
+ <return type="Material">
+ </return>
+ <argument index="0" name="surface" type="int">
+ </argument>
+ <description>
+ </description>
+ </method>
<method name="set_mesh">
<argument index="0" name="mesh" type="Mesh">
</argument>
@@ -23893,6 +24950,14 @@
<description>
</description>
</method>
+ <method name="set_surface_material">
+ <argument index="0" name="surface" type="int">
+ </argument>
+ <argument index="1" name="material" type="Material">
+ </argument>
+ <description>
+ </description>
+ </method>
</methods>
<members>
<member name="mesh" type="Mesh" setter="set_mesh" getter="get_mesh" brief="">
@@ -24957,6 +26022,12 @@
<description>
</description>
</method>
+ <method name="get_h_axis_stretch_mode" qualifiers="const">
+ <return type="int">
+ </return>
+ <description>
+ </description>
+ </method>
<method name="get_patch_margin" qualifiers="const">
<return type="int">
</return>
@@ -24977,12 +26048,24 @@
<description>
</description>
</method>
+ <method name="get_v_axis_stretch_mode" qualifiers="const">
+ <return type="int">
+ </return>
+ <description>
+ </description>
+ </method>
<method name="set_draw_center">
<argument index="0" name="draw_center" type="bool">
</argument>
<description>
</description>
</method>
+ <method name="set_h_axis_stretch_mode">
+ <argument index="0" name="mode" type="int">
+ </argument>
+ <description>
+ </description>
+ </method>
<method name="set_patch_margin">
<argument index="0" name="margin" type="int">
</argument>
@@ -25003,8 +26086,18 @@
<description>
</description>
</method>
+ <method name="set_v_axis_stretch_mode">
+ <argument index="0" name="mode" type="int">
+ </argument>
+ <description>
+ </description>
+ </method>
</methods>
<members>
+ <member name="axis_stretch_horizontal" type="int" setter="set_h_axis_stretch_mode" getter="get_h_axis_stretch_mode" brief="">
+ </member>
+ <member name="axis_stretch_vertical" type="int" setter="set_v_axis_stretch_mode" getter="get_v_axis_stretch_mode" brief="">
+ </member>
<member name="draw_center" type="bool" setter="set_draw_center" getter="get_draw_center" brief="">
</member>
<member name="patch_margin_bottom" type="int" setter="set_patch_margin" getter="get_patch_margin" brief="">
@@ -25027,6 +26120,12 @@
</signal>
</signals>
<constants>
+ <constant name="AXIS_STRETCH_MODE_STRETCH" value="0">
+ </constant>
+ <constant name="AXIS_STRETCH_MODE_TILE" value="1">
+ </constant>
+ <constant name="AXIS_STRETCH_MODE_TILE_FIT" value="2">
+ </constant>
</constants>
</class>
<class name="Node" inherits="Object" category="Core">
@@ -25207,7 +26306,7 @@
Return the name of the node. This name is unique among the siblings (other child nodes from the same parent).
</description>
</method>
- <method name="get_network_mode" qualifiers="const">
+ <method name="get_network_master" qualifiers="const">
<return type="int">
</return>
<description>
@@ -25611,11 +26710,12 @@
Set the name of the [Node]. Name must be unique within parent, and setting an already existing name will cause for the node to be automatically renamed.
</description>
</method>
- <method name="set_network_mode">
- <argument index="0" name="mode" type="int">
+ <method name="set_network_master">
+ <argument index="0" name="id" type="int">
+ </argument>
+ <argument index="1" name="recursive" type="bool" default="true">
</argument>
<description>
- Change the networking mode of the [Node], where [i]mode[/i] is one of the constants NETWORK_MODE_*. Master nodes will only call gdscript methods defined as [i]master func[/i] if a RPC call is received (slave nodes will only call [i]slave func[/i]; both will call [i]remote func[/i] if the call is not local, and [i]sync func[/i] in any case). Inherit mode looks at the parent node to determine the value (root node depends on the [SceneTree] having a networking peer set with [method SceneTree.set_network_peer])
</description>
</method>
<method name="set_owner">
@@ -25732,12 +26832,6 @@
</constant>
<constant name="NOTIFICATION_INTERNAL_FIXED_PROCESS" value="26">
</constant>
- <constant name="NETWORK_MODE_INHERIT" value="0">
- </constant>
- <constant name="NETWORK_MODE_MASTER" value="1">
- </constant>
- <constant name="NETWORK_MODE_SLAVE" value="2">
- </constant>
<constant name="RPC_MODE_DISABLED" value="0">
</constant>
<constant name="RPC_MODE_REMOTE" value="1">
@@ -26700,6 +27794,12 @@
<description>
</description>
</method>
+ <method name="set_ime_position">
+ <argument index="0" name="arg0" type="Vector2">
+ </argument>
+ <description>
+ </description>
+ </method>
<method name="set_keep_screen_on">
<argument index="0" name="enabled" type="bool">
</argument>
@@ -27036,6 +28136,17 @@
Return the class of the object as a string.
</description>
</method>
+ <method name="get_incoming_connections" qualifiers="const">
+ <return type="Array">
+ </return>
+ <description>
+ Returns an [Array] of dictionaries with informations about signals that are connected to this object.
+ Inside each [Dictionary] there are 3 fields:
+ - "source" is a reference to signal emitter.
+ - "signal_name" is name of connected signal.
+ - "method_name" is a name of method to which signal is connected.
+ </description>
+ </method>
<method name="get_instance_ID" qualifiers="const">
<return type="int">
</return>
@@ -27044,6 +28155,8 @@
</description>
</method>
<method name="get_meta" qualifiers="const">
+ <return type="Variant">
+ </return>
<argument index="0" name="name" type="String">
</argument>
<description>
@@ -27408,6 +28521,8 @@
</description>
</method>
<method name="get_item_metadata" qualifiers="const">
+ <return type="Variant">
+ </return>
<argument index="0" name="idx" type="int">
</argument>
<description>
@@ -27436,6 +28551,8 @@
</description>
</method>
<method name="get_selected_metadata" qualifiers="const">
+ <return type="Variant">
+ </return>
<description>
</description>
</method>
@@ -27782,7 +28899,7 @@
UDP packet peer.
</brief_description>
<description>
- UDP packet peer. Can be used to send raw UDP packets as well as [Variant]s.
+ UDP packet peer. Can be used to send raw UDP packets as well as [Variant]\ s.
</description>
<methods>
<method name="close">
@@ -28079,102 +29196,6 @@
<constants>
</constants>
</class>
-<class name="ParticleAttractor2D" inherits="Node2D" category="Core">
- <brief_description>
- </brief_description>
- <description>
- </description>
- <methods>
- <method name="get_absorption" qualifiers="const">
- <return type="float">
- </return>
- <description>
- </description>
- </method>
- <method name="get_disable_radius" qualifiers="const">
- <return type="float">
- </return>
- <description>
- </description>
- </method>
- <method name="get_gravity" qualifiers="const">
- <return type="float">
- </return>
- <description>
- </description>
- </method>
- <method name="get_particles_path" qualifiers="const">
- <return type="NodePath">
- </return>
- <description>
- </description>
- </method>
- <method name="get_radius" qualifiers="const">
- <return type="float">
- </return>
- <description>
- </description>
- </method>
- <method name="is_enabled" qualifiers="const">
- <return type="bool">
- </return>
- <description>
- </description>
- </method>
- <method name="set_absorption">
- <argument index="0" name="absorption" type="float">
- </argument>
- <description>
- </description>
- </method>
- <method name="set_disable_radius">
- <argument index="0" name="radius" type="float">
- </argument>
- <description>
- </description>
- </method>
- <method name="set_enabled">
- <argument index="0" name="enabled" type="bool">
- </argument>
- <description>
- </description>
- </method>
- <method name="set_gravity">
- <argument index="0" name="gravity" type="float">
- </argument>
- <description>
- </description>
- </method>
- <method name="set_particles_path">
- <argument index="0" name="path" type="NodePath">
- </argument>
- <description>
- </description>
- </method>
- <method name="set_radius">
- <argument index="0" name="radius" type="float">
- </argument>
- <description>
- </description>
- </method>
- </methods>
- <members>
- <member name="absorption" type="float" setter="set_absorption" getter="get_absorption" brief="">
- </member>
- <member name="disable_radius" type="float" setter="set_disable_radius" getter="get_disable_radius" brief="">
- </member>
- <member name="enabled" type="bool" setter="set_enabled" getter="is_enabled" brief="">
- </member>
- <member name="gravity" type="float" setter="set_gravity" getter="get_gravity" brief="">
- </member>
- <member name="particles_path" type="NodePath" setter="set_particles_path" getter="get_particles_path" brief="">
- </member>
- <member name="radius" type="float" setter="set_radius" getter="get_radius" brief="">
- </member>
- </members>
- <constants>
- </constants>
-</class>
<class name="Particles" inherits="GeometryInstance" category="Core">
<brief_description>
</brief_description>
@@ -28237,6 +29258,12 @@
<description>
</description>
</method>
+ <method name="get_one_shot" qualifiers="const">
+ <return type="bool">
+ </return>
+ <description>
+ </description>
+ </method>
<method name="get_pre_process_time" qualifiers="const">
<return type="float">
</return>
@@ -28279,6 +29306,10 @@
<description>
</description>
</method>
+ <method name="restart">
+ <description>
+ </description>
+ </method>
<method name="set_amount">
<argument index="0" name="amount" type="int">
</argument>
@@ -28335,6 +29366,12 @@
<description>
</description>
</method>
+ <method name="set_one_shot">
+ <argument index="0" name="enable" type="bool">
+ </argument>
+ <description>
+ </description>
+ </method>
<method name="set_pre_process_time">
<argument index="0" name="secs" type="float">
</argument>
@@ -28399,9 +29436,11 @@
</member>
<member name="local_coords" type="bool" setter="set_use_local_coordinates" getter="get_use_local_coordinates" brief="">
</member>
+ <member name="one_shot" type="bool" setter="set_one_shot" getter="get_one_shot" brief="">
+ </member>
<member name="preprocess" type="float" setter="set_pre_process_time" getter="get_pre_process_time" brief="">
</member>
- <member name="process_material" type="ParticlesMaterial,ShaderMaterial" setter="set_process_material" getter="get_process_material" brief="">
+ <member name="process_material" type="ShaderMaterial,ParticlesMaterial" setter="set_process_material" getter="get_process_material" brief="">
</member>
<member name="randomness" type="float" setter="set_randomness_ratio" getter="get_randomness_ratio" brief="">
</member>
@@ -28429,129 +29468,90 @@
Particles2D is a particle system 2D [Node] that is used to simulate several types of particle effects, such as explosions, rain, snow, fireflies, or other magical-like shinny sparkles. Particles are drawn using impostors, and given their dynamic behavior, the user must provide a visibility bounding box (although helpers to create one automatically exist).
</description>
<methods>
- <method name="get_amount" qualifiers="const">
- <return type="int">
+ <method name="capture_rect" qualifiers="const">
+ <return type="Rect2">
</return>
<description>
- Returns the amount of particles spawned at each emission
</description>
</method>
- <method name="get_color" qualifiers="const">
- <return type="Color">
+ <method name="get_amount" qualifiers="const">
+ <return type="int">
</return>
<description>
- Returns the tint color for each particle.
+ Returns the amount of particles spawned at each emission
</description>
</method>
- <method name="get_color_phase_color" qualifiers="const">
- <return type="Color">
+ <method name="get_draw_order" qualifiers="const">
+ <return type="int">
</return>
- <argument index="0" name="phase" type="int">
- </argument>
<description>
</description>
</method>
- <method name="get_color_phase_pos" qualifiers="const">
+ <method name="get_explosiveness_ratio" qualifiers="const">
<return type="float">
</return>
- <argument index="0" name="phase" type="int">
- </argument>
<description>
</description>
</method>
- <method name="get_color_phases" qualifiers="const">
+ <method name="get_fixed_fps" qualifiers="const">
<return type="int">
</return>
<description>
</description>
</method>
- <method name="get_emission_half_extents" qualifiers="const">
- <return type="Vector2">
- </return>
- <description>
- Returns the half extents of the emission box.
- </description>
- </method>
- <method name="get_emission_points" qualifiers="const">
- <return type="PoolVector2Array">
- </return>
- <description>
- </description>
- </method>
- <method name="get_emissor_offset" qualifiers="const">
- <return type="Vector2">
+ <method name="get_fractional_delta" qualifiers="const">
+ <return type="bool">
</return>
<description>
- Returns the particle spawn origin position relative to the emitter.
</description>
</method>
- <method name="get_emit_timeout" qualifiers="const">
- <return type="float">
+ <method name="get_h_frames" qualifiers="const">
+ <return type="int">
</return>
<description>
- Returns the amount of seconds during which the emitter will spawn particles
</description>
</method>
- <method name="get_explosiveness" qualifiers="const">
+ <method name="get_lifetime" qualifiers="const">
<return type="float">
</return>
<description>
+ Gets the amount of seconds that each particle will be visible.
</description>
</method>
- <method name="get_gradient" qualifiers="const">
- <return type="Gradient">
- </return>
- <description>
- Returns the [Gradient] used to tint each particle.
- </description>
- </method>
- <method name="get_h_frames" qualifiers="const">
- <return type="int">
+ <method name="get_normal_map" qualifiers="const">
+ <return type="Texture">
</return>
<description>
</description>
</method>
- <method name="get_initial_velocity" qualifiers="const">
- <return type="Vector2">
+ <method name="get_one_shot" qualifiers="const">
+ <return type="bool">
</return>
<description>
</description>
</method>
- <method name="get_lifetime" qualifiers="const">
+ <method name="get_pre_process_time" qualifiers="const">
<return type="float">
</return>
<description>
- Gets the amount of seconds that each particle will be visible.
</description>
</method>
- <method name="get_param" qualifiers="const">
- <return type="float">
+ <method name="get_process_material" qualifiers="const">
+ <return type="Material">
</return>
- <argument index="0" name="param" type="int">
- </argument>
<description>
- Returns the value of the specified emitter parameter
</description>
</method>
- <method name="get_pre_process_time" qualifiers="const">
+ <method name="get_randomness_ratio" qualifiers="const">
<return type="float">
</return>
<description>
</description>
</method>
- <method name="get_process_mode" qualifiers="const">
- <return type="int">
- </return>
- <description>
- </description>
- </method>
- <method name="get_randomness" qualifiers="const">
+ <method name="get_speed_scale" qualifiers="const">
<return type="float">
</return>
- <argument index="0" name="param" type="int">
- </argument>
<description>
- Returns the randomness value of the specified emitter parameter
</description>
</method>
<method name="get_texture" qualifiers="const">
@@ -28561,11 +29561,10 @@
Returns the texture for emitted particles
</description>
</method>
- <method name="get_time_scale" qualifiers="const">
- <return type="float">
+ <method name="get_use_local_coordinates" qualifiers="const">
+ <return type="bool">
</return>
<description>
- Returns the emitter time scale
</description>
</method>
<method name="get_v_frames" qualifiers="const">
@@ -28574,38 +29573,20 @@
<description>
</description>
</method>
- <method name="is_emitting" qualifiers="const">
- <return type="bool">
- </return>
- <description>
- Returns whether this emitter is currently emitting or not
- </description>
- </method>
- <method name="is_flipped_h" qualifiers="const">
- <return type="bool">
- </return>
- <description>
- </description>
- </method>
- <method name="is_flipped_v" qualifiers="const">
- <return type="bool">
+ <method name="get_visibility_rect" qualifiers="const">
+ <return type="Rect2">
</return>
<description>
</description>
</method>
- <method name="is_using_local_space" qualifiers="const">
+ <method name="is_emitting" qualifiers="const">
<return type="bool">
</return>
<description>
+ Returns whether this emitter is currently emitting or not
</description>
</method>
- <method name="pre_process">
- <argument index="0" name="time" type="float">
- </argument>
- <description>
- </description>
- </method>
- <method name="reset">
+ <method name="restart">
<description>
</description>
</method>
@@ -28616,348 +29597,153 @@
Sets the amount of particles spawned at each emission
</description>
</method>
- <method name="set_color">
- <argument index="0" name="color" type="Color">
- </argument>
- <description>
- Set the tint color for each particle.
- </description>
- </method>
- <method name="set_color_phase_color">
- <argument index="0" name="phase" type="int">
- </argument>
- <argument index="1" name="color" type="Color">
- </argument>
- <description>
- </description>
- </method>
- <method name="set_color_phase_pos">
- <argument index="0" name="phase" type="int">
- </argument>
- <argument index="1" name="pos" type="float">
- </argument>
- <description>
- </description>
- </method>
- <method name="set_color_phases">
- <argument index="0" name="phases" type="int">
- </argument>
- <description>
- </description>
- </method>
- <method name="set_emission_half_extents">
- <argument index="0" name="extents" type="Vector2">
- </argument>
- <description>
- Sets the half extents of the emission box, particles will be spawned at random inside this box.
- </description>
- </method>
- <method name="set_emission_points">
- <argument index="0" name="points" type="PoolVector2Array">
- </argument>
- <description>
- </description>
- </method>
- <method name="set_emissor_offset">
- <argument index="0" name="offset" type="Vector2">
- </argument>
- <description>
- Sets the particle spawn origin position relative to the emitter center. for example if this value is set to (50, 50), the particle will spawn 50 units to the right and 50 units to the bottom of the emitter center.
- </description>
- </method>
- <method name="set_emit_timeout">
- <argument index="0" name="value" type="float">
+ <method name="set_draw_order">
+ <argument index="0" name="order" type="int">
</argument>
<description>
- Sets the amount of seconds during which the emitter will spawn particles, after the specified seconds the emitter state will be set to non emitting, so calling [method is_emitting] will return false. If the timeout is 0 the emitter will spawn forever.
</description>
</method>
<method name="set_emitting">
- <argument index="0" name="active" type="bool">
+ <argument index="0" name="emitting" type="bool">
</argument>
<description>
If this is set to true then the particle emitter will emit particles, if its false it will not.
</description>
</method>
- <method name="set_explosiveness">
- <argument index="0" name="amount" type="float">
+ <method name="set_explosiveness_ratio">
+ <argument index="0" name="ratio" type="float">
</argument>
<description>
</description>
</method>
- <method name="set_flip_h">
- <argument index="0" name="enable" type="bool">
+ <method name="set_fixed_fps">
+ <argument index="0" name="fps" type="int">
</argument>
<description>
</description>
</method>
- <method name="set_flip_v">
+ <method name="set_fractional_delta">
<argument index="0" name="enable" type="bool">
</argument>
<description>
</description>
</method>
- <method name="set_gradient">
- <return type="Gradient">
- </return>
- <argument index="0" name="gradient" type="Object">
+ <method name="set_h_frames">
+ <argument index="0" name="frames" type="int">
</argument>
<description>
- Sets the [Gradient] used to tint each particle. Particle will be tinted according to their lifetimes.
</description>
</method>
- <method name="set_h_frames">
- <argument index="0" name="enable" type="int">
+ <method name="set_lifetime">
+ <argument index="0" name="secs" type="float">
</argument>
<description>
+ Sets the amount of seconds that each particle will be visible.
</description>
</method>
- <method name="set_initial_velocity">
- <argument index="0" name="velocity" type="Vector2">
+ <method name="set_normal_map">
+ <argument index="0" name="texture" type="Texture">
</argument>
<description>
</description>
</method>
- <method name="set_lifetime">
- <argument index="0" name="lifetime" type="float">
+ <method name="set_one_shot">
+ <argument index="0" name="secs" type="bool">
</argument>
<description>
- Sets the amount of seconds that each particle will be visible.
</description>
</method>
- <method name="set_param">
- <argument index="0" name="param" type="int">
- </argument>
- <argument index="1" name="value" type="float">
+ <method name="set_pre_process_time">
+ <argument index="0" name="secs" type="float">
</argument>
<description>
- Sets the value of the specified emitter parameter (see the constants secction for the list of parameters)
</description>
</method>
- <method name="set_pre_process_time">
- <argument index="0" name="time" type="float">
+ <method name="set_process_material">
+ <argument index="0" name="material" type="Material">
</argument>
<description>
</description>
</method>
- <method name="set_process_mode">
- <argument index="0" name="mode" type="int">
+ <method name="set_randomness_ratio">
+ <argument index="0" name="ratio" type="float">
</argument>
<description>
</description>
</method>
- <method name="set_randomness">
- <argument index="0" name="param" type="int">
- </argument>
- <argument index="1" name="value" type="float">
+ <method name="set_speed_scale">
+ <argument index="0" name="scale" type="float">
</argument>
<description>
- Sets the randomness value of the specified emitter parameter (see the constants secction for the list of parameters), 0 means no randomness, so every particle will have the parameters specified, 1 means that the parameter will be chosen at random, the closer the randomness value gets to 0 the more conservative the variation of the parameter will be.
</description>
</method>
<method name="set_texture">
- <return type="Texture">
- </return>
- <argument index="0" name="texture" type="Object">
+ <argument index="0" name="texture" type="Texture">
</argument>
<description>
- Sets the texture for each particle
</description>
</method>
- <method name="set_time_scale">
- <argument index="0" name="time_scale" type="float">
+ <method name="set_use_local_coordinates">
+ <argument index="0" name="enable" type="bool">
</argument>
<description>
- Sets the increment or decrement for the particle lifetime. for example: if the time scale is set to 2, the particles will die and move twice as fast.
</description>
</method>
- <method name="set_use_local_space">
- <argument index="0" name="enable" type="bool">
+ <method name="set_v_frames">
+ <argument index="0" name="frames" type="int">
</argument>
<description>
</description>
</method>
- <method name="set_v_frames">
- <argument index="0" name="enable" type="int">
+ <method name="set_visibility_rect">
+ <argument index="0" name="aabb" type="Rect2">
</argument>
<description>
</description>
</method>
</methods>
<members>
- <member name="color/color" type="Color" setter="set_color" getter="get_color" brief="">
- </member>
- <member name="color/color_ramp" type="Gradient" setter="set_color_ramp" getter="get_color_ramp" brief="">
- </member>
- <member name="color_phases/count" type="int" setter="set_color_phases" getter="get_color_phases" brief="">
- </member>
- <member name="config/amount" type="int" setter="set_amount" getter="get_amount" brief="">
- </member>
- <member name="config/emit_timeout" type="float" setter="set_emit_timeout" getter="get_emit_timeout" brief="">
- </member>
- <member name="config/emitting" type="bool" setter="set_emitting" getter="is_emitting" brief="">
- </member>
- <member name="config/explosiveness" type="float" setter="set_explosiveness" getter="get_explosiveness" brief="">
- </member>
- <member name="config/flip_h" type="bool" setter="set_flip_h" getter="is_flipped_h" brief="">
- </member>
- <member name="config/flip_v" type="bool" setter="set_flip_v" getter="is_flipped_v" brief="">
- </member>
- <member name="config/h_frames" type="int" setter="set_h_frames" getter="get_h_frames" brief="">
- </member>
- <member name="config/half_extents" type="Vector2" setter="set_emission_half_extents" getter="get_emission_half_extents" brief="">
- </member>
- <member name="config/lifetime" type="float" setter="set_lifetime" getter="get_lifetime" brief="">
- </member>
- <member name="config/local_space" type="bool" setter="set_use_local_space" getter="is_using_local_space" brief="">
- </member>
- <member name="config/offset" type="Vector2" setter="set_emissor_offset" getter="get_emissor_offset" brief="">
- </member>
- <member name="config/preprocess" type="float" setter="set_pre_process_time" getter="get_pre_process_time" brief="">
- </member>
- <member name="config/process_mode" type="int" setter="set_process_mode" getter="get_process_mode" brief="">
- </member>
- <member name="config/texture" type="Texture" setter="set_texture" getter="get_texture" brief="">
- </member>
- <member name="config/time_scale" type="float" setter="set_time_scale" getter="get_time_scale" brief="">
- </member>
- <member name="config/v_frames" type="int" setter="set_v_frames" getter="get_v_frames" brief="">
- </member>
- <member name="emission_points" type="PoolVector2Array" setter="set_emission_points" getter="get_emission_points" brief="">
- </member>
- <member name="params/anim_initial_pos" type="float" setter="set_param" getter="get_param" brief="">
- </member>
- <member name="params/anim_speed_scale" type="float" setter="set_param" getter="get_param" brief="">
- </member>
- <member name="params/damping" type="float" setter="set_param" getter="get_param" brief="">
- </member>
- <member name="params/direction" type="float" setter="set_param" getter="get_param" brief="">
- </member>
- <member name="params/final_size" type="float" setter="set_param" getter="get_param" brief="">
- </member>
- <member name="params/gravity_direction" type="float" setter="set_param" getter="get_param" brief="">
- </member>
- <member name="params/gravity_strength" type="float" setter="set_param" getter="get_param" brief="">
- </member>
- <member name="params/hue_variation" type="float" setter="set_param" getter="get_param" brief="">
- </member>
- <member name="params/initial_angle" type="float" setter="set_param" getter="get_param" brief="">
- </member>
- <member name="params/initial_size" type="float" setter="set_param" getter="get_param" brief="">
- </member>
- <member name="params/linear_velocity" type="float" setter="set_param" getter="get_param" brief="">
- </member>
- <member name="params/orbit_velocity" type="float" setter="set_param" getter="get_param" brief="">
- </member>
- <member name="params/radial_accel" type="float" setter="set_param" getter="get_param" brief="">
- </member>
- <member name="params/spin_velocity" type="float" setter="set_param" getter="get_param" brief="">
- </member>
- <member name="params/spread" type="float" setter="set_param" getter="get_param" brief="">
- </member>
- <member name="params/tangential_accel" type="float" setter="set_param" getter="get_param" brief="">
- </member>
- <member name="phase_0/color" type="Color" setter="set_color_phase_color" getter="get_color_phase_color" brief="">
- </member>
- <member name="phase_0/pos" type="float" setter="set_color_phase_pos" getter="get_color_phase_pos" brief="">
- </member>
- <member name="phase_1/color" type="Color" setter="set_color_phase_color" getter="get_color_phase_color" brief="">
- </member>
- <member name="phase_1/pos" type="float" setter="set_color_phase_pos" getter="get_color_phase_pos" brief="">
- </member>
- <member name="phase_2/color" type="Color" setter="set_color_phase_color" getter="get_color_phase_color" brief="">
- </member>
- <member name="phase_2/pos" type="float" setter="set_color_phase_pos" getter="get_color_phase_pos" brief="">
- </member>
- <member name="phase_3/color" type="Color" setter="set_color_phase_color" getter="get_color_phase_color" brief="">
+ <member name="amount" type="int" setter="set_amount" getter="get_amount" brief="">
</member>
- <member name="phase_3/pos" type="float" setter="set_color_phase_pos" getter="get_color_phase_pos" brief="">
+ <member name="draw_order" type="int" setter="set_draw_order" getter="get_draw_order" brief="">
</member>
- <member name="randomness/anim_initial_pos" type="float" setter="set_randomness" getter="get_randomness" brief="">
+ <member name="emitting" type="bool" setter="set_emitting" getter="is_emitting" brief="">
</member>
- <member name="randomness/anim_speed_scale" type="float" setter="set_randomness" getter="get_randomness" brief="">
+ <member name="explosiveness" type="float" setter="set_explosiveness_ratio" getter="get_explosiveness_ratio" brief="">
</member>
- <member name="randomness/damping" type="float" setter="set_randomness" getter="get_randomness" brief="">
+ <member name="fixed_fps" type="int" setter="set_fixed_fps" getter="get_fixed_fps" brief="">
</member>
- <member name="randomness/direction" type="float" setter="set_randomness" getter="get_randomness" brief="">
+ <member name="fract_delta" type="bool" setter="set_fractional_delta" getter="get_fractional_delta" brief="">
</member>
- <member name="randomness/final_size" type="float" setter="set_randomness" getter="get_randomness" brief="">
+ <member name="h_frames" type="int" setter="set_h_frames" getter="get_h_frames" brief="">
</member>
- <member name="randomness/gravity_direction" type="float" setter="set_randomness" getter="get_randomness" brief="">
+ <member name="lifetime" type="float" setter="set_lifetime" getter="get_lifetime" brief="">
</member>
- <member name="randomness/gravity_strength" type="float" setter="set_randomness" getter="get_randomness" brief="">
+ <member name="local_coords" type="bool" setter="set_use_local_coordinates" getter="get_use_local_coordinates" brief="">
</member>
- <member name="randomness/hue_variation" type="float" setter="set_randomness" getter="get_randomness" brief="">
+ <member name="normal_map" type="Texture" setter="set_normal_map" getter="get_normal_map" brief="">
</member>
- <member name="randomness/initial_angle" type="float" setter="set_randomness" getter="get_randomness" brief="">
+ <member name="one_shot" type="bool" setter="set_one_shot" getter="get_one_shot" brief="">
</member>
- <member name="randomness/initial_size" type="float" setter="set_randomness" getter="get_randomness" brief="">
+ <member name="preprocess" type="float" setter="set_pre_process_time" getter="get_pre_process_time" brief="">
</member>
- <member name="randomness/linear_velocity" type="float" setter="set_randomness" getter="get_randomness" brief="">
+ <member name="process_material" type="ShaderMaterial,ParticlesMaterial" setter="set_process_material" getter="get_process_material" brief="">
</member>
- <member name="randomness/orbit_velocity" type="float" setter="set_randomness" getter="get_randomness" brief="">
+ <member name="randomness" type="float" setter="set_randomness_ratio" getter="get_randomness_ratio" brief="">
</member>
- <member name="randomness/radial_accel" type="float" setter="set_randomness" getter="get_randomness" brief="">
+ <member name="speed_scale" type="float" setter="set_speed_scale" getter="get_speed_scale" brief="">
</member>
- <member name="randomness/spin_velocity" type="float" setter="set_randomness" getter="get_randomness" brief="">
+ <member name="texture" type="Texture" setter="set_texture" getter="get_texture" brief="">
</member>
- <member name="randomness/spread" type="float" setter="set_randomness" getter="get_randomness" brief="">
+ <member name="v_frames" type="int" setter="set_v_frames" getter="get_v_frames" brief="">
</member>
- <member name="randomness/tangential_accel" type="float" setter="set_randomness" getter="get_randomness" brief="">
+ <member name="visibility_rect" type="Rect3" setter="set_visibility_rect" getter="get_visibility_rect" brief="">
</member>
</members>
- <signals>
- <signal name="emission_finished">
- <description>
- </description>
- </signal>
- </signals>
<constants>
- <constant name="PARAM_DIRECTION" value="0">
- Direction in degrees at which the particles will be launched, Notice that when the direction is set to 0 the particles will be launched to the negative
- </constant>
- <constant name="PARAM_SPREAD" value="1">
- </constant>
- <constant name="PARAM_LINEAR_VELOCITY" value="2">
- Velocity at which the particles will be launched.
- </constant>
- <constant name="PARAM_SPIN_VELOCITY" value="3">
- The speed at which particles will spin around its own center.
- </constant>
- <constant name="PARAM_ORBIT_VELOCITY" value="4">
- Velocity at which the particles will orbit around the emitter center
- </constant>
- <constant name="PARAM_GRAVITY_DIRECTION" value="5">
- Direction in degrees at which the particles will be attracted
- </constant>
- <constant name="PARAM_GRAVITY_STRENGTH" value="6">
- Strength of the gravitation attraction for each particle
- </constant>
- <constant name="PARAM_RADIAL_ACCEL" value="7">
- </constant>
- <constant name="PARAM_TANGENTIAL_ACCEL" value="8">
- </constant>
- <constant name="PARAM_DAMPING" value="9">
- Amount of damping for each particle
- </constant>
- <constant name="PARAM_INITIAL_ANGLE" value="10">
- Initial angle in radians at which each particle will be spawned
- </constant>
- <constant name="PARAM_INITIAL_SIZE" value="11">
- Initial size of each particle
- </constant>
- <constant name="PARAM_FINAL_SIZE" value="12">
- Final size of each particle, the particle size will interpolate to this value during its lifetime.
- </constant>
- <constant name="PARAM_HUE_VARIATION" value="13">
- </constant>
- <constant name="PARAM_ANIM_SPEED_SCALE" value="14">
- </constant>
- <constant name="PARAM_ANIM_INITIAL_POS" value="15">
- </constant>
- <constant name="PARAM_MAX" value="16">
+ <constant name="DRAW_ORDER_INDEX" value="0">
</constant>
- <constant name="MAX_COLOR_PHASES" value="4">
+ <constant name="DRAW_ORDER_LIFETIME" value="1">
</constant>
</constants>
</class>
@@ -28985,6 +29771,12 @@
<description>
</description>
</method>
+ <method name="get_emission_color_texture" qualifiers="const">
+ <return type="Texture">
+ </return>
+ <description>
+ </description>
+ </method>
<method name="get_emission_normal_texture" qualifiers="const">
<return type="Texture">
</return>
@@ -29101,6 +29893,12 @@
<description>
</description>
</method>
+ <method name="set_emission_color_texture">
+ <argument index="0" name="texture" type="Texture">
+ </argument>
+ <description>
+ </description>
+ </method>
<method name="set_emission_normal_texture">
<argument index="0" name="texture" type="Texture">
</argument>
@@ -29213,6 +30011,8 @@
</member>
<member name="angular_velocity_random" type="float" setter="set_param_randomness" getter="get_param_randomness" brief="">
</member>
+ <member name="anim_loop" type="bool" setter="set_flag" getter="get_flag" brief="">
+ </member>
<member name="anim_offset" type="float" setter="set_param" getter="get_param" brief="">
</member>
<member name="anim_offset_curve" type="CurveTexture" setter="set_param_texture" getter="get_param_texture" brief="">
@@ -29237,6 +30037,8 @@
</member>
<member name="emission_box_extents" type="Vector3" setter="set_emission_box_extents" getter="get_emission_box_extents" brief="">
</member>
+ <member name="emission_color_texture" type="Texture" setter="set_emission_color_texture" getter="get_emission_color_texture" brief="">
+ </member>
<member name="emission_normal_texture" type="Texture" setter="set_emission_normal_texture" getter="get_emission_normal_texture" brief="">
</member>
<member name="emission_point_count" type="int" setter="set_emission_point_count" getter="get_emission_point_count" brief="">
@@ -29249,6 +30051,8 @@
</member>
<member name="flag_align_y" type="bool" setter="set_flag" getter="get_flag" brief="">
</member>
+ <member name="flag_disable_z" type="bool" setter="set_flag" getter="get_flag" brief="">
+ </member>
<member name="flag_rotate_y" type="bool" setter="set_flag" getter="get_flag" brief="">
</member>
<member name="flatness" type="float" setter="set_flatness" getter="get_flatness" brief="">
@@ -29335,7 +30139,7 @@
</constant>
<constant name="FLAG_ROTATE_Y" value="1">
</constant>
- <constant name="FLAG_MAX" value="2">
+ <constant name="FLAG_MAX" value="4">
</constant>
<constant name="EMISSION_SHAPE_POINT" value="0">
</constant>
@@ -30021,7 +30825,7 @@
collider_id: Id of the object the point is in.
collider: Object the point is inside of.
rid: [RID] of the object the point is in.
- Additionally, the method can take an array of objects or [RID]s that are to be excluded from collisions, a bitmask representing the physics layers to check in, and another bitmask for the types of objects to check (see TYPE_MASK_* constants).
+ Additionally, the method can take an array of objects or [RID]\ s that are to be excluded from collisions, a bitmask representing the physics layers to check in, and another bitmask for the types of objects to check (see TYPE_MASK_* constants).
</description>
</method>
<method name="intersect_ray">
@@ -30047,7 +30851,7 @@
collider: Object against which the ray was stopped.
rid: [RID] of the object against which the ray was stopped.
If the ray did not intersect anything, then an empty dictionary (dir.empty()==true) is returned instead.
- Additionally, the method can take an array of objects or [RID]s that are to be excluded from collisions, a bitmask representing the physics layers to check in, and another bitmask for the types of objects to check (see TYPE_MASK_* constants).
+ Additionally, the method can take an array of objects or [RID]\ s that are to be excluded from collisions, a bitmask representing the physics layers to check in, and another bitmask for the types of objects to check (see TYPE_MASK_* constants).
</description>
</method>
<method name="intersect_shape">
@@ -30272,6 +31076,16 @@
Substitute a given area shape by another. The old shape is selected by its index, the new one by its [RID].
</description>
</method>
+ <method name="area_set_shape_disabled">
+ <argument index="0" name="area" type="RID">
+ </argument>
+ <argument index="1" name="shape_idx" type="int">
+ </argument>
+ <argument index="2" name="disable" type="bool">
+ </argument>
+ <description>
+ </description>
+ </method>
<method name="area_set_shape_transform">
<argument index="0" name="area" type="RID">
</argument>
@@ -30433,24 +31247,6 @@
Get the instance ID of the object the area is assigned to.
</description>
</method>
- <method name="body_get_one_way_collision_direction" qualifiers="const">
- <return type="Vector2">
- </return>
- <argument index="0" name="body" type="RID">
- </argument>
- <description>
- Return the direction used for one-way collision detection.
- </description>
- </method>
- <method name="body_get_one_way_collision_max_depth" qualifiers="const">
- <return type="float">
- </return>
- <argument index="0" name="body" type="RID">
- </argument>
- <description>
- Return how far a body can go through the given one, when it allows one-way collisions.
- </description>
- </method>
<method name="body_get_param" qualifiers="const">
<return type="float">
</return>
@@ -30529,17 +31325,6 @@
Return whether a body uses a callback function to calculate its own physics (see [method body_set_force_integration_callback]).
</description>
</method>
- <method name="body_is_shape_set_as_trigger" qualifiers="const">
- <return type="bool">
- </return>
- <argument index="0" name="body" type="RID">
- </argument>
- <argument index="1" name="shape_idx" type="int">
- </argument>
- <description>
- Return whether a body's shape is marked as a trigger.
- </description>
- </method>
<method name="body_remove_collision_exception">
<argument index="0" name="body" type="RID">
</argument>
@@ -30635,24 +31420,6 @@
Set whether a body uses a callback function to calculate its own physics (see [method body_set_force_integration_callback]).
</description>
</method>
- <method name="body_set_one_way_collision_direction">
- <argument index="0" name="body" type="RID">
- </argument>
- <argument index="1" name="normal" type="Vector2">
- </argument>
- <description>
- Set a direction in which bodies can go through the given one. If this value is different from (0,0), any movement within 90 degrees of this vector is considered a valid movement. Set this direction to (0,0) to disable one-way collisions.
- </description>
- </method>
- <method name="body_set_one_way_collision_max_depth">
- <argument index="0" name="body" type="RID">
- </argument>
- <argument index="1" name="depth" type="float">
- </argument>
- <description>
- Set how far a body can go through the given one, if it allows one-way collisions (see [method body_set_one_way_collision_direction]).
- </description>
- </method>
<method name="body_set_param">
<argument index="0" name="body" type="RID">
</argument>
@@ -30675,7 +31442,7 @@
Substitute a given body shape by another. The old shape is selected by its index, the new one by its [RID].
</description>
</method>
- <method name="body_set_shape_as_trigger">
+ <method name="body_set_shape_as_one_way_collision">
<argument index="0" name="body" type="RID">
</argument>
<argument index="1" name="shape_idx" type="int">
@@ -30683,7 +31450,16 @@
<argument index="2" name="enable" type="bool">
</argument>
<description>
- Mark a body's shape as a trigger. A trigger shape cannot affect other bodies, but detects other shapes entering and exiting it.
+ </description>
+ </method>
+ <method name="body_set_shape_disabled">
+ <argument index="0" name="body" type="RID">
+ </argument>
+ <argument index="1" name="shape_idx" type="int">
+ </argument>
+ <argument index="2" name="disable" type="bool">
+ </argument>
+ <description>
</description>
</method>
<method name="body_set_shape_metadata">
@@ -30967,11 +31743,9 @@
<constant name="SPACE_PARAM_BODY_MAX_ALLOWED_PENETRATION" value="2">
Constant to set/get the maximum distance a shape can penetrate another shape before it is considered a collision.
</constant>
- <constant name="SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_TRESHOLD" value="3">
- Constant to set/get the linear velocity threshold. Bodies slower than this will be marked as potentially inactive.
+ <constant name="SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD" value="3">
</constant>
- <constant name="SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_TRESHOLD" value="4">
- Constant to set/get the angular velocity threshold. Bodies slower than this will be marked as potentially inactive.
+ <constant name="SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD" value="4">
</constant>
<constant name="SPACE_PARAM_BODY_TIME_TO_SLEEP" value="5">
Constant to set/get the maximum time of activity. A body marked as potentially inactive for both linear and angular velocity will be put to sleep after this time.
@@ -31168,7 +31942,7 @@
<return type="Array">
</return>
<description>
- Return the list of objects, or object [RID]s, that will be excluded from collisions.
+ Return the list of objects, or object [RID]\ s, that will be excluded from collisions.
</description>
</method>
<method name="get_margin" qualifiers="const">
@@ -31217,7 +31991,7 @@
<argument index="0" name="exclude" type="Array">
</argument>
<description>
- Set the list of objects, or object [RID]s, that will be excluded from collisions.
+ Set the list of objects, or object [RID]\ s, that will be excluded from collisions.
</description>
</method>
<method name="set_margin">
@@ -31511,20 +32285,6 @@
Return an individual bit on the collision mask.
</description>
</method>
- <method name="get_one_way_collision_direction" qualifiers="const">
- <return type="Vector2">
- </return>
- <description>
- Return the direction used for one-way collision detection.
- </description>
- </method>
- <method name="get_one_way_collision_max_depth" qualifiers="const">
- <return type="float">
- </return>
- <description>
- Return how far a body can go through this one, when it allows one-way collisions.
- </description>
- </method>
<method name="remove_collision_exception_with">
<argument index="0" name="body" type="PhysicsBody2D">
</argument>
@@ -31566,20 +32326,6 @@
Set/clear individual bits on the collision mask. This makes selecting the areas scanned easier.
</description>
</method>
- <method name="set_one_way_collision_direction">
- <argument index="0" name="dir" type="Vector2">
- </argument>
- <description>
- Set a direction in which bodies can go through this one. If this value is different from (0,0), any movement within 90 degrees of this vector is considered a valid movement. Set this direction to (0,0) to disable one-way collisions.
- </description>
- </method>
- <method name="set_one_way_collision_max_depth">
- <argument index="0" name="depth" type="float">
- </argument>
- <description>
- Set how far a body can go through this one, when it allows one-way collisions (see [method set_one_way_collision_direction]).
- </description>
- </method>
</methods>
<members>
<member name="collision_layer" type="int" setter="set_collision_layer" getter="get_collision_layer" brief="">
@@ -31588,10 +32334,6 @@
</member>
<member name="layers" type="int" setter="_set_layers" getter="_get_layers" brief="">
</member>
- <member name="one_way_collision/direction" type="Vector2" setter="set_one_way_collision_direction" getter="get_one_way_collision_direction" brief="">
- </member>
- <member name="one_way_collision/max_depth" type="float" setter="set_one_way_collision_max_depth" getter="get_one_way_collision_max_depth" brief="">
- </member>
</members>
<constants>
</constants>
@@ -33792,7 +34534,7 @@
<argument index="0" name="compression_mode" type="int" default="0">
</argument>
<description>
- Returns a new [PoolByteArray] with the data compressed. The compression mode can be set using one of the COMPRESS_* constants of [File].
+ Returns a new [PoolByteArray] with the data compressed. The compression mode can be set using one of the COMPRESS_* constants of [File].
</description>
</method>
<method name="decompress">
@@ -33803,7 +34545,7 @@
<argument index="1" name="compression_mode" type="int" default="0">
</argument>
<description>
- Returns a new [PoolByteArray] with the data decompressed. The buffer_size should be set as the size of the uncompressed data. The compression mode can be set using one of the COMPRESS_* constants of [File].
+ Returns a new [PoolByteArray] with the data decompressed. The buffer_size should be set as the size of the uncompressed data. The compression mode can be set using one of the COMPRESS_* constants of [File].
</description>
</method>
<method name="get_string_from_ascii">
@@ -34677,6 +35419,8 @@
</description>
</method>
<method name="get_item_metadata" qualifiers="const">
+ <return type="Variant">
+ </return>
<argument index="0" name="idx" type="int">
</argument>
<description>
@@ -34717,6 +35461,13 @@
<description>
</description>
</method>
+ <method name="is_hide_on_checkable_item_selection">
+ <return type="bool">
+ </return>
+ <description>
+ Returns a boolean that indicates whether or not the PopupMenu will hide on checkable item selection.
+ </description>
+ </method>
<method name="is_hide_on_item_selection">
<return type="bool">
</return>
@@ -34724,13 +35475,6 @@
Returns a boolean that indicates whether or not the PopupMenu will hide on item selection.
</description>
</method>
- <method name="is_hide_on_checkable_item_selection">
- <return type="bool">
- </return>
- <description>
- Returns a boolean that indicates whether or not the PopupMenu will hide on checkable item selection.
- </description>
- </method>
<method name="is_item_checkable" qualifiers="const">
<return type="bool">
</return>
@@ -34774,6 +35518,13 @@
Removes the item at index "idx" from the menu. Note that the indexes of items after the removed item are going to be shifted by one.
</description>
</method>
+ <method name="set_hide_on_checkable_item_selection">
+ <argument index="0" name="enable" type="bool">
+ </argument>
+ <description>
+ Sets whether or not the PopupMenu will hide on checkable item selection.
+ </description>
+ </method>
<method name="set_hide_on_item_selection">
<argument index="0" name="enable" type="bool">
</argument>
@@ -34781,13 +35532,6 @@
Sets whether or not the PopupMenu will hide on item selection.
</description>
</method>
- <method name="set_hide_on_checkable_item_selection">
- <argument index="0" name="enable" type="bool">
- </argument>
- <description>
- Sets whether or not the PopupMenu will hide on checkable item selection.
- </description>
- </method>
<method name="set_item_ID">
<argument index="0" name="idx" type="int">
</argument>
@@ -34904,6 +35648,8 @@
</method>
</methods>
<members>
+ <member name="hide_on_checkable_item_selection" type="bool" setter="set_hide_on_checkable_item_selection" getter="is_hide_on_checkable_item_selection" brief="">
+ </member>
<member name="hide_on_item_selection" type="bool" setter="set_hide_on_item_selection" getter="is_hide_on_item_selection" brief="">
</member>
<member name="items" type="Array" setter="_set_items" getter="_get_items" brief="">
@@ -36383,6 +37129,7 @@
Ending corner.
</member>
<member name="position" type="Vector2" setter="" getter="" brief="">
+ Position (starting corner).
</member>
<member name="size" type="Vector2" setter="" getter="" brief="">
Size from position to end.
@@ -36579,8 +37326,7 @@
<member name="end" type="Vector3" setter="" getter="" brief="">
Ending corner.
</member>
- <member name="pos" type="Vector3" setter="" getter="" brief="">
- Position (starting corner).
+ <member name="position" type="Vector3" setter="" getter="" brief="">
</member>
<member name="size" type="Vector3" setter="" getter="" brief="">
Size from position to end.
@@ -36923,7 +37669,7 @@
</description>
</method>
<method name="search" qualifiers="const">
- <return type="Object">
+ <return type="RegExMatch">
</return>
<argument index="0" name="text" type="String">
</argument>
@@ -37046,16 +37792,72 @@
<description>
</description>
</method>
+ <method name="get_update_position" qualifiers="const">
+ <return type="bool">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="get_update_rotation" qualifiers="const">
+ <return type="bool">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="get_update_scale" qualifiers="const">
+ <return type="bool">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="get_use_global_coordinates" qualifiers="const">
+ <return type="bool">
+ </return>
+ <description>
+ </description>
+ </method>
<method name="set_remote_node">
<argument index="0" name="path" type="NodePath">
</argument>
<description>
</description>
</method>
+ <method name="set_update_position">
+ <argument index="0" name="update_remote_position" type="bool">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="set_update_rotation">
+ <argument index="0" name="update_remote_rotation" type="bool">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="set_update_scale">
+ <argument index="0" name="update_remote_scale" type="bool">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="set_use_global_coordinates">
+ <argument index="0" name="use_global_coordinates" type="bool">
+ </argument>
+ <description>
+ </description>
+ </method>
</methods>
<members>
<member name="remote_path" type="NodePath" setter="set_remote_node" getter="get_remote_node" brief="">
</member>
+ <member name="update_position" type="bool" setter="set_update_position" getter="get_update_position" brief="">
+ </member>
+ <member name="update_rotation" type="bool" setter="set_update_rotation" getter="get_update_rotation" brief="">
+ </member>
+ <member name="update_scale" type="bool" setter="set_update_scale" getter="get_update_scale" brief="">
+ </member>
+ <member name="use_global_coordinates" type="bool" setter="set_use_global_coordinates" getter="get_use_global_coordinates" brief="">
+ </member>
</members>
<constants>
</constants>
@@ -37072,16 +37874,72 @@
<description>
</description>
</method>
+ <method name="get_update_position" qualifiers="const">
+ <return type="bool">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="get_update_rotation" qualifiers="const">
+ <return type="bool">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="get_update_scale" qualifiers="const">
+ <return type="bool">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="get_use_global_coordinates" qualifiers="const">
+ <return type="bool">
+ </return>
+ <description>
+ </description>
+ </method>
<method name="set_remote_node">
<argument index="0" name="path" type="NodePath">
</argument>
<description>
</description>
</method>
+ <method name="set_update_position">
+ <argument index="0" name="update_remote_position" type="bool">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="set_update_rotation">
+ <argument index="0" name="update_remote_rotation" type="bool">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="set_update_scale">
+ <argument index="0" name="update_remote_scale" type="bool">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="set_use_global_coordinates">
+ <argument index="0" name="use_global_coordinates" type="bool">
+ </argument>
+ <description>
+ </description>
+ </method>
</methods>
<members>
<member name="remote_path" type="NodePath" setter="set_remote_node" getter="get_remote_node" brief="">
</member>
+ <member name="update_position" type="bool" setter="set_update_position" getter="get_update_position" brief="">
+ </member>
+ <member name="update_rotation" type="bool" setter="set_update_rotation" getter="get_update_rotation" brief="">
+ </member>
+ <member name="update_scale" type="bool" setter="set_update_scale" getter="get_update_scale" brief="">
+ </member>
+ <member name="use_global_coordinates" type="bool" setter="set_use_global_coordinates" getter="get_use_global_coordinates" brief="">
+ </member>
</members>
<constants>
</constants>
@@ -37471,6 +38329,12 @@
<description>
</description>
</method>
+ <method name="get_percent_visible" qualifiers="const">
+ <return type="float">
+ </return>
+ <description>
+ </description>
+ </method>
<method name="get_tab_size" qualifiers="const">
<return type="int">
</return>
@@ -37491,7 +38355,7 @@
</description>
</method>
<method name="get_v_scroll">
- <return type="Object">
+ <return type="VScrollBar">
</return>
<description>
</description>
@@ -37566,7 +38430,7 @@
</description>
</method>
<method name="push_font">
- <argument index="0" name="font" type="Object">
+ <argument index="0" name="font" type="Font">
</argument>
<description>
</description>
@@ -37625,6 +38489,12 @@
<description>
</description>
</method>
+ <method name="set_percent_visible">
+ <argument index="0" name="percent_visible" type="float">
+ </argument>
+ <description>
+ </description>
+ </method>
<method name="set_scroll_active">
<argument index="0" name="active" type="bool">
</argument>
@@ -37660,6 +38530,12 @@
<description>
</description>
</method>
+ <method name="set_text">
+ <argument index="0" name="text" type="String">
+ </argument>
+ <description>
+ </description>
+ </method>
<method name="set_use_bbcode">
<argument index="0" name="enable" type="bool">
</argument>
@@ -37678,6 +38554,8 @@
</member>
<member name="bbcode_text" type="String" setter="set_bbcode" getter="get_bbcode" brief="">
</member>
+ <member name="percent_visible" type="float" setter="set_percent_visible" getter="get_percent_visible" brief="">
+ </member>
<member name="visible_characters" type="int" setter="set_visible_characters" getter="get_visible_characters" brief="">
</member>
</members>
@@ -38760,6 +39638,8 @@
</description>
</method>
<method name="get_node_property_value" qualifiers="const">
+ <return type="Variant">
+ </return>
<argument index="0" name="idx" type="int">
</argument>
<argument index="1" name="prop_idx" type="int">
@@ -38861,6 +39741,12 @@
<description>
</description>
</method>
+ <method name="get_network_connected_peers" qualifiers="const">
+ <return type="PoolIntArray">
+ </return>
+ <description>
+ </description>
+ </method>
<method name="get_network_unique_id" qualifiers="const">
<return type="int">
</return>
@@ -39345,6 +40231,44 @@
<constants>
</constants>
</class>
+<class name="ScriptEditor" inherits="PanelContainer" category="Core">
+ <brief_description>
+ </brief_description>
+ <description>
+ </description>
+ <methods>
+ <method name="get_current_script">
+ <return type="Script">
+ </return>
+ <description>
+ Returns a [Script] that is currently active in editor.
+ </description>
+ </method>
+ <method name="get_open_scripts">
+ <return type="Array">
+ </return>
+ <description>
+ Returns an array with all [Script] objects which are currently open in editor.
+ </description>
+ </method>
+ </methods>
+ <signals>
+ <signal name="editor_script_changed">
+ <argument index="0" name="script" type="Script">
+ </argument>
+ <description>
+ Emitted when user changed active script. Argument is a freshly activated [Script].
+ </description>
+ </signal>
+ <signal name="script_close">
+ <argument index="0" name="script" type="Script">
+ </argument>
+ <description>
+ Emitted when editor is about to close the active script. Argument is a [Script] that is going to be closed.
+ </description>
+ </signal>
+ </signals>
+</class>
<class name="SegmentShape2D" inherits="Shape2D" category="Core">
<brief_description>
Segment Shape for 2D Collision Detection.
@@ -39506,6 +40430,8 @@
</description>
</method>
<method name="get_shader_param" qualifiers="const">
+ <return type="Variant">
+ </return>
<argument index="0" name="param" type="String">
</argument>
<description>
@@ -39932,6 +40858,18 @@
Return true if ticks are visible on borders.
</description>
</method>
+ <method name="is_editable" qualifiers="const">
+ <return type="bool">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="set_editable">
+ <argument index="0" name="editable" type="bool">
+ </argument>
+ <description>
+ </description>
+ </method>
<method name="set_ticks">
<argument index="0" name="count" type="int">
</argument>
@@ -39948,6 +40886,8 @@
</method>
</methods>
<members>
+ <member name="editable" type="bool" setter="set_editable" getter="is_editable" brief="">
+ </member>
<member name="focus_mode" type="int" setter="set_focus_mode" getter="get_focus_mode" brief="">
</member>
<member name="tick_count" type="int" setter="set_ticks" getter="get_ticks" brief="">
@@ -40496,6 +41436,12 @@
<description>
</description>
</method>
+ <method name="get_grow" qualifiers="const">
+ <return type="float">
+ </return>
+ <description>
+ </description>
+ </method>
<method name="get_line_width" qualifiers="const">
<return type="float">
</return>
@@ -40568,6 +41514,12 @@
<description>
</description>
</method>
+ <method name="get_specular_mode" qualifiers="const">
+ <return type="int">
+ </return>
+ <description>
+ </description>
+ </method>
<method name="get_subsurface_scattering_strength" qualifiers="const">
<return type="float">
</return>
@@ -40583,25 +41535,37 @@
</description>
</method>
<method name="get_uv1_offset" qualifiers="const">
- <return type="Vector2">
+ <return type="Vector3">
</return>
<description>
</description>
</method>
<method name="get_uv1_scale" qualifiers="const">
- <return type="Vector2">
+ <return type="Vector3">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="get_uv1_triplanar_blend_sharpness" qualifiers="const">
+ <return type="float">
</return>
<description>
</description>
</method>
<method name="get_uv2_offset" qualifiers="const">
- <return type="Vector2">
+ <return type="Vector3">
</return>
<description>
</description>
</method>
<method name="get_uv2_scale" qualifiers="const">
- <return type="Vector2">
+ <return type="Vector3">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="get_uv2_triplanar_blend_sharpness" qualifiers="const">
+ <return type="float">
</return>
<description>
</description>
@@ -40612,6 +41576,12 @@
<description>
</description>
</method>
+ <method name="is_grow_enabled" qualifiers="const">
+ <return type="bool">
+ </return>
+ <description>
+ </description>
+ </method>
<method name="set_albedo">
<argument index="0" name="albedo" type="Color">
</argument>
@@ -40730,6 +41700,18 @@
<description>
</description>
</method>
+ <method name="set_grow">
+ <argument index="0" name="amount" type="float">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="set_grow_enabled">
+ <argument index="0" name="enable" type="bool">
+ </argument>
+ <description>
+ </description>
+ </method>
<method name="set_line_width">
<argument index="0" name="line_width" type="float">
</argument>
@@ -40802,6 +41784,12 @@
<description>
</description>
</method>
+ <method name="set_specular_mode">
+ <argument index="0" name="specular_mode" type="int">
+ </argument>
+ <description>
+ </description>
+ </method>
<method name="set_subsurface_scattering_strength">
<argument index="0" name="strength" type="float">
</argument>
@@ -40817,25 +41805,37 @@
</description>
</method>
<method name="set_uv1_offset">
- <argument index="0" name="offset" type="Vector2">
+ <argument index="0" name="offset" type="Vector3">
</argument>
<description>
</description>
</method>
<method name="set_uv1_scale">
- <argument index="0" name="scale" type="Vector2">
+ <argument index="0" name="scale" type="Vector3">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="set_uv1_triplanar_blend_sharpness">
+ <argument index="0" name="sharpness" type="float">
</argument>
<description>
</description>
</method>
<method name="set_uv2_offset">
- <argument index="0" name="offset" type="Vector2">
+ <argument index="0" name="offset" type="Vector3">
</argument>
<description>
</description>
</method>
<method name="set_uv2_scale">
- <argument index="0" name="scale" type="Vector2">
+ <argument index="0" name="scale" type="Vector3">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="set_uv2_triplanar_blend_sharpness">
+ <argument index="0" name="sharpness" type="float">
</argument>
<description>
</description>
@@ -40846,7 +41846,7 @@
</member>
<member name="albedo_texture" type="Texture" setter="set_texture" getter="get_texture" brief="">
</member>
- <member name="anisotropy_anisotropy" type="float" setter="set_anisotropy" getter="get_anisotropy" brief="">
+ <member name="anisotropy" type="float" setter="set_anisotropy" getter="get_anisotropy" brief="">
</member>
<member name="anisotropy_enabled" type="bool" setter="set_feature" getter="get_feature" brief="">
</member>
@@ -40854,9 +41854,11 @@
</member>
<member name="ao_enabled" type="bool" setter="set_feature" getter="get_feature" brief="">
</member>
+ <member name="ao_on_uv2" type="bool" setter="set_flag" getter="get_flag" brief="">
+ </member>
<member name="ao_texture" type="Texture" setter="set_texture" getter="get_texture" brief="">
</member>
- <member name="clearcoat_amount" type="float" setter="set_clearcoat" getter="get_clearcoat" brief="">
+ <member name="clearcoat" type="float" setter="set_clearcoat" getter="get_clearcoat" brief="">
</member>
<member name="clearcoat_enabled" type="bool" setter="set_feature" getter="get_feature" brief="">
</member>
@@ -40888,7 +41890,7 @@
</member>
<member name="detail_uv_layer" type="int" setter="set_detail_uv" getter="get_detail_uv" brief="">
</member>
- <member name="emission_color" type="Color" setter="set_emission" getter="get_emission" brief="">
+ <member name="emission" type="Color" setter="set_emission" getter="get_emission" brief="">
</member>
<member name="emission_enabled" type="bool" setter="set_feature" getter="get_feature" brief="">
</member>
@@ -40906,7 +41908,7 @@
</member>
<member name="flags_use_point_size" type="bool" setter="set_flag" getter="get_flag" brief="">
</member>
- <member name="metallic_amount" type="float" setter="set_metallic" getter="get_metallic" brief="">
+ <member name="metallic" type="float" setter="set_metallic" getter="get_metallic" brief="">
</member>
<member name="metallic_specular" type="float" setter="set_specular" getter="get_specular" brief="">
</member>
@@ -40928,10 +41930,16 @@
</member>
<member name="params_diffuse_mode" type="int" setter="set_diffuse_mode" getter="get_diffuse_mode" brief="">
</member>
+ <member name="params_grow" type="bool" setter="set_grow_enabled" getter="is_grow_enabled" brief="">
+ </member>
+ <member name="params_grow_amount" type="float" setter="set_grow" getter="get_grow" brief="">
+ </member>
<member name="params_line_width" type="float" setter="set_line_width" getter="get_line_width" brief="">
</member>
<member name="params_point_size" type="float" setter="set_point_size" getter="get_point_size" brief="">
</member>
+ <member name="params_specular_mode" type="int" setter="set_specular_mode" getter="get_specular_mode" brief="">
+ </member>
<member name="particles_anim_h_frames" type="int" setter="set_particles_anim_h_frames" getter="get_particles_anim_h_frames" brief="">
</member>
<member name="particles_anim_loop" type="bool" setter="set_particles_anim_loop" getter="get_particles_anim_loop" brief="">
@@ -40944,7 +41952,7 @@
</member>
<member name="refraction_texture" type="Texture" setter="set_texture" getter="get_texture" brief="">
</member>
- <member name="rim_amount" type="float" setter="set_rim" getter="get_rim" brief="">
+ <member name="rim" type="float" setter="set_rim" getter="get_rim" brief="">
</member>
<member name="rim_enabled" type="bool" setter="set_feature" getter="get_feature" brief="">
</member>
@@ -40952,7 +41960,7 @@
</member>
<member name="rim_tint" type="float" setter="set_rim_tint" getter="get_rim_tint" brief="">
</member>
- <member name="roughness_amount" type="float" setter="set_roughness" getter="get_roughness" brief="">
+ <member name="roughness" type="float" setter="set_roughness" getter="get_roughness" brief="">
</member>
<member name="roughness_texture" type="Texture" setter="set_texture" getter="get_texture" brief="">
</member>
@@ -40962,13 +41970,21 @@
</member>
<member name="subsurf_scatter_texture" type="Texture" setter="set_texture" getter="get_texture" brief="">
</member>
- <member name="uv1_offset" type="Vector2" setter="set_uv1_offset" getter="get_uv1_offset" brief="">
+ <member name="uv1_offset" type="Vector3" setter="set_uv1_offset" getter="get_uv1_offset" brief="">
</member>
- <member name="uv1_scale" type="Vector2" setter="set_uv1_scale" getter="get_uv1_scale" brief="">
+ <member name="uv1_scale" type="Vector3" setter="set_uv1_scale" getter="get_uv1_scale" brief="">
</member>
- <member name="uv2_offset" type="Vector2" setter="set_uv2_offset" getter="get_uv2_offset" brief="">
+ <member name="uv1_triplanar" type="bool" setter="set_flag" getter="get_flag" brief="">
</member>
- <member name="uv2_scale" type="Vector2" setter="set_uv2_scale" getter="get_uv2_scale" brief="">
+ <member name="uv1_triplanar_sharpness" type="float" setter="set_uv1_triplanar_blend_sharpness" getter="get_uv1_triplanar_blend_sharpness" brief="">
+ </member>
+ <member name="uv2_offset" type="Vector3" setter="set_uv2_offset" getter="get_uv2_offset" brief="">
+ </member>
+ <member name="uv2_scale" type="Vector3" setter="set_uv2_scale" getter="get_uv2_scale" brief="">
+ </member>
+ <member name="uv2_triplanar" type="bool" setter="set_flag" getter="get_flag" brief="">
+ </member>
+ <member name="uv2_triplanar_sharpness" type="float" setter="set_uv2_triplanar_blend_sharpness" getter="get_uv2_triplanar_blend_sharpness" brief="">
</member>
<member name="vertex_color_is_srgb" type="bool" setter="set_flag" getter="get_flag" brief="">
</member>
@@ -41070,7 +42086,7 @@
</constant>
<constant name="FLAG_FIXED_SIZE" value="5">
</constant>
- <constant name="FLAG_MAX" value="6">
+ <constant name="FLAG_MAX" value="9">
</constant>
<constant name="DIFFUSE_LAMBERT" value="0">
</constant>
@@ -41080,6 +42096,18 @@
</constant>
<constant name="DIFFUSE_BURLEY" value="3">
</constant>
+ <constant name="DIFFUSE_TOON" value="4">
+ </constant>
+ <constant name="SPECULAR_SCHLICK_GGX" value="0">
+ </constant>
+ <constant name="SPECULAR_BLINN" value="1">
+ </constant>
+ <constant name="SPECULAR_PHONG" value="2">
+ </constant>
+ <constant name="SPECULAR_TOON" value="3">
+ </constant>
+ <constant name="SPECULAR_DISABLED" value="4">
+ </constant>
<constant name="BILLBOARD_DISABLED" value="0">
</constant>
<constant name="BILLBOARD_ENABLED" value="1">
@@ -41090,6 +42118,46 @@
</constant>
</constants>
</class>
+<class name="SpatialVelocityTracker" inherits="Reference" category="Core">
+ <brief_description>
+ </brief_description>
+ <description>
+ </description>
+ <methods>
+ <method name="get_tracked_linear_velocity" qualifiers="const">
+ <return type="Vector3">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="is_tracking_fixed_step" qualifiers="const">
+ <return type="bool">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="reset">
+ <argument index="0" name="position" type="Vector3">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="set_track_fixed_step">
+ <argument index="0" name="enable" type="bool">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="update_position">
+ <argument index="0" name="position" type="Vector3">
+ </argument>
+ <description>
+ </description>
+ </method>
+ </methods>
+ <constants>
+ </constants>
+</class>
<class name="SphereMesh" inherits="PrimitiveMesh" category="Core">
<brief_description>
</brief_description>
@@ -41393,6 +42461,12 @@
Return the amount of horizontal frames. See [method set_hframes].
</description>
</method>
+ <method name="get_normal_map" qualifiers="const">
+ <return type="Texture">
+ </return>
+ <description>
+ </description>
+ </method>
<method name="get_offset" qualifiers="const">
<return type="Vector2">
</return>
@@ -41449,6 +42523,12 @@
Return if the sprite reads from a region.
</description>
</method>
+ <method name="is_region_filter_clip_enabled" qualifiers="const">
+ <return type="bool">
+ </return>
+ <description>
+ </description>
+ </method>
<method name="set_centered">
<argument index="0" name="centered" type="bool">
</argument>
@@ -41484,6 +42564,12 @@
Set the amount of horizontal frames and converts the sprite into a sprite-sheet. This is useful for animation.
</description>
</method>
+ <method name="set_normal_map">
+ <argument index="0" name="normal_map" type="Texture">
+ </argument>
+ <description>
+ </description>
+ </method>
<method name="set_offset">
<argument index="0" name="offset" type="Vector2">
</argument>
@@ -41498,6 +42584,12 @@
Set the sprite as a sub-region of a bigger texture. Useful for texture-atlases.
</description>
</method>
+ <method name="set_region_filter_clip">
+ <argument index="0" name="enabled" type="bool">
+ </argument>
+ <description>
+ </description>
+ </method>
<method name="set_region_rect">
<argument index="0" name="rect" type="Rect2">
</argument>
@@ -41531,9 +42623,13 @@
</member>
<member name="hframes" type="int" setter="set_hframes" getter="get_hframes" brief="">
</member>
+ <member name="normal_map" type="Texture" setter="set_normal_map" getter="get_normal_map" brief="">
+ </member>
<member name="offset" type="Vector2" setter="set_offset" getter="get_offset" brief="">
</member>
- <member name="region" type="bool" setter="set_region" getter="is_region" brief="">
+ <member name="region_enabled" type="bool" setter="set_region" getter="is_region" brief="">
+ </member>
+ <member name="region_filter_clip" type="bool" setter="set_region_filter_clip" getter="is_region_filter_clip_enabled" brief="">
</member>
<member name="region_rect" type="Rect2" setter="set_region_rect" getter="get_region_rect" brief="">
</member>
@@ -41639,7 +42735,7 @@
</member>
<member name="hframes" type="int" setter="set_hframes" getter="get_hframes" brief="">
</member>
- <member name="region" type="bool" setter="set_region" getter="is_region" brief="">
+ <member name="region_enabled" type="bool" setter="set_region" getter="is_region" brief="">
</member>
<member name="region_rect" type="Rect2" setter="set_region_rect" getter="get_region_rect" brief="">
</member>
@@ -41801,6 +42897,8 @@
</member>
<member name="centered" type="bool" setter="set_centered" getter="is_centered" brief="">
</member>
+ <member name="double_sided" type="bool" setter="set_draw_flag" getter="get_draw_flag" brief="">
+ </member>
<member name="flip_h" type="bool" setter="set_flip_h" getter="is_flipped_h" brief="">
</member>
<member name="flip_v" type="bool" setter="set_flip_v" getter="is_flipped_v" brief="">
@@ -41823,7 +42921,9 @@
</constant>
<constant name="FLAG_SHADED" value="1">
</constant>
- <constant name="FLAG_MAX" value="2">
+ <constant name="FLAG_DOUBLE_SIDED" value="2">
+ </constant>
+ <constant name="FLAG_MAX" value="3">
</constant>
<constant name="ALPHA_CUT_DISABLED" value="0">
</constant>
@@ -43542,6 +44642,12 @@
<description>
</description>
</method>
+ <method name="get_normal_map" qualifiers="const">
+ <return type="Texture">
+ </return>
+ <description>
+ </description>
+ </method>
<method name="get_region_rect" qualifiers="const">
<return type="Rect2">
</return>
@@ -43582,6 +44688,12 @@
<description>
</description>
</method>
+ <method name="set_normal_map">
+ <argument index="0" name="normal_map" type="Texture">
+ </argument>
+ <description>
+ </description>
+ </method>
<method name="set_region_rect">
<argument index="0" name="region" type="Rect2">
</argument>
@@ -43616,6 +44728,8 @@
</member>
<member name="modulate_color" type="Color" setter="set_modulate" getter="get_modulate" brief="">
</member>
+ <member name="normal_map" type="Texture" setter="set_normal_map" getter="get_normal_map" brief="">
+ </member>
<member name="region_rect" type="Rect2" setter="set_region_rect" getter="get_region_rect" brief="">
</member>
<member name="texture" type="Texture" setter="set_texture" getter="get_texture" brief="">
@@ -44095,6 +45209,15 @@
<description>
</description>
</method>
+ <method name="get_tab_rect">
+ <return type="Rect2">
+ </return>
+ <argument index="0" name="tab_idx" type="int">
+ </argument>
+ <description>
+ Returns tab [Rect2] with local position and size.
+ </description>
+ </method>
<method name="get_tab_title" qualifiers="const">
<return type="String">
</return>
@@ -44103,6 +45226,15 @@
<description>
</description>
</method>
+ <method name="move_tab">
+ <argument index="0" name="from" type="int">
+ </argument>
+ <argument index="1" name="to" type="int">
+ </argument>
+ <description>
+ Rearrange tab.
+ </description>
+ </method>
<method name="remove_tab">
<argument index="0" name="tab_idx" type="int">
</argument>
@@ -44151,6 +45283,12 @@
</member>
</members>
<signals>
+ <signal name="reposition_active_tab_request">
+ <argument index="0" name="idx_to" type="int">
+ </argument>
+ <description>
+ </description>
+ </signal>
<signal name="right_button_pressed">
<argument index="0" name="tab" type="int">
</argument>
@@ -44712,6 +45850,8 @@
</argument>
<argument index="3" name="transpose" type="bool" default="false">
</argument>
+ <argument index="4" name="normal_map" type="Texture" default="NULL">
+ </argument>
<description>
</description>
</method>
@@ -44726,6 +45866,8 @@
</argument>
<argument index="4" name="transpose" type="bool" default="false">
</argument>
+ <argument index="5" name="normal_map" type="Texture" default="NULL">
+ </argument>
<description>
</description>
</method>
@@ -44740,6 +45882,10 @@
</argument>
<argument index="4" name="transpose" type="bool" default="false">
</argument>
+ <argument index="5" name="normal_map" type="Texture" default="NULL">
+ </argument>
+ <argument index="6" name="clip_uv" type="bool" default="true">
+ </argument>
<description>
</description>
</method>
@@ -45428,7 +46574,7 @@
A unit of execution in a process.
</brief_description>
<description>
- A unit of execution in a process. Can run methods on [Object]s simultaneously. The use of synchronization via [Mutex], [Semaphore] is advised if working with shared objects.
+ A unit of execution in a process. Can run methods on [Object]\ s simultaneously. The use of synchronization via [Mutex], [Semaphore] is advised if working with shared objects.
</description>
<methods>
<method name="get_id" qualifiers="const">
@@ -45997,6 +47143,18 @@
Remove the tile referenced by the given ID.
</description>
</method>
+ <method name="tile_add_shape">
+ <argument index="0" name="id" type="int">
+ </argument>
+ <argument index="1" name="shape" type="Shape2D">
+ </argument>
+ <argument index="2" name="shape_transform" type="Transform2D">
+ </argument>
+ <argument index="3" name="one_way" type="bool" default="false">
+ </argument>
+ <description>
+ </description>
+ </method>
<method name="tile_get_light_occluder" qualifiers="const">
<return type="OccluderPolygon2D">
</return>
@@ -46042,6 +47200,14 @@
Return the offset of the tile's navigation polygon.
</description>
</method>
+ <method name="tile_get_normal_map" qualifiers="const">
+ <return type="Texture">
+ </return>
+ <argument index="0" name="id" type="int">
+ </argument>
+ <description>
+ </description>
+ </method>
<method name="tile_get_occluder_offset" qualifiers="const">
<return type="Vector2">
</return>
@@ -46065,17 +47231,37 @@
</return>
<argument index="0" name="id" type="int">
</argument>
+ <argument index="1" name="shape_id" type="int">
+ </argument>
<description>
- Return the shape of the tile.
</description>
</method>
- <method name="tile_get_shape_offset" qualifiers="const">
- <return type="Vector2">
+ <method name="tile_get_shape_count" qualifiers="const">
+ <return type="int">
</return>
<argument index="0" name="id" type="int">
</argument>
<description>
- Return the shape offset of the tile.
+ </description>
+ </method>
+ <method name="tile_get_shape_one_way" qualifiers="const">
+ <return type="bool">
+ </return>
+ <argument index="0" name="id" type="int">
+ </argument>
+ <argument index="1" name="shape_id" type="int">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="tile_get_shape_transform" qualifiers="const">
+ <return type="Transform2D">
+ </return>
+ <argument index="0" name="id" type="int">
+ </argument>
+ <argument index="1" name="shape_id" type="int">
+ </argument>
+ <description>
</description>
</method>
<method name="tile_get_shapes" qualifiers="const">
@@ -46150,6 +47336,14 @@
Set an offset for the tile's navigation polygon.
</description>
</method>
+ <method name="tile_set_normal_map">
+ <argument index="0" name="id" type="int">
+ </argument>
+ <argument index="1" name="normal_map" type="Texture">
+ </argument>
+ <description>
+ </description>
+ </method>
<method name="tile_set_occluder_offset">
<argument index="0" name="id" type="int">
</argument>
@@ -46171,19 +47365,31 @@
<method name="tile_set_shape">
<argument index="0" name="id" type="int">
</argument>
- <argument index="1" name="shape" type="Shape2D">
+ <argument index="1" name="shape_id" type="int">
+ </argument>
+ <argument index="2" name="shape" type="Shape2D">
</argument>
<description>
- Set a shape for the tile, enabling physics to collide with it.
</description>
</method>
- <method name="tile_set_shape_offset">
+ <method name="tile_set_shape_one_way">
<argument index="0" name="id" type="int">
</argument>
- <argument index="1" name="shape_offset" type="Vector2">
+ <argument index="1" name="shape_id" type="int">
+ </argument>
+ <argument index="2" name="one_way" type="bool">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="tile_set_shape_transform">
+ <argument index="0" name="id" type="int">
+ </argument>
+ <argument index="1" name="shape_id" type="int">
+ </argument>
+ <argument index="2" name="shape_transform" type="Transform2D">
</argument>
<description>
- Set the shape offset of the tile.
</description>
</method>
<method name="tile_set_shapes">
@@ -46829,7 +48035,7 @@
</method>
</methods>
<members>
- <member name="o" type="Vector2" setter="" getter="" brief="">
+ <member name="origin" type="Vector2" setter="" getter="" brief="">
</member>
<member name="x" type="Vector2" setter="" getter="" brief="">
</member>
@@ -47496,6 +48702,14 @@
<description>
</description>
</method>
+ <method name="get_expand_right" qualifiers="const">
+ <return type="bool">
+ </return>
+ <argument index="0" name="column" type="int">
+ </argument>
+ <description>
+ </description>
+ </method>
<method name="get_icon" qualifiers="const">
<return type="Texture">
</return>
@@ -47580,6 +48794,14 @@
<description>
</description>
</method>
+ <method name="get_text_align" qualifiers="const">
+ <return type="int">
+ </return>
+ <argument index="0" name="column" type="int">
+ </argument>
+ <description>
+ </description>
+ </method>
<method name="get_tooltip" qualifiers="const">
<return type="String">
</return>
@@ -47628,6 +48850,12 @@
<description>
</description>
</method>
+ <method name="is_folding_disabled" qualifiers="const">
+ <return type="bool">
+ </return>
+ <description>
+ </description>
+ </method>
<method name="is_selectable" qualifiers="const">
<return type="bool">
</return>
@@ -47734,6 +48962,12 @@
<description>
</description>
</method>
+ <method name="set_disable_folding">
+ <argument index="0" name="disable" type="bool">
+ </argument>
+ <description>
+ </description>
+ </method>
<method name="set_editable">
<argument index="0" name="column" type="int">
</argument>
@@ -47742,6 +48976,14 @@
<description>
</description>
</method>
+ <method name="set_expand_right">
+ <argument index="0" name="column" type="int">
+ </argument>
+ <argument index="1" name="enable" type="bool">
+ </argument>
+ <description>
+ </description>
+ </method>
<method name="set_icon">
<argument index="0" name="column" type="int">
</argument>
@@ -47812,6 +49054,14 @@
<description>
</description>
</method>
+ <method name="set_text_align">
+ <argument index="0" name="column" type="int">
+ </argument>
+ <argument index="1" name="text_align" type="int">
+ </argument>
+ <description>
+ </description>
+ </method>
<method name="set_tooltip">
<argument index="0" name="column" type="int">
</argument>
@@ -48315,7 +49565,7 @@
Helper to manage UndoRedo in the editor or custom tools.
</brief_description>
<description>
- Helper to maange UndoRedo in the editor or custom tools. It works by storing calls to functions in both 'do' an 'undo' lists.
+ Helper to manage UndoRedo in the editor or custom tools. It works by storing calls to functions in both 'do' an 'undo' lists.
Common behavior is to create an action, then add do/undo calls to functions or property changes, then committing the action.
</description>
<methods>
@@ -48368,13 +49618,12 @@
<argument index="0" name="object" type="Object">
</argument>
<description>
- Add an 'undo' reference that will be erased if the 'undo' history is lost. This is useful mostly for nodes rmoved with the 'do' call (not the 'undo' call!).
+ Add an 'undo' reference that will be erased if the 'undo' history is lost. This is useful mostly for nodes removed with the 'do' call (not the 'undo' call!).
</description>
</method>
<method name="clear_history">
<description>
- Clear the undo/redo history and associated
- references.
+ Clear the undo/redo history and associated references.
</description>
</method>
<method name="commit_action">
@@ -48388,8 +49637,7 @@
<argument index="1" name="merge_mode" type="int" default="0">
</argument>
<description>
- Create a new action. After this is called, do all your calls to [method add_do_method], [method add_undo_method], [method add_do_property] and [method add_un
-do_property].
+ Create a new action. After this is called, do all your calls to [method add_do_method], [method add_undo_method], [method add_do_property] and [method add_undo_property].
</description>
</method>
<method name="get_current_action_name" qualifiers="const">
@@ -48494,6 +49742,10 @@ do_property].
<theme_items>
<theme_item name="grabber" type="Texture">
</theme_item>
+ <theme_item name="grabber_disabled" type="Texture">
+ </theme_item>
+ <theme_item name="grabber_disabled" type="StyleBox">
+ </theme_item>
<theme_item name="grabber_highlight" type="Texture">
</theme_item>
<theme_item name="grabber_highlight" type="StyleBox">
@@ -48744,12 +49996,6 @@ do_property].
</method>
</methods>
<members>
- <member name="height" type="float" setter="" getter="" brief="">
- Height of the vector (Same as Y).
- </member>
- <member name="width" type="float" setter="" getter="" brief="">
- Width of the vector (Same as X).
- </member>
<member name="x" type="float" setter="" getter="" brief="">
X component of the vector.
</member>
@@ -49751,7 +50997,7 @@ do_property].
<argument index="0" name="xform" type="Transform2D">
</argument>
<description>
- Set the canvas transform of the viewport, useful for changing the on-screen positions of all child [CanvasItem]s. This is relative to the global canvas transform of the viewport.
+ Set the canvas transform of the viewport, useful for changing the on-screen positions of all child [CanvasItem]\ s. This is relative to the global canvas transform of the viewport.
</description>
</method>
<method name="set_clear_on_new_frame">
@@ -50943,6 +52189,8 @@ do_property].
</description>
</method>
<method name="get_constant_value" qualifiers="const">
+ <return type="Variant">
+ </return>
<description>
</description>
</method>
@@ -50960,9 +52208,9 @@ do_property].
</method>
</methods>
<members>
- <member name="constant/type" type="int" setter="set_constant_type" getter="get_constant_type" brief="">
+ <member name="type" type="int" setter="set_constant_type" getter="get_constant_type" brief="">
</member>
- <member name="constant/value" type="Nil" setter="set_constant_value" getter="get_constant_value" brief="">
+ <member name="value" type="Nil" setter="set_constant_value" getter="get_constant_value" brief="">
</member>
</members>
<constants>
@@ -51184,7 +52432,7 @@ do_property].
</method>
</methods>
<members>
- <member name="signal/signal" type="String" setter="set_signal" getter="get_signal" brief="">
+ <member name="signal" type="String" setter="set_signal" getter="get_signal" brief="">
</member>
</members>
<constants>
@@ -51364,27 +52612,27 @@ do_property].
</method>
</methods>
<members>
- <member name="function/argument_cache" type="Dictionary" setter="_set_argument_cache" getter="_get_argument_cache" brief="">
+ <member name="argument_cache" type="Dictionary" setter="_set_argument_cache" getter="_get_argument_cache" brief="">
</member>
- <member name="function/base_script" type="String" setter="set_base_script" getter="get_base_script" brief="">
+ <member name="base_script" type="String" setter="set_base_script" getter="get_base_script" brief="">
</member>
- <member name="function/base_type" type="String" setter="set_base_type" getter="get_base_type" brief="">
+ <member name="base_type" type="String" setter="set_base_type" getter="get_base_type" brief="">
</member>
- <member name="function/basic_type" type="int" setter="set_basic_type" getter="get_basic_type" brief="">
+ <member name="basic_type" type="int" setter="set_basic_type" getter="get_basic_type" brief="">
</member>
- <member name="function/call_mode" type="int" setter="set_call_mode" getter="get_call_mode" brief="">
+ <member name="call_mode" type="int" setter="set_call_mode" getter="get_call_mode" brief="">
</member>
- <member name="function/function" type="String" setter="set_function" getter="get_function" brief="">
+ <member name="function" type="String" setter="set_function" getter="get_function" brief="">
</member>
- <member name="function/node_path" type="NodePath" setter="set_base_path" getter="get_base_path" brief="">
+ <member name="node_path" type="NodePath" setter="set_base_path" getter="get_base_path" brief="">
</member>
- <member name="function/singleton" type="String" setter="set_singleton" getter="get_singleton" brief="">
+ <member name="rpc_call_mode" type="int" setter="set_rpc_call_mode" getter="get_rpc_call_mode" brief="">
</member>
- <member name="function/use_default_args" type="int" setter="set_use_default_args" getter="get_use_default_args" brief="">
+ <member name="singleton" type="String" setter="set_singleton" getter="get_singleton" brief="">
</member>
- <member name="function/validate" type="bool" setter="set_validate" getter="get_validate" brief="">
+ <member name="use_default_args" type="int" setter="set_use_default_args" getter="get_use_default_args" brief="">
</member>
- <member name="rpc/call_mode" type="int" setter="set_rpc_call_mode" getter="get_rpc_call_mode" brief="">
+ <member name="validate" type="bool" setter="set_validate" getter="get_validate" brief="">
</member>
</members>
<constants>
@@ -51560,9 +52808,9 @@ do_property].
</method>
</methods>
<members>
- <member name="variable/name" type="String" setter="set_var_name" getter="get_var_name" brief="">
+ <member name="type" type="int" setter="set_var_type" getter="get_var_type" brief="">
</member>
- <member name="variable/type" type="int" setter="set_var_type" getter="get_var_type" brief="">
+ <member name="var_name" type="String" setter="set_var_name" getter="get_var_name" brief="">
</member>
</members>
<constants>
@@ -51600,9 +52848,9 @@ do_property].
</method>
</methods>
<members>
- <member name="variable/name" type="String" setter="set_var_name" getter="get_var_name" brief="">
+ <member name="type" type="int" setter="set_var_type" getter="get_var_type" brief="">
</member>
- <member name="variable/type" type="int" setter="set_var_type" getter="get_var_type" brief="">
+ <member name="var_name" type="String" setter="set_var_name" getter="get_var_name" brief="">
</member>
</members>
<constants>
@@ -51708,9 +52956,9 @@ do_property].
</method>
</methods>
<members>
- <member name="operator_value/type" type="int" setter="set_operator" getter="get_operator" brief="">
+ <member name="operator" type="int" setter="set_operator" getter="get_operator" brief="">
</member>
- <member name="typed_value/typed" type="int" setter="set_typed" getter="get_typed" brief="">
+ <member name="type" type="int" setter="set_typed" getter="get_typed" brief="">
</member>
</members>
<constants>
@@ -51778,6 +53026,12 @@ do_property].
<description>
</description>
</method>
+ <method name="get_index" qualifiers="const">
+ <return type="String">
+ </return>
+ <description>
+ </description>
+ </method>
<method name="get_property" qualifiers="const">
<return type="String">
</return>
@@ -51814,6 +53068,12 @@ do_property].
<description>
</description>
</method>
+ <method name="set_index">
+ <argument index="0" name="index" type="String">
+ </argument>
+ <description>
+ </description>
+ </method>
<method name="set_property">
<argument index="0" name="property" type="String">
</argument>
@@ -51822,19 +53082,21 @@ do_property].
</method>
</methods>
<members>
- <member name="property/base_script" type="String" setter="set_base_script" getter="get_base_script" brief="">
+ <member name="base_script" type="String" setter="set_base_script" getter="get_base_script" brief="">
</member>
- <member name="property/base_type" type="String" setter="set_base_type" getter="get_base_type" brief="">
+ <member name="base_type" type="String" setter="set_base_type" getter="get_base_type" brief="">
</member>
- <member name="property/basic_type" type="int" setter="set_basic_type" getter="get_basic_type" brief="">
+ <member name="basic_type" type="int" setter="set_basic_type" getter="get_basic_type" brief="">
+ </member>
+ <member name="index" type="String" setter="set_index" getter="get_index" brief="">
</member>
- <member name="property/node_path" type="NodePath" setter="set_base_path" getter="get_base_path" brief="">
+ <member name="node_path" type="NodePath" setter="set_base_path" getter="get_base_path" brief="">
</member>
- <member name="property/property" type="String" setter="set_property" getter="get_property" brief="">
+ <member name="property" type="String" setter="set_property" getter="get_property" brief="">
</member>
- <member name="property/set_mode" type="int" setter="set_call_mode" getter="get_call_mode" brief="">
+ <member name="set_mode" type="int" setter="set_call_mode" getter="get_call_mode" brief="">
</member>
- <member name="property/type_cache" type="int" setter="_set_type_cache" getter="_get_type_cache" brief="">
+ <member name="type_cache" type="int" setter="_set_type_cache" getter="_get_type_cache" brief="">
</member>
</members>
<constants>
@@ -51852,6 +53114,12 @@ do_property].
<description>
</description>
<methods>
+ <method name="get_assign_op" qualifiers="const">
+ <return type="int">
+ </return>
+ <description>
+ </description>
+ </method>
<method name="get_base_path" qualifiers="const">
<return type="NodePath">
</return>
@@ -51882,12 +53150,24 @@ do_property].
<description>
</description>
</method>
+ <method name="get_index" qualifiers="const">
+ <return type="String">
+ </return>
+ <description>
+ </description>
+ </method>
<method name="get_property" qualifiers="const">
<return type="String">
</return>
<description>
</description>
</method>
+ <method name="set_assign_op">
+ <argument index="0" name="assign_op" type="int">
+ </argument>
+ <description>
+ </description>
+ </method>
<method name="set_base_path">
<argument index="0" name="base_path" type="NodePath">
</argument>
@@ -51918,6 +53198,12 @@ do_property].
<description>
</description>
</method>
+ <method name="set_index">
+ <argument index="0" name="index" type="String">
+ </argument>
+ <description>
+ </description>
+ </method>
<method name="set_property">
<argument index="0" name="property" type="String">
</argument>
@@ -51926,19 +53212,23 @@ do_property].
</method>
</methods>
<members>
- <member name="property/base_script" type="String" setter="set_base_script" getter="get_base_script" brief="">
+ <member name="assign_op" type="int" setter="set_assign_op" getter="get_assign_op" brief="">
+ </member>
+ <member name="base_script" type="String" setter="set_base_script" getter="get_base_script" brief="">
</member>
- <member name="property/base_type" type="String" setter="set_base_type" getter="get_base_type" brief="">
+ <member name="base_type" type="String" setter="set_base_type" getter="get_base_type" brief="">
+ </member>
+ <member name="basic_type" type="int" setter="set_basic_type" getter="get_basic_type" brief="">
</member>
- <member name="property/basic_type" type="int" setter="set_basic_type" getter="get_basic_type" brief="">
+ <member name="index" type="String" setter="set_index" getter="get_index" brief="">
</member>
- <member name="property/node_path" type="NodePath" setter="set_base_path" getter="get_base_path" brief="">
+ <member name="node_path" type="NodePath" setter="set_base_path" getter="get_base_path" brief="">
</member>
- <member name="property/property" type="String" setter="set_property" getter="get_property" brief="">
+ <member name="property" type="String" setter="set_property" getter="get_property" brief="">
</member>
- <member name="property/set_mode" type="int" setter="set_call_mode" getter="get_call_mode" brief="">
+ <member name="set_mode" type="int" setter="set_call_mode" getter="get_call_mode" brief="">
</member>
- <member name="property/type_cache" type="int" setter="_set_type_cache" getter="_get_type_cache" brief="">
+ <member name="type_cache" type="int" setter="_set_type_cache" getter="_get_type_cache" brief="">
</member>
</members>
<constants>
@@ -52008,9 +53298,9 @@ do_property].
</method>
</methods>
<members>
- <member name="return_value/enabled" type="bool" setter="set_enable_return_value" getter="is_return_value_enabled" brief="">
+ <member name="return_enabled" type="bool" setter="set_enable_return_value" getter="is_return_value_enabled" brief="">
</member>
- <member name="return_value/type" type="int" setter="set_return_type" getter="get_return_type" brief="">
+ <member name="return_type" type="int" setter="set_return_type" getter="get_return_type" brief="">
</member>
</members>
<constants>
@@ -52052,6 +53342,32 @@ do_property].
<constants>
</constants>
</class>
+<class name="VisualScriptSelect" inherits="VisualScriptNode" category="Core">
+ <brief_description>
+ </brief_description>
+ <description>
+ </description>
+ <methods>
+ <method name="get_typed" qualifiers="const">
+ <return type="int">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="set_typed">
+ <argument index="0" name="type" type="int">
+ </argument>
+ <description>
+ </description>
+ </method>
+ </methods>
+ <members>
+ <member name="type" type="int" setter="set_typed" getter="get_typed" brief="">
+ </member>
+ </members>
+ <constants>
+ </constants>
+</class>
<class name="VisualScriptSelf" inherits="VisualScriptNode" category="Core">
<brief_description>
</brief_description>
@@ -52146,9 +53462,9 @@ do_property].
</method>
</methods>
<members>
- <member name="function/base_type" type="String" setter="set_base_type" getter="get_base_type" brief="">
+ <member name="base_script" type="String" setter="set_base_script" getter="get_base_script" brief="">
</member>
- <member name="property/base_script" type="String" setter="set_base_script" getter="get_base_script" brief="">
+ <member name="base_type" type="String" setter="set_base_type" getter="get_base_type" brief="">
</member>
</members>
<constants>
@@ -52174,7 +53490,7 @@ do_property].
</method>
</methods>
<members>
- <member name="variable/name" type="String" setter="set_variable" getter="get_variable" brief="">
+ <member name="var_name" type="String" setter="set_variable" getter="get_variable" brief="">
</member>
</members>
<constants>
@@ -52200,7 +53516,7 @@ do_property].
</method>
</methods>
<members>
- <member name="variable/name" type="String" setter="set_variable" getter="get_variable" brief="">
+ <member name="var_name" type="String" setter="set_variable" getter="get_variable" brief="">
</member>
</members>
<constants>
@@ -52318,13 +53634,13 @@ do_property].
</method>
</methods>
<members>
- <member name="signal/base_type" type="String" setter="set_base_type" getter="get_base_type" brief="">
+ <member name="base_type" type="String" setter="set_base_type" getter="get_base_type" brief="">
</member>
- <member name="signal/call_mode" type="int" setter="set_call_mode" getter="get_call_mode" brief="">
+ <member name="call_mode" type="int" setter="set_call_mode" getter="get_call_mode" brief="">
</member>
- <member name="signal/node_path" type="NodePath" setter="set_base_path" getter="get_base_path" brief="">
+ <member name="node_path" type="NodePath" setter="set_base_path" getter="get_base_path" brief="">
</member>
- <member name="signal/signal" type="String" setter="set_signal" getter="get_signal" brief="">
+ <member name="signal" type="String" setter="set_signal" getter="get_signal" brief="">
</member>
</members>
<constants>
@@ -52575,13 +53891,6 @@ do_property].
Retrieve the state of this world's physics space. This allows arbitrary querying for collision.
</description>
</method>
- <method name="get_sound_space">
- <return type="RID">
- </return>
- <description>
- Retrieve the [RID] of this world's sound space resource. Used by the [SpatialSound2DServer] for 2D spatial audio.
- </description>
- </method>
<method name="get_space">
<return type="RID">
</return>
@@ -52593,7 +53902,7 @@ do_property].
<constants>
</constants>
</class>
-<class name="WorldEnvironment" inherits="Spatial" category="Core">
+<class name="WorldEnvironment" inherits="Node" category="Core">
<brief_description>
Sets environment properties for the entire scene
</brief_description>
diff --git a/doc/tools/makerst.py b/doc/tools/makerst.py
index 8a117f6450..696e3c9c78 100644
--- a/doc/tools/makerst.py
+++ b/doc/tools/makerst.py
@@ -172,6 +172,7 @@ def rstize_text(text, cclass):
pos += 1
# Handle [tags]
+ inside_code = False
pos = 0
while True:
pos = text.find('[', pos)
@@ -191,7 +192,18 @@ def rstize_text(text, cclass):
else: # command
cmd = tag_text
space_pos = tag_text.find(' ')
- if cmd.find('html') == 0:
+ if cmd == '/codeblock':
+ tag_text = ''
+ inside_code = False
+ # Strip newline if the tag was alone on one
+ if pre_text[-1] == '\n':
+ pre_text = pre_text[:-1]
+ elif cmd == '/code':
+ tag_text = '``'
+ inside_code = False
+ elif inside_code:
+ tag_text = '[' + tag_text + ']'
+ elif cmd.find('html') == 0:
cmd = tag_text[:space_pos]
param = tag_text[space_pos + 1:]
tag_text = param
@@ -216,11 +228,7 @@ def rstize_text(text, cclass):
tag_text = ''
elif cmd == 'codeblock':
tag_text = '\n::\n'
- elif cmd == '/codeblock':
- tag_text = ''
- # Strip newline if the tag was alone on one
- if pre_text[-1] == '\n':
- pre_text = pre_text[:-1]
+ inside_code = True
elif cmd == 'br':
# Make a new paragraph instead of a linebreak, rst is not so linebreak friendly
tag_text = '\n\n'
@@ -233,10 +241,11 @@ def rstize_text(text, cclass):
tag_text = '**'
elif cmd == 'u' or cmd == '/u':
tag_text = ''
- elif cmd == 'code' or cmd == '/code':
+ elif cmd == 'code':
tag_text = '``'
+ inside_code = True
else:
- tag_text = ':ref:`' + tag_text + '<class_' + tag_text.lower() + '>`'
+ tag_text = make_type(tag_text)
text = pre_text + tag_text + post_text
pos = len(pre_text) + len(tag_text)
diff --git a/drivers/alsa/audio_driver_alsa.cpp b/drivers/alsa/audio_driver_alsa.cpp
index b32d540380..4e6739e8c0 100644
--- a/drivers/alsa/audio_driver_alsa.cpp
+++ b/drivers/alsa/audio_driver_alsa.cpp
@@ -31,7 +31,7 @@
#ifdef ALSA_ENABLED
-#include "global_config.h"
+#include "project_settings.h"
#include <errno.h>
diff --git a/drivers/gles2/rasterizer_gles2.cpp b/drivers/gles2/rasterizer_gles2.cpp
index 3c543365f0..2abdbe9d0a 100644
--- a/drivers/gles2/rasterizer_gles2.cpp
+++ b/drivers/gles2/rasterizer_gles2.cpp
@@ -31,8 +31,8 @@
#include "rasterizer_gles2.h"
#include "gl_context/context_gl.h"
-#include "global_config.h"
#include "os/os.h"
+#include "project_settings.h"
#include "servers/visual/particle_system_sw.h"
#include "servers/visual/shader_language.h"
#include <stdio.h>
@@ -3941,8 +3941,8 @@ void RasterizerGLES2::begin_frame() {
//fragment_lighting=Globals::get_singleton()->get("rasterizer/use_fragment_lighting");
#ifdef TOOLS_ENABLED
- canvas_shader.set_conditional(CanvasShaderGLES2::USE_PIXEL_SNAP, GLOBAL_DEF("display/use_2d_pixel_snap", false));
- shadow_filter = ShadowFilterTechnique(int(GlobalConfig::get_singleton()->get("rasterizer/shadow_filter")));
+ canvas_shader.set_conditional(CanvasShaderGLES2::USE_PIXEL_SNAP, GLOBAL_DEF("rendering/use_2d_pixel_snap", false));
+ shadow_filter = ShadowFilterTechnique(int(ProjectSettings::get_singleton()->get("rasterizer/shadow_filter")));
#endif
canvas_shader.set_conditional(CanvasShaderGLES2::SHADOW_PCF5, shadow_filter == SHADOW_FILTER_PCF5);
@@ -4199,7 +4199,7 @@ void RasterizerGLES2::set_camera(const Transform &p_world, const CameraMatrix &p
void RasterizerGLES2::add_light(RID p_light_instance) {
-#define LIGHT_FADE_TRESHOLD 0.05
+#define LIGHT_FADE_THRESHOLD 0.05
ERR_FAIL_COND(light_instance_count >= MAX_SCENE_LIGHTS);
@@ -6481,7 +6481,7 @@ void RasterizerGLES2::_process_glow_bloom() {
copy_shader.bind();
copy_shader.set_uniform(CopyShaderGLES2::BLOOM, float(current_env->fx_param[VS::ENV_FX_PARAM_GLOW_BLOOM]));
- copy_shader.set_uniform(CopyShaderGLES2::BLOOM_TRESHOLD, float(current_env->fx_param[VS::ENV_FX_PARAM_GLOW_BLOOM_TRESHOLD]));
+ copy_shader.set_uniform(CopyShaderGLES2::BLOOM_THRESHOLD, float(current_env->fx_param[VS::ENV_FX_PARAM_GLOW_BLOOM_THRESHOLD]));
glUniform1i(copy_shader.get_uniform_location(CopyShaderGLES2::SOURCE), 0);
if (current_vd && current_env->fx_enabled[VS::ENV_FX_HDR]) {
@@ -6491,7 +6491,7 @@ void RasterizerGLES2::_process_glow_bloom() {
copy_shader.set_uniform(CopyShaderGLES2::TONEMAP_EXPOSURE, float(current_env->fx_param[VS::ENV_FX_PARAM_HDR_EXPOSURE]));
copy_shader.set_uniform(CopyShaderGLES2::TONEMAP_WHITE, float(current_env->fx_param[VS::ENV_FX_PARAM_HDR_WHITE]));
//copy_shader.set_uniform(CopyShaderGLES2::TONEMAP_WHITE,1.0);
- copy_shader.set_uniform(CopyShaderGLES2::HDR_GLOW_TRESHOLD, float(current_env->fx_param[VS::ENV_FX_PARAM_HDR_GLOW_TRESHOLD]));
+ copy_shader.set_uniform(CopyShaderGLES2::HDR_GLOW_THRESHOLD, float(current_env->fx_param[VS::ENV_FX_PARAM_HDR_GLOW_THRESHOLD]));
copy_shader.set_uniform(CopyShaderGLES2::HDR_GLOW_SCALE, float(current_env->fx_param[VS::ENV_FX_PARAM_HDR_GLOW_SCALE]));
glActiveTexture(GL_TEXTURE0);
@@ -6819,7 +6819,7 @@ void RasterizerGLES2::end_scene() {
if (current_env->bg_mode == VS::ENV_BG_COLOR)
bgcolor = current_env->bg_param[VS::ENV_BG_PARAM_COLOR];
else
- bgcolor = GlobalConfig::get_singleton()->get("render/default_clear_color");
+ bgcolor = ProjectSettings::get_singleton()->get("render/default_clear_color");
bgcolor = _convert_color(bgcolor);
float a = use_fb ? float(current_env->bg_param[VS::ENV_BG_PARAM_GLOW]) : 1.0;
glClearColor(bgcolor.r, bgcolor.g, bgcolor.b, a);
@@ -10386,7 +10386,7 @@ void RasterizerGLES2::init() {
copy_shader.set_conditional(CopyShaderGLES2::USE_8BIT_HDR, !use_fp16_fb);
canvas_shader.set_conditional(CanvasShaderGLES2::USE_DEPTH_SHADOWS, read_depth_supported);
- canvas_shader.set_conditional(CanvasShaderGLES2::USE_PIXEL_SNAP, GLOBAL_DEF("display/use_2d_pixel_snap", false));
+ canvas_shader.set_conditional(CanvasShaderGLES2::USE_PIXEL_SNAP, GLOBAL_DEF("rendering/use_2d_pixel_snap", false));
npo2_textures_available = true;
//fragment_lighting=false;
@@ -10718,7 +10718,7 @@ RasterizerGLES2::RasterizerGLES2(bool p_compress_arrays, bool p_keep_ram_copy, b
fragment_lighting = GLOBAL_DEF("rasterizer/use_fragment_lighting", true);
read_depth_supported = true; //todo check for extension
shadow_filter = ShadowFilterTechnique((int)(GLOBAL_DEF("rasterizer/shadow_filter", SHADOW_FILTER_PCF5)));
- GlobalConfig::get_singleton()->set_custom_property_info("rasterizer/shadow_filter", PropertyInfo(Variant::INT, "rasterizer/shadow_filter", PROPERTY_HINT_ENUM, "None,PCF5,PCF13,ESM"));
+ ProjectSettings::get_singleton()->set_custom_property_info("rasterizer/shadow_filter", PropertyInfo(Variant::INT, "rasterizer/shadow_filter", PROPERTY_HINT_ENUM, "None,PCF5,PCF13,ESM"));
use_fp16_fb = bool(GLOBAL_DEF("rasterizer/fp16_framebuffer", true));
use_shadow_mapping = true;
use_fast_texture_filter = !bool(GLOBAL_DEF("rasterizer/trilinear_mipmap_filter", true));
diff --git a/drivers/gles2/rasterizer_gles2.h b/drivers/gles2/rasterizer_gles2.h
index e6b76a4e92..e86d3ba298 100644
--- a/drivers/gles2/rasterizer_gles2.h
+++ b/drivers/gles2/rasterizer_gles2.h
@@ -689,14 +689,14 @@ class RasterizerGLES2 : public Rasterizer {
fx_param[VS::ENV_FX_PARAM_GLOW_BLUR_STRENGTH] = 1.0;
fx_param[VS::ENV_FX_PARAM_GLOW_BLUR_BLEND_MODE] = 0;
fx_param[VS::ENV_FX_PARAM_GLOW_BLOOM] = 0.0;
- fx_param[VS::ENV_FX_PARAM_GLOW_BLOOM_TRESHOLD] = 0.5;
+ fx_param[VS::ENV_FX_PARAM_GLOW_BLOOM_THRESHOLD] = 0.5;
fx_param[VS::ENV_FX_PARAM_DOF_BLUR_PASSES] = 1;
fx_param[VS::ENV_FX_PARAM_DOF_BLUR_BEGIN] = 100.0;
fx_param[VS::ENV_FX_PARAM_DOF_BLUR_RANGE] = 10.0;
fx_param[VS::ENV_FX_PARAM_HDR_TONEMAPPER] = VS::ENV_FX_HDR_TONE_MAPPER_LINEAR;
fx_param[VS::ENV_FX_PARAM_HDR_EXPOSURE] = 0.4;
fx_param[VS::ENV_FX_PARAM_HDR_WHITE] = 1.0;
- fx_param[VS::ENV_FX_PARAM_HDR_GLOW_TRESHOLD] = 0.95;
+ fx_param[VS::ENV_FX_PARAM_HDR_GLOW_THRESHOLD] = 0.95;
fx_param[VS::ENV_FX_PARAM_HDR_GLOW_SCALE] = 0.2;
fx_param[VS::ENV_FX_PARAM_HDR_MIN_LUMINANCE] = 0.4;
fx_param[VS::ENV_FX_PARAM_HDR_MAX_LUMINANCE] = 8.0;
diff --git a/drivers/gles2/shaders/copy.glsl b/drivers/gles2/shaders/copy.glsl
index cb42970921..23680ffe91 100644
--- a/drivers/gles2/shaders/copy.glsl
+++ b/drivers/gles2/shaders/copy.glsl
@@ -16,6 +16,7 @@ attribute vec2 uv_in; // attrib:4
#endif
attribute vec2 uv2_in; // attrib:5
+
#ifdef USE_CUBEMAP
varying vec3 cube_interp;
#else
@@ -58,7 +59,9 @@ float sRGB_gamma_correct(float c){
#define LUM_RANGE 4.0
-#ifdef USE_CUBEMAP
+#ifdef USE_ARRAY
+uniform sampler2DArray source;
+#elif defined(USE_CUBEMAP)
varying vec3 cube_interp;
uniform samplerCube source_cube;
#else
@@ -84,7 +87,7 @@ uniform sampler2D glow_source;
#if defined(USE_HDR) && defined(USE_GLOW_COPY)
-uniform highp float hdr_glow_treshold;
+uniform highp float hdr_glow_threshold;
uniform highp float hdr_glow_scale;
#endif
@@ -104,7 +107,7 @@ uniform vec3 bcs;
#ifdef USE_GLOW_COPY
uniform float bloom;
-uniform float bloom_treshold;
+uniform float bloom_threshold;
#endif
@@ -145,23 +148,17 @@ uniform float custom_alpha;
void main() {
//vec4 color = color_interp;
-#ifdef USE_HIGHP_SOURCE
-#ifdef USE_CUBEMAP
+
+#ifdef USE_ARRAY
+ highp vec4 color = textureLod( source, vec3(uv_interp,0.0),0.0 );
+#elif defined(USE_CUBEMAP)
highp vec4 color = textureCube( source_cube, normalize(cube_interp) );
#else
highp vec4 color = texture2D( source, uv_interp );
#endif
-#else
-
-#ifdef USE_CUBEMAP
- vec4 color = textureCube( source_cube, normalize(cube_interp) );
-
-#else
- vec4 color = texture2D( source, uv_interp );
-#endif
#endif
@@ -377,11 +374,11 @@ void main() {
#ifdef USE_GLOW_COPY
- highp vec3 glowcol = color.rgb*color.a+step(bloom_treshold,dot(vec3(0.3333,0.3333,0.3333),color.rgb))*bloom*color.rgb;
+ highp vec3 glowcol = color.rgb*color.a+step(bloom_threshold,dot(vec3(0.3333,0.3333,0.3333),color.rgb))*bloom*color.rgb;
#ifdef USE_HDR
highp float collum = max(color.r,max(color.g,color.b));
- glowcol+=color.rgb*max(collum-hdr_glow_treshold,0.0)*hdr_glow_scale;
+ glowcol+=color.rgb*max(collum-hdr_glow_threshold,0.0)*hdr_glow_scale;
#endif
color.rgb=glowcol;
color.a=0.0;
@@ -503,7 +500,7 @@ void main() {
//lum_accum=exp(lum_accum);
-#ifdef USE_8BIT_HDR
+#ifdef USE_8BIT_HDR
highp float vd_lum = dot(texture2D( source_vd_lum, vec2(0.0) ), _multcv );
lum_accum = clamp( vd_lum + (lum_accum-vd_lum)*hdr_time_delta*hdr_exp_adj_speed,min_luminance*(1.0/LUM_RANGE),max_luminance*(1.0/LUM_RANGE));
@@ -558,4 +555,3 @@ void main() {
#endif
}
-
diff --git a/drivers/gles3/rasterizer_canvas_gles3.cpp b/drivers/gles3/rasterizer_canvas_gles3.cpp
index 8c3569bec0..56d9f2cc47 100644
--- a/drivers/gles3/rasterizer_canvas_gles3.cpp
+++ b/drivers/gles3/rasterizer_canvas_gles3.cpp
@@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "rasterizer_canvas_gles3.h"
-#include "global_config.h"
#include "os/os.h"
+#include "project_settings.h"
#include "rasterizer_scene_gles3.h"
#include "servers/visual/visual_server_raster.h"
#ifndef GLES_OVER_GL
@@ -348,6 +348,53 @@ void RasterizerCanvasGLES3::_draw_polygon(const int *p_indices, int p_index_coun
glBindVertexArray(0);
}
+void RasterizerCanvasGLES3::_draw_generic(GLuint p_primitive, int p_vertex_count, const Vector2 *p_vertices, const Vector2 *p_uvs, const Color *p_colors, bool p_singlecolor) {
+
+ glBindVertexArray(data.polygon_buffer_pointer_array);
+ glBindBuffer(GL_ARRAY_BUFFER, data.polygon_buffer);
+
+ uint32_t buffer_ofs = 0;
+
+ //vertex
+ glBufferSubData(GL_ARRAY_BUFFER, buffer_ofs, sizeof(Vector2) * p_vertex_count, p_vertices);
+ glEnableVertexAttribArray(VS::ARRAY_VERTEX);
+ glVertexAttribPointer(VS::ARRAY_VERTEX, 2, GL_FLOAT, false, sizeof(Vector2), ((uint8_t *)0) + buffer_ofs);
+ buffer_ofs += sizeof(Vector2) * p_vertex_count;
+ //color
+
+ if (p_singlecolor) {
+ glDisableVertexAttribArray(VS::ARRAY_COLOR);
+ Color m = *p_colors;
+ glVertexAttrib4f(VS::ARRAY_COLOR, m.r, m.g, m.b, m.a);
+ } else if (!p_colors) {
+ glDisableVertexAttribArray(VS::ARRAY_COLOR);
+ glVertexAttrib4f(VS::ARRAY_COLOR, 1, 1, 1, 1);
+ } else {
+
+ glBufferSubData(GL_ARRAY_BUFFER, buffer_ofs, sizeof(Color) * p_vertex_count, p_colors);
+ glEnableVertexAttribArray(VS::ARRAY_COLOR);
+ glVertexAttribPointer(VS::ARRAY_COLOR, 4, GL_FLOAT, false, sizeof(Color), ((uint8_t *)0) + buffer_ofs);
+ buffer_ofs += sizeof(Color) * p_vertex_count;
+ }
+
+ if (p_uvs) {
+
+ glBufferSubData(GL_ARRAY_BUFFER, buffer_ofs, sizeof(Vector2) * p_vertex_count, p_uvs);
+ glEnableVertexAttribArray(VS::ARRAY_TEX_UV);
+ glVertexAttribPointer(VS::ARRAY_TEX_UV, 2, GL_FLOAT, false, sizeof(Vector2), ((uint8_t *)0) + buffer_ofs);
+ buffer_ofs += sizeof(Vector2) * p_vertex_count;
+
+ } else {
+ glDisableVertexAttribArray(VS::ARRAY_TEX_UV);
+ }
+
+ glDrawArrays(p_primitive, 0, p_vertex_count);
+
+ storage->frame.canvas_draw_commands++;
+
+ glBindVertexArray(0);
+}
+
void RasterizerCanvasGLES3::_draw_gui_primitive(int p_points, const Vector2 *p_vertices, const Color *p_colors, const Vector2 *p_uvs) {
static const GLenum prim[5] = { GL_POINTS, GL_POINTS, GL_LINES, GL_TRIANGLES, GL_TRIANGLE_FAN };
@@ -425,22 +472,83 @@ void RasterizerCanvasGLES3::_canvas_item_render_commands(Item *p_item, Item *cur
glVertexAttrib4f(VS::ARRAY_COLOR, line->color.r, line->color.g, line->color.b, line->color.a);
- Vector2 verts[2] = {
- Vector2(line->from.x, line->from.y),
- Vector2(line->to.x, line->to.y)
- };
+ if (line->width <= 1) {
+ Vector2 verts[2] = {
+ Vector2(line->from.x, line->from.y),
+ Vector2(line->to.x, line->to.y)
+ };
#ifdef GLES_OVER_GL
- if (line->antialiased)
- glEnable(GL_LINE_SMOOTH);
+ if (line->antialiased)
+ glEnable(GL_LINE_SMOOTH);
#endif
- //glLineWidth(line->width);
- _draw_gui_primitive(2, verts, NULL, NULL);
+ //glLineWidth(line->width);
+ _draw_gui_primitive(2, verts, NULL, NULL);
#ifdef GLES_OVER_GL
- if (line->antialiased)
+ if (line->antialiased)
+ glDisable(GL_LINE_SMOOTH);
+#endif
+ } else {
+ //thicker line
+
+ Vector2 t = (line->from - line->to).normalized().tangent() * line->width * 0.5;
+
+ Vector2 verts[4] = {
+ line->from - t,
+ line->from + t,
+ line->to + t,
+ line->to - t,
+ };
+
+ //glLineWidth(line->width);
+ _draw_gui_primitive(4, verts, NULL, NULL);
+#ifdef GLES_OVER_GL
+ if (line->antialiased) {
+ glEnable(GL_LINE_SMOOTH);
+ for (int i = 0; i < 4; i++) {
+ Vector2 vertsl[2] = {
+ verts[i],
+ verts[(i + 1) % 4],
+ };
+ _draw_gui_primitive(2, vertsl, NULL, NULL);
+ }
+ glDisable(GL_LINE_SMOOTH);
+ }
+#endif
+ }
+
+ } break;
+ case Item::Command::TYPE_POLYLINE: {
+
+ Item::CommandPolyLine *pline = static_cast<Item::CommandPolyLine *>(c);
+ _set_texture_rect_mode(false);
+
+ _bind_canvas_texture(RID(), RID());
+
+ if (pline->triangles.size()) {
+
+ _draw_generic(GL_TRIANGLE_STRIP, pline->triangles.size(), pline->triangles.ptr(), NULL, pline->triangle_colors.ptr(), pline->triangle_colors.size() == 1);
+#ifdef GLES_OVER_GL
+ glEnable(GL_LINE_SMOOTH);
+ if (pline->lines.size()) {
+ _draw_generic(GL_LINE_LOOP, pline->lines.size(), pline->lines.ptr(), NULL, pline->line_colors.ptr(), pline->line_colors.size() == 1);
+ }
glDisable(GL_LINE_SMOOTH);
#endif
+ } else {
+
+#ifdef GLES_OVER_GL
+ if (pline->antialiased)
+ glEnable(GL_LINE_SMOOTH);
+#endif
+ _draw_generic(GL_LINE_STRIP, pline->lines.size(), pline->lines.ptr(), NULL, pline->line_colors.ptr(), pline->line_colors.size() == 1);
+
+#ifdef GLES_OVER_GL
+ if (pline->antialiased)
+ glDisable(GL_LINE_SMOOTH);
+#endif
+ }
} break;
case Item::Command::TYPE_RECT: {
@@ -1550,7 +1658,7 @@ void RasterizerCanvasGLES3::initialize() {
}
{
- uint32_t poly_size = GLOBAL_DEF("rendering/buffers/canvas_polygon_buffer_size_kb", 128);
+ uint32_t poly_size = GLOBAL_DEF("rendering/limits/buffers/canvas_polygon_buffer_size_kb", 128);
poly_size *= 1024; //kb
poly_size = MAX(poly_size, (2 + 2 + 4) * 4 * sizeof(float));
glGenBuffers(1, &data.polygon_buffer);
@@ -1596,7 +1704,7 @@ void RasterizerCanvasGLES3::initialize() {
glGenVertexArrays(1, &data.polygon_buffer_pointer_array);
- uint32_t index_size = GLOBAL_DEF("rendering/buffers/canvas_polygon_index_buffer_size_kb", 128);
+ uint32_t index_size = GLOBAL_DEF("rendering/limits/buffers/canvas_polygon_index_buffer_size_kb", 128);
index_size *= 1024; //kb
glGenBuffers(1, &data.polygon_index_buffer);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, data.polygon_index_buffer);
diff --git a/drivers/gles3/rasterizer_canvas_gles3.h b/drivers/gles3/rasterizer_canvas_gles3.h
index ee018e15ea..c0af22b5e8 100644
--- a/drivers/gles3/rasterizer_canvas_gles3.h
+++ b/drivers/gles3/rasterizer_canvas_gles3.h
@@ -121,6 +121,8 @@ public:
_FORCE_INLINE_ void _draw_gui_primitive(int p_points, const Vector2 *p_vertices, const Color *p_colors, const Vector2 *p_uvs);
_FORCE_INLINE_ void _draw_polygon(const int *p_indices, int p_index_count, int p_vertex_count, const Vector2 *p_vertices, const Vector2 *p_uvs, const Color *p_colors, bool p_singlecolor);
+ _FORCE_INLINE_ void _draw_generic(GLuint p_primitive, int p_vertex_count, const Vector2 *p_vertices, const Vector2 *p_uvs, const Color *p_colors, bool p_singlecolor);
+
_FORCE_INLINE_ void _canvas_item_render_commands(Item *p_item, Item *current_clip, bool &reclip);
_FORCE_INLINE_ void _copy_texscreen(const Rect2 &p_rect);
diff --git a/drivers/gles3/rasterizer_gles3.cpp b/drivers/gles3/rasterizer_gles3.cpp
index 0cfa8a7d6e..bb7b85e653 100644
--- a/drivers/gles3/rasterizer_gles3.cpp
+++ b/drivers/gles3/rasterizer_gles3.cpp
@@ -30,8 +30,8 @@
#include "rasterizer_gles3.h"
#include "gl_context/context_gl.h"
-#include "global_config.h"
#include "os/os.h"
+#include "project_settings.h"
#include <string.h>
RasterizerStorage *RasterizerGLES3::get_storage() {
@@ -186,6 +186,9 @@ void RasterizerGLES3::initialize() {
GL_DEBUG_SEVERITY_HIGH_ARB,5, "hello");
*/
+
+ const GLubyte *renderer = glGetString(GL_RENDERER);
+ print_line("OpenGL ES 3.0 Renderer: " + String((const char *)renderer));
storage->initialize();
canvas->initialize();
scene->initialize();
@@ -336,6 +339,10 @@ void RasterizerGLES3::blit_render_target_to_screen(RID p_render_target, const Re
glBindFramebuffer(GL_FRAMEBUFFER, RasterizerStorageGLES3::system_fbo);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, rt->color);
+ //glBindTexture(GL_TEXTURE_2D, rt->effects.mip_maps[0].color);
+ glActiveTexture(GL_TEXTURE1);
+ glBindTexture(GL_TEXTURE_2D, storage->resources.normal_tex);
+
canvas->draw_generic_textured_rect(p_screen_rect, Rect2(0, 0, 1, -1));
glBindTexture(GL_TEXTURE_2D, 0);
canvas->canvas_end();
@@ -400,10 +407,8 @@ void RasterizerGLES3::make_current() {
void RasterizerGLES3::register_config() {
- GLOBAL_DEF("rendering/gles3/render_architecture", 0);
- GlobalConfig::get_singleton()->set_custom_property_info("rendering/gles3/render_architecture", PropertyInfo(Variant::INT, "", PROPERTY_HINT_ENUM, "Desktop,Mobile"));
- GLOBAL_DEF("rendering/quality/use_nearest_mipmap_filter", false);
- GLOBAL_DEF("rendering/quality/anisotropic_filter_level", 4.0);
+ GLOBAL_DEF("rendering/quality/filters/use_nearest_mipmap_filter", false);
+ GLOBAL_DEF("rendering/quality/filters/anisotropic_filter_level", 4.0);
}
RasterizerGLES3::RasterizerGLES3() {
diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp
index 96c3da99f0..cd74c450f5 100644
--- a/drivers/gles3/rasterizer_scene_gles3.cpp
+++ b/drivers/gles3/rasterizer_scene_gles3.cpp
@@ -29,8 +29,8 @@
/*************************************************************************/
#include "rasterizer_scene_gles3.h"
-#include "global_config.h"
#include "os/os.h"
+#include "project_settings.h"
#include "rasterizer_canvas_gles3.h"
#ifndef GLES_OVER_GL
@@ -521,13 +521,7 @@ void RasterizerSceneGLES3::reflection_atlas_set_size(RID p_ref_atlas, int p_size
glBindTexture(GL_TEXTURE_2D, reflection_atlas->color);
int mmsize = reflection_atlas->size;
-
- for (int i = 0; i < 6; i++) {
- glTexImage2D(GL_TEXTURE_2D, i, internal_format, mmsize, mmsize, 0,
- format, type, NULL);
-
- mmsize >>= 1;
- }
+ glTexStorage2DCustom(GL_TEXTURE_2D, 6, internal_format, mmsize, mmsize, format, type);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
@@ -537,8 +531,6 @@ void RasterizerSceneGLES3::reflection_atlas_set_size(RID p_ref_atlas, int p_size
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 5);
- mmsize = reflection_atlas->size;
-
for (int i = 0; i < 6; i++) {
glGenFramebuffers(1, &reflection_atlas->fbo[i]);
glBindFramebuffer(GL_FRAMEBUFFER, reflection_atlas->fbo[i]);
@@ -761,7 +753,7 @@ bool RasterizerSceneGLES3::reflection_probe_instance_postprocess_step(RID p_inst
storage->shaders.cubemap_filter.set_conditional(CubemapFilterShaderGLES3::LOW_QUALITY, rpi->probe_ptr->update_mode == VS::REFLECTION_PROBE_UPDATE_ALWAYS);
for (int i = 0; i < 2; i++) {
- storage->shaders.cubemap_filter.set_uniform(CubemapFilterShaderGLES3::Z_FLIP, i > 0);
+ storage->shaders.cubemap_filter.set_uniform(CubemapFilterShaderGLES3::Z_FLIP, i == 0);
storage->shaders.cubemap_filter.set_uniform(CubemapFilterShaderGLES3::ROUGHNESS, rpi->render_step / 5.0);
uint32_t local_width = width, local_height = height;
@@ -869,7 +861,7 @@ void RasterizerSceneGLES3::environment_set_dof_blur_near(RID p_env, bool p_enabl
env->dof_blur_near_amount = p_amount;
env->dof_blur_near_quality = p_quality;
}
-void RasterizerSceneGLES3::environment_set_glow(RID p_env, bool p_enable, int p_level_flags, float p_intensity, float p_strength, float p_bloom_treshold, VS::EnvironmentGlowBlendMode p_blend_mode, float p_hdr_bleed_treshold, float p_hdr_bleed_scale, bool p_bicubic_upscale) {
+void RasterizerSceneGLES3::environment_set_glow(RID p_env, bool p_enable, int p_level_flags, float p_intensity, float p_strength, float p_bloom_threshold, VS::EnvironmentGlowBlendMode p_blend_mode, float p_hdr_bleed_threshold, float p_hdr_bleed_scale, bool p_bicubic_upscale) {
Environment *env = environment_owner.getornull(p_env);
ERR_FAIL_COND(!env);
@@ -878,9 +870,9 @@ void RasterizerSceneGLES3::environment_set_glow(RID p_env, bool p_enable, int p_
env->glow_levels = p_level_flags;
env->glow_intensity = p_intensity;
env->glow_strength = p_strength;
- env->glow_bloom = p_bloom_treshold;
+ env->glow_bloom = p_bloom_threshold;
env->glow_blend_mode = p_blend_mode;
- env->glow_hdr_bleed_treshold = p_hdr_bleed_treshold;
+ env->glow_hdr_bleed_threshold = p_hdr_bleed_threshold;
env->glow_hdr_bleed_scale = p_hdr_bleed_scale;
env->glow_bicubic_upscale = p_bicubic_upscale;
}
@@ -1251,36 +1243,36 @@ bool RasterizerSceneGLES3::_setup_material(RasterizerStorageGLES3::Material *p_m
if (t->render_target)
t->render_target->used_in_frame = true;
- if (storage->config.srgb_decode_supported) {
- //if SRGB decode extension is present, simply switch the texture to whathever is needed
- bool must_srgb = false;
+ target = t->target;
+ tex = t->tex_id;
+ }
+
+ glBindTexture(target, tex);
- if (t->srgb && (texture_hints[i] == ShaderLanguage::ShaderNode::Uniform::HINT_ALBEDO || texture_hints[i] == ShaderLanguage::ShaderNode::Uniform::HINT_BLACK_ALBEDO)) {
- must_srgb = true;
- }
+ if (t && storage->config.srgb_decode_supported) {
+ //if SRGB decode extension is present, simply switch the texture to whathever is needed
+ bool must_srgb = false;
+
+ if (t->srgb && (texture_hints[i] == ShaderLanguage::ShaderNode::Uniform::HINT_ALBEDO || texture_hints[i] == ShaderLanguage::ShaderNode::Uniform::HINT_BLACK_ALBEDO)) {
+ must_srgb = true;
+ }
- if (t->using_srgb != must_srgb) {
- if (must_srgb) {
- glTexParameteri(t->target, _TEXTURE_SRGB_DECODE_EXT, _DECODE_EXT);
+ if (t->using_srgb != must_srgb) {
+ if (must_srgb) {
+ glTexParameteri(t->target, _TEXTURE_SRGB_DECODE_EXT, _DECODE_EXT);
#ifdef TOOLS_ENABLED
- if (t->detect_srgb) {
- t->detect_srgb(t->detect_srgb_ud);
- }
+ if (t->detect_srgb) {
+ t->detect_srgb(t->detect_srgb_ud);
+ }
#endif
- } else {
- glTexParameteri(t->target, _TEXTURE_SRGB_DECODE_EXT, _SKIP_DECODE_EXT);
- }
- t->using_srgb = must_srgb;
+ } else {
+ glTexParameteri(t->target, _TEXTURE_SRGB_DECODE_EXT, _SKIP_DECODE_EXT);
}
+ t->using_srgb = must_srgb;
}
-
- target = t->target;
- tex = t->tex_id;
}
- glBindTexture(target, tex);
-
if (i == 0) {
state.current_main_tex = tex;
}
@@ -1834,12 +1826,14 @@ void RasterizerSceneGLES3::_setup_light(RenderList::Element *e, const Transform
GIProbeInstance *gipi = gi_probe_instance_owner.getptr(ridp[0]);
+ float bias_scale = e->instance->baked_light ? 1 : 0;
glActiveTexture(GL_TEXTURE0 + storage->config.max_texture_image_units - 9);
glBindTexture(GL_TEXTURE_3D, gipi->tex_cache);
state.scene_shader.set_uniform(SceneShaderGLES3::GI_PROBE_XFORM1, gipi->transform_to_data * p_view_transform);
state.scene_shader.set_uniform(SceneShaderGLES3::GI_PROBE_BOUNDS1, gipi->bounds);
state.scene_shader.set_uniform(SceneShaderGLES3::GI_PROBE_MULTIPLIER1, gipi->probe ? gipi->probe->dynamic_range * gipi->probe->energy : 0.0);
- state.scene_shader.set_uniform(SceneShaderGLES3::GI_PROBE_BIAS1, gipi->probe ? gipi->probe->bias : 0.0);
+ state.scene_shader.set_uniform(SceneShaderGLES3::GI_PROBE_BIAS1, gipi->probe ? gipi->probe->bias * bias_scale : 0.0);
+ state.scene_shader.set_uniform(SceneShaderGLES3::GI_PROBE_NORMAL_BIAS1, gipi->probe ? gipi->probe->normal_bias * bias_scale : 0.0);
state.scene_shader.set_uniform(SceneShaderGLES3::GI_PROBE_BLEND_AMBIENT1, gipi->probe ? !gipi->probe->interior : false);
state.scene_shader.set_uniform(SceneShaderGLES3::GI_PROBE_CELL_SIZE1, gipi->cell_size_cache);
if (gi_probe_count > 1) {
@@ -1852,7 +1846,8 @@ void RasterizerSceneGLES3::_setup_light(RenderList::Element *e, const Transform
state.scene_shader.set_uniform(SceneShaderGLES3::GI_PROBE_BOUNDS2, gipi2->bounds);
state.scene_shader.set_uniform(SceneShaderGLES3::GI_PROBE_CELL_SIZE2, gipi2->cell_size_cache);
state.scene_shader.set_uniform(SceneShaderGLES3::GI_PROBE_MULTIPLIER2, gipi2->probe ? gipi2->probe->dynamic_range * gipi2->probe->energy : 0.0);
- state.scene_shader.set_uniform(SceneShaderGLES3::GI_PROBE_BIAS2, gipi2->probe ? gipi2->probe->bias : 0.0);
+ state.scene_shader.set_uniform(SceneShaderGLES3::GI_PROBE_BIAS2, gipi2->probe ? gipi2->probe->bias * bias_scale : 0.0);
+ state.scene_shader.set_uniform(SceneShaderGLES3::GI_PROBE_NORMAL_BIAS2, gipi2->probe ? gipi2->probe->normal_bias * bias_scale : 0.0);
state.scene_shader.set_uniform(SceneShaderGLES3::GI_PROBE_BLEND_AMBIENT2, gipi2->probe ? !gipi2->probe->interior : false);
state.scene_shader.set_uniform(SceneShaderGLES3::GI_PROBE2_ENABLED, true);
} else {
@@ -1879,19 +1874,29 @@ void RasterizerSceneGLES3::_render_list(RenderList::Element **p_elements, int p_
glBindBufferBase(GL_UNIFORM_BUFFER, 0, state.scene_ubo); //bind globals ubo
+ bool use_radiance_map = false;
if (!p_shadow && !p_directional_add) {
glBindBufferBase(GL_UNIFORM_BUFFER, 2, state.env_radiance_ubo); //bind environment radiance info
if (p_base_env) {
glActiveTexture(GL_TEXTURE0 + storage->config.max_texture_image_units - 2);
- glBindTexture(GL_TEXTURE_2D, p_base_env);
+ if (storage->config.use_texture_array_environment) {
+ glBindTexture(GL_TEXTURE_2D_ARRAY, p_base_env);
+ } else {
+ glBindTexture(GL_TEXTURE_2D, p_base_env);
+ }
+
state.scene_shader.set_conditional(SceneShaderGLES3::USE_RADIANCE_MAP, true);
+ state.scene_shader.set_conditional(SceneShaderGLES3::USE_RADIANCE_MAP_ARRAY, storage->config.use_texture_array_environment);
+ use_radiance_map = true;
} else {
state.scene_shader.set_conditional(SceneShaderGLES3::USE_RADIANCE_MAP, false);
+ state.scene_shader.set_conditional(SceneShaderGLES3::USE_RADIANCE_MAP_ARRAY, false);
}
} else {
state.scene_shader.set_conditional(SceneShaderGLES3::USE_RADIANCE_MAP, false);
+ state.scene_shader.set_conditional(SceneShaderGLES3::USE_RADIANCE_MAP_ARRAY, false);
}
state.cull_front = false;
@@ -1949,6 +1954,7 @@ void RasterizerSceneGLES3::_render_list(RenderList::Element **p_elements, int p_
state.scene_shader.set_conditional(SceneShaderGLES3::SHADELESS, true);
state.scene_shader.set_conditional(SceneShaderGLES3::USE_FORWARD_LIGHTING, false);
+ state.scene_shader.set_conditional(SceneShaderGLES3::USE_VERTEX_LIGHTING, false);
state.scene_shader.set_conditional(SceneShaderGLES3::USE_LIGHT_DIRECTIONAL, false);
state.scene_shader.set_conditional(SceneShaderGLES3::LIGHT_DIRECTIONAL_SHADOW, false);
state.scene_shader.set_conditional(SceneShaderGLES3::LIGHT_USE_PSSM4, false);
@@ -1958,6 +1964,8 @@ void RasterizerSceneGLES3::_render_list(RenderList::Element **p_elements, int p_
state.scene_shader.set_conditional(SceneShaderGLES3::SHADOW_MODE_PCF_5, false);
state.scene_shader.set_conditional(SceneShaderGLES3::SHADOW_MODE_PCF_13, false);
state.scene_shader.set_conditional(SceneShaderGLES3::USE_GI_PROBES, false);
+ state.scene_shader.set_conditional(SceneShaderGLES3::USE_RADIANCE_MAP, false);
+ state.scene_shader.set_conditional(SceneShaderGLES3::USE_CONTACT_SHADOWS, false);
//state.scene_shader.set_conditional(SceneShaderGLES3::SHADELESS,true);
} else {
@@ -1965,7 +1973,10 @@ void RasterizerSceneGLES3::_render_list(RenderList::Element **p_elements, int p_
state.scene_shader.set_conditional(SceneShaderGLES3::USE_GI_PROBES, e->instance->gi_probe_instances.size() > 0);
state.scene_shader.set_conditional(SceneShaderGLES3::SHADELESS, false);
+
state.scene_shader.set_conditional(SceneShaderGLES3::USE_FORWARD_LIGHTING, !p_directional_add);
+ state.scene_shader.set_conditional(SceneShaderGLES3::USE_VERTEX_LIGHTING, (e->sort_key & SORT_KEY_VERTEX_LIT_FLAG));
+
state.scene_shader.set_conditional(SceneShaderGLES3::USE_LIGHT_DIRECTIONAL, false);
state.scene_shader.set_conditional(SceneShaderGLES3::LIGHT_DIRECTIONAL_SHADOW, false);
state.scene_shader.set_conditional(SceneShaderGLES3::LIGHT_USE_PSSM4, false);
@@ -1973,6 +1984,8 @@ void RasterizerSceneGLES3::_render_list(RenderList::Element **p_elements, int p_
state.scene_shader.set_conditional(SceneShaderGLES3::LIGHT_USE_PSSM_BLEND, false);
state.scene_shader.set_conditional(SceneShaderGLES3::SHADOW_MODE_PCF_5, shadow_filter_mode == SHADOW_FILTER_PCF5);
state.scene_shader.set_conditional(SceneShaderGLES3::SHADOW_MODE_PCF_13, shadow_filter_mode == SHADOW_FILTER_PCF13);
+ state.scene_shader.set_conditional(SceneShaderGLES3::USE_RADIANCE_MAP, use_radiance_map);
+ state.scene_shader.set_conditional(SceneShaderGLES3::USE_CONTACT_SHADOWS, state.used_contact_shadows);
if (p_directional_add || (directional_light && (e->sort_key & SORT_KEY_NO_DIRECTIONAL_FLAG) == 0)) {
state.scene_shader.set_conditional(SceneShaderGLES3::USE_LIGHT_DIRECTIONAL, true);
@@ -2121,6 +2134,8 @@ void RasterizerSceneGLES3::_render_list(RenderList::Element **p_elements, int p_
state.scene_shader.set_conditional(SceneShaderGLES3::SHADOW_MODE_PCF_5, false);
state.scene_shader.set_conditional(SceneShaderGLES3::SHADOW_MODE_PCF_13, false);
state.scene_shader.set_conditional(SceneShaderGLES3::USE_GI_PROBES, false);
+ state.scene_shader.set_conditional(SceneShaderGLES3::USE_CONTACT_SHADOWS, false);
+ state.scene_shader.set_conditional(SceneShaderGLES3::USE_VERTEX_LIGHTING, false);
}
void RasterizerSceneGLES3::_add_geometry(RasterizerStorageGLES3::Geometry *p_geometry, InstanceBase *p_instance, RasterizerStorageGLES3::GeometryOwner *p_owner, int p_material, bool p_shadow) {
@@ -2155,7 +2170,19 @@ void RasterizerSceneGLES3::_add_geometry(RasterizerStorageGLES3::Geometry *p_geo
ERR_FAIL_COND(!m);
- bool has_base_alpha = (m->shader->spatial.uses_alpha || m->shader->spatial.uses_screen_texture);
+ _add_geometry_with_material(p_geometry, p_instance, p_owner, m, p_shadow);
+
+ while (m->next_pass.is_valid()) {
+ m = storage->material_owner.getornull(m->next_pass);
+ if (!m)
+ break;
+ _add_geometry_with_material(p_geometry, p_instance, p_owner, m, p_shadow);
+ }
+}
+
+void RasterizerSceneGLES3::_add_geometry_with_material(RasterizerStorageGLES3::Geometry *p_geometry, InstanceBase *p_instance, RasterizerStorageGLES3::GeometryOwner *p_owner, RasterizerStorageGLES3::Material *m, bool p_shadow) {
+
+ bool has_base_alpha = (m->shader->spatial.uses_alpha || m->shader->spatial.uses_screen_texture || m->shader->spatial.unshaded);
bool has_blend_alpha = m->shader->spatial.blend_mode != RasterizerStorageGLES3::Shader::Spatial::BLEND_MODE_MIX || m->shader->spatial.ontop;
bool has_alpha = has_base_alpha || has_blend_alpha;
bool shadow = false;
@@ -2254,6 +2281,11 @@ void RasterizerSceneGLES3::_add_geometry(RasterizerStorageGLES3::Geometry *p_geo
e->sort_key |= SORT_KEY_UNSHADED_FLAG;
}
+
+ if (!shadow && (m->shader->spatial.uses_vertex_lighting || storage->config.force_vertex_shading)) {
+
+ e->sort_key |= SORT_KEY_VERTEX_LIT_FLAG;
+ }
}
void RasterizerSceneGLES3::_draw_sky(RasterizerStorageGLES3::Sky *p_sky, const CameraMatrix &p_projection, const Transform &p_transform, bool p_vflip, float p_scale, float p_energy) {
@@ -2865,7 +2897,7 @@ void RasterizerSceneGLES3::_setup_reflections(RID *p_reflection_probe_cull_resul
reflection_ubo.atlas_clamp[0] = float(x) / reflection_atlas->size;
reflection_ubo.atlas_clamp[1] = float(y) / reflection_atlas->size;
reflection_ubo.atlas_clamp[2] = float(width) / reflection_atlas->size;
- reflection_ubo.atlas_clamp[3] = float(height / 2) / reflection_atlas->size;
+ reflection_ubo.atlas_clamp[3] = float(height) / reflection_atlas->size;
Transform proj = (p_camera_inverse_transform * rpi->transform).inverse();
store_transform(proj, reflection_ubo.local_matrix);
@@ -2885,7 +2917,19 @@ void RasterizerSceneGLES3::_setup_reflections(RID *p_reflection_probe_cull_resul
glBindBufferBase(GL_UNIFORM_BUFFER, 6, state.reflection_array_ubo);
}
-void RasterizerSceneGLES3::_copy_screen() {
+void RasterizerSceneGLES3::_copy_screen(bool p_invalidate_color, bool p_invalidate_depth) {
+
+#ifndef GLES_OVER_GL
+ if (p_invalidate_color) {
+
+ GLenum attachments[2] = {
+ GL_COLOR_ATTACHMENT0,
+ GL_DEPTH_STENCIL_ATTACHMENT
+ };
+
+ glInvalidateFramebuffer(GL_FRAMEBUFFER, p_invalidate_depth ? 2 : 1, attachments);
+ }
+#endif
glBindVertexArray(storage->resources.quadie_array);
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
@@ -3053,7 +3097,7 @@ void RasterizerSceneGLES3::_blur_effect_buffer() {
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, storage->frame.current_rt->effects.mip_maps[0].color); //previous level, since mipmaps[0] starts one level bigger
glBindFramebuffer(GL_FRAMEBUFFER, storage->frame.current_rt->effects.mip_maps[1].sizes[i].fbo);
- _copy_screen();
+ _copy_screen(true);
state.effect_blur_shader.set_conditional(EffectBlurShaderGLES3::GAUSSIAN_HORIZONTAL, false);
//vertical pass
@@ -3064,7 +3108,7 @@ void RasterizerSceneGLES3::_blur_effect_buffer() {
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, storage->frame.current_rt->effects.mip_maps[1].color);
glBindFramebuffer(GL_FRAMEBUFFER, storage->frame.current_rt->effects.mip_maps[0].sizes[i + 1].fbo); //next level, since mipmaps[0] starts one level bigger
- _copy_screen();
+ _copy_screen(true);
state.effect_blur_shader.set_conditional(EffectBlurShaderGLES3::GAUSSIAN_VERTICAL, false);
}
}
@@ -3112,7 +3156,7 @@ void RasterizerSceneGLES3::_render_mrts(Environment *env, const CameraMatrix &p_
glBindFramebuffer(GL_FRAMEBUFFER, storage->frame.current_rt->effects.ssao.depth_mipmap_fbos[i]); //copy to front first
glViewport(0, 0, ss[0], ss[1]);
- _copy_screen();
+ _copy_screen(true);
}
ss[0] = storage->frame.current_rt->width;
ss[1] = storage->frame.current_rt->height;
@@ -3164,7 +3208,7 @@ void RasterizerSceneGLES3::_render_mrts(Environment *env, const CameraMatrix &p_
Color white(1, 1, 1, 1);
glClearBufferfv(GL_COLOR, 0, white.components); // specular
- _copy_screen();
+ _copy_screen(true);
//do the batm, i mean blur
@@ -3185,7 +3229,7 @@ void RasterizerSceneGLES3::_render_mrts(Environment *env, const CameraMatrix &p_
if (i == 0) {
glClearBufferfv(GL_COLOR, 0, white.components); // specular
}
- _copy_screen();
+ _copy_screen(true);
}
}
@@ -3202,7 +3246,7 @@ void RasterizerSceneGLES3::_render_mrts(Environment *env, const CameraMatrix &p_
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, storage->frame.current_rt->effects.ssao.blur_red[0]); //previous level, since mipmaps[0] starts one level bigger
glBindFramebuffer(GL_FRAMEBUFFER, storage->frame.current_rt->effects.mip_maps[0].sizes[0].fbo); // copy to base level
- _copy_screen();
+ _copy_screen(true);
state.effect_blur_shader.set_conditional(EffectBlurShaderGLES3::SSAO_MERGE, false);
} else {
@@ -3251,14 +3295,14 @@ void RasterizerSceneGLES3::_render_mrts(Environment *env, const CameraMatrix &p_
glBindFramebuffer(GL_FRAMEBUFFER, storage->frame.current_rt->fbo); //copy to front first
- _copy_screen();
+ _copy_screen(true);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, storage->frame.current_rt->color);
state.sss_shader.set_uniform(SubsurfScatteringShaderGLES3::DIR, Vector2(0, 1));
glBindFramebuffer(GL_FRAMEBUFFER, storage->frame.current_rt->effects.mip_maps[0].sizes[0].fbo); // copy to base level
- _copy_screen();
+ _copy_screen(true);
glBindTexture(GL_TEXTURE_2D, storage->frame.current_rt->effects.mip_maps[0].color); //restore filter
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
@@ -3310,7 +3354,7 @@ void RasterizerSceneGLES3::_render_mrts(Environment *env, const CameraMatrix &p_
glBindFramebuffer(GL_FRAMEBUFFER, storage->frame.current_rt->effects.mip_maps[1].sizes[0].fbo);
glViewport(0, 0, ssr_w, ssr_h);
- _copy_screen();
+ _copy_screen(true);
glViewport(0, 0, storage->frame.current_rt->width, storage->frame.current_rt->height);
}
@@ -3341,7 +3385,7 @@ void RasterizerSceneGLES3::_render_mrts(Environment *env, const CameraMatrix &p_
glBlendEquation(GL_FUNC_ADD);
glBlendFunc(GL_ONE, GL_ONE); //use additive to accumulate one over the other
- _copy_screen();
+ _copy_screen(true);
glDisable(GL_BLEND); //end additive
@@ -3365,7 +3409,7 @@ void RasterizerSceneGLES3::_render_mrts(Environment *env, const CameraMatrix &p_
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, storage->frame.current_rt->effects.mip_maps[0].color);
- _copy_screen();
+ _copy_screen(true);
state.effect_blur_shader.set_conditional(EffectBlurShaderGLES3::SIMPLE_COPY, false);
}
@@ -3386,13 +3430,16 @@ void RasterizerSceneGLES3::_post_process(Environment *env, const CameraMatrix &p
//copy specular to front buffer
//copy diffuse to effect buffer
- glReadBuffer(GL_COLOR_ATTACHMENT0);
- glBindFramebuffer(GL_READ_FRAMEBUFFER, storage->frame.current_rt->buffers.fbo);
- glBindFramebuffer(GL_DRAW_FRAMEBUFFER, storage->frame.current_rt->effects.mip_maps[0].sizes[0].fbo);
- glBlitFramebuffer(0, 0, storage->frame.current_rt->width, storage->frame.current_rt->height, 0, 0, storage->frame.current_rt->width, storage->frame.current_rt->height, GL_COLOR_BUFFER_BIT, GL_NEAREST);
+ if (storage->frame.current_rt->buffers.active) {
+ //transfer to effect buffer if using buffers, also resolve MSAA
+ glReadBuffer(GL_COLOR_ATTACHMENT0);
+ glBindFramebuffer(GL_READ_FRAMEBUFFER, storage->frame.current_rt->buffers.fbo);
+ glBindFramebuffer(GL_DRAW_FRAMEBUFFER, storage->frame.current_rt->effects.mip_maps[0].sizes[0].fbo);
+ glBlitFramebuffer(0, 0, storage->frame.current_rt->width, storage->frame.current_rt->height, 0, 0, storage->frame.current_rt->width, storage->frame.current_rt->height, GL_COLOR_BUFFER_BIT, GL_NEAREST);
- glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
- glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
+ glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
+ glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
+ }
if (!env || storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_TRANSPARENT]) {
//no environment or transparent render, simply return and convert to SRGB
@@ -3404,7 +3451,7 @@ void RasterizerSceneGLES3::_post_process(Environment *env, const CameraMatrix &p
storage->shaders.copy.set_conditional(CopyShaderGLES3::DISABLE_ALPHA, !storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_TRANSPARENT]);
storage->shaders.copy.bind();
- _copy_screen();
+ _copy_screen(true);
storage->shaders.copy.set_conditional(CopyShaderGLES3::LINEAR_TO_SRGB, false);
storage->shaders.copy.set_conditional(CopyShaderGLES3::DISABLE_ALPHA, false); //compute luminance
@@ -3460,7 +3507,7 @@ void RasterizerSceneGLES3::_post_process(Environment *env, const CameraMatrix &p
glBindFramebuffer(GL_FRAMEBUFFER, storage->frame.current_rt->fbo); //copy to front first
- _copy_screen();
+ _copy_screen(true);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, storage->frame.current_rt->color);
@@ -3469,7 +3516,6 @@ void RasterizerSceneGLES3::_post_process(Environment *env, const CameraMatrix &p
_copy_screen();
state.effect_blur_shader.set_conditional(EffectBlurShaderGLES3::DOF_FAR_BLUR, false);
- state.effect_blur_shader.set_conditional(EffectBlurShaderGLES3::DOF_FAR_BLUR, false);
state.effect_blur_shader.set_conditional(EffectBlurShaderGLES3::DOF_QUALITY_LOW, false);
state.effect_blur_shader.set_conditional(EffectBlurShaderGLES3::DOF_QUALITY_MEDIUM, false);
state.effect_blur_shader.set_conditional(EffectBlurShaderGLES3::DOF_QUALITY_HIGH, false);
@@ -3547,7 +3593,7 @@ void RasterizerSceneGLES3::_post_process(Environment *env, const CameraMatrix &p
glBindTexture(GL_TEXTURE_2D, storage->frame.current_rt->buffers.diffuse);
}
- _copy_screen();
+ _copy_screen(true);
if (composite_from != storage->frame.current_rt->buffers.diffuse) {
@@ -3564,6 +3610,16 @@ void RasterizerSceneGLES3::_post_process(Environment *env, const CameraMatrix &p
composite_from = storage->frame.current_rt->effects.mip_maps[0].color;
}
+ if (env->dof_blur_near_enabled || env->dof_blur_far_enabled) {
+ //these needed to disable filtering, reenamble
+ glActiveTexture(GL_TEXTURE0);
+ glBindTexture(GL_TEXTURE_2D, storage->frame.current_rt->effects.mip_maps[0].color);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ }
+
if (env->auto_exposure) {
//compute auto exposure
@@ -3587,7 +3643,7 @@ void RasterizerSceneGLES3::_post_process(Environment *env, const CameraMatrix &p
glBindFramebuffer(GL_FRAMEBUFFER, exposure_shrink[0].fbo);
glViewport(0, 0, exposure_shrink_size, exposure_shrink_size);
- _copy_screen();
+ _copy_screen(true);
//second step, shrink to 2x2 pixels
state.exposure_shader.set_conditional(ExposureShaderGLES3::EXPOSURE_BEGIN, false);
@@ -3631,7 +3687,7 @@ void RasterizerSceneGLES3::_post_process(Environment *env, const CameraMatrix &p
state.exposure_shader.set_uniform(ExposureShaderGLES3::MAX_LUMINANCE, env->auto_exposure_max);
state.exposure_shader.set_uniform(ExposureShaderGLES3::MIN_LUMINANCE, env->auto_exposure_min);
- _copy_screen();
+ _copy_screen(true);
state.exposure_shader.set_conditional(ExposureShaderGLES3::EXPOSURE_FORCE_SET, false);
state.exposure_shader.set_conditional(ExposureShaderGLES3::EXPOSURE_END, false);
@@ -3695,14 +3751,14 @@ void RasterizerSceneGLES3::_post_process(Environment *env, const CameraMatrix &p
glBindTexture(GL_TEXTURE_2D, storage->frame.current_rt->exposure.color);
state.effect_blur_shader.set_uniform(EffectBlurShaderGLES3::GLOW_BLOOM, env->glow_bloom);
- state.effect_blur_shader.set_uniform(EffectBlurShaderGLES3::GLOW_HDR_TRESHOLD, env->glow_hdr_bleed_treshold);
+ state.effect_blur_shader.set_uniform(EffectBlurShaderGLES3::GLOW_HDR_THRESHOLD, env->glow_hdr_bleed_threshold);
state.effect_blur_shader.set_uniform(EffectBlurShaderGLES3::GLOW_HDR_SCALE, env->glow_hdr_bleed_scale);
} else {
glBindTexture(GL_TEXTURE_2D, storage->frame.current_rt->effects.mip_maps[0].color); //previous level, since mipmaps[0] starts one level bigger
}
glBindFramebuffer(GL_FRAMEBUFFER, storage->frame.current_rt->effects.mip_maps[1].sizes[i].fbo);
- _copy_screen();
+ _copy_screen(true);
state.effect_blur_shader.set_conditional(EffectBlurShaderGLES3::GLOW_GAUSSIAN_HORIZONTAL, false);
state.effect_blur_shader.set_conditional(EffectBlurShaderGLES3::GLOW_FIRST_PASS, false);
state.effect_blur_shader.set_conditional(EffectBlurShaderGLES3::GLOW_USE_AUTO_EXPOSURE, false);
@@ -3810,7 +3866,7 @@ void RasterizerSceneGLES3::_post_process(Environment *env, const CameraMatrix &p
state.tonemap_shader.set_uniform(TonemapShaderGLES3::BCS, Vector3(env->adjustments_brightness, env->adjustments_contrast, env->adjustments_saturation));
}
- _copy_screen();
+ _copy_screen(true, true);
//turn off everything used
state.tonemap_shader.set_conditional(TonemapShaderGLES3::USE_AUTO_EXPOSURE, false);
@@ -3886,7 +3942,7 @@ void RasterizerSceneGLES3::render_scene(const Transform &p_cam_transform, const
state.used_contact_shadows = true;
- if (storage->frame.current_rt && state.debug_draw != VS::VIEWPORT_DEBUG_DRAW_OVERDRAW) { //detect with state.used_contact_shadows too
+ if (!storage->config.no_depth_prepass && storage->frame.current_rt && state.debug_draw != VS::VIEWPORT_DEBUG_DRAW_OVERDRAW) { //detect with state.used_contact_shadows too
//pre z pass
glDisable(GL_BLEND);
@@ -3900,7 +3956,7 @@ void RasterizerSceneGLES3::render_scene(const Transform &p_cam_transform, const
glColorMask(0, 0, 0, 0);
glClearDepth(1.0f);
- glClear(GL_DEPTH_BUFFER_BIT);
+ glClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
render_list.clear();
_fill_render_list(p_cull_result, p_cull_count, true);
@@ -3926,6 +3982,9 @@ void RasterizerSceneGLES3::render_scene(const Transform &p_cam_transform, const
fb_cleared = true;
render_pass++;
+ state.using_contact_shadows = true;
+ } else {
+ state.using_contact_shadows = false;
}
_setup_lights(p_light_cull_result, p_light_cull_count, p_cam_transform.affine_inverse(), p_cam_projection, p_shadow_atlas);
@@ -3973,7 +4032,7 @@ void RasterizerSceneGLES3::render_scene(const Transform &p_cam_transform, const
} else {
- use_mrt = env && (state.used_screen_texture || state.used_sss || env->ssao_enabled || env->ssr_enabled); //only enable MRT rendering if any of these is enabled
+ use_mrt = env && (state.used_sss || env->ssao_enabled || env->ssr_enabled); //only enable MRT rendering if any of these is enabled
//effects disabled and transparency also prevent using MRTs
use_mrt = use_mrt && !storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_TRANSPARENT];
use_mrt = use_mrt && !storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_NO_3D_EFFECTS];
@@ -4007,8 +4066,13 @@ void RasterizerSceneGLES3::render_scene(const Transform &p_cam_transform, const
} else {
- current_fbo = storage->frame.current_rt->buffers.fbo;
- glBindFramebuffer(GL_FRAMEBUFFER, storage->frame.current_rt->buffers.fbo);
+ if (storage->frame.current_rt->buffers.active) {
+ current_fbo = storage->frame.current_rt->buffers.fbo;
+ } else {
+ current_fbo = storage->frame.current_rt->effects.mip_maps[0].sizes[0].fbo;
+ }
+
+ glBindFramebuffer(GL_FRAMEBUFFER, current_fbo);
state.scene_shader.set_conditional(SceneShaderGLES3::USE_MULTIPLE_RENDER_TARGETS, false);
Vector<GLenum> draw_buffers;
@@ -4018,8 +4082,7 @@ void RasterizerSceneGLES3::render_scene(const Transform &p_cam_transform, const
}
if (!fb_cleared) {
- glClearDepth(1.0f);
- glClear(GL_DEPTH_BUFFER_BIT);
+ glClearBufferfi(GL_DEPTH_STENCIL, 0, 1.0, 0);
}
Color clear_color(0, 0, 0, 0);
@@ -4084,7 +4147,7 @@ void RasterizerSceneGLES3::render_scene(const Transform &p_cam_transform, const
storage->shaders.copy.bind();
- _copy_screen();
+ _copy_screen(true, true);
//turn off everything used
storage->shaders.copy.set_conditional(CopyShaderGLES3::SRGB_TO_LINEAR, false);
@@ -4132,7 +4195,7 @@ void RasterizerSceneGLES3::render_scene(const Transform &p_cam_transform, const
glDrawBuffers(1, &gldb);
}
- if (env && env->bg_mode == VS::ENV_BG_SKY && !storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_TRANSPARENT] && state.debug_draw != VS::VIEWPORT_DEBUG_DRAW_OVERDRAW) {
+ if (env && env->bg_mode == VS::ENV_BG_SKY && (!storage->frame.current_rt || (!storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_TRANSPARENT] && state.debug_draw != VS::VIEWPORT_DEBUG_DRAW_OVERDRAW))) {
/*
if (use_mrt) {
@@ -4149,9 +4212,23 @@ void RasterizerSceneGLES3::render_scene(const Transform &p_cam_transform, const
if (use_mrt) {
_render_mrts(env, p_cam_projection);
+ } else {
+ //FIXME: check that this is possible to use
+ if (storage->frame.current_rt && storage->frame.current_rt->buffers.active && state.used_screen_texture) {
+ glBindFramebuffer(GL_READ_FRAMEBUFFER, storage->frame.current_rt->buffers.fbo);
+ glReadBuffer(GL_COLOR_ATTACHMENT0);
+ glBindFramebuffer(GL_DRAW_FRAMEBUFFER, storage->frame.current_rt->effects.mip_maps[0].sizes[0].fbo);
+ glBlitFramebuffer(0, 0, storage->frame.current_rt->width, storage->frame.current_rt->height, 0, 0, storage->frame.current_rt->width, storage->frame.current_rt->height, GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, GL_NEAREST);
+ glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
+ glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
+ _blur_effect_buffer();
+ //restored framebuffer
+ glBindFramebuffer(GL_FRAMEBUFFER, storage->frame.current_rt->buffers.fbo);
+ glViewport(0, 0, storage->frame.current_rt->width, storage->frame.current_rt->height);
+ }
}
- if (state.used_screen_texture) {
+ if (storage->frame.current_rt && state.used_screen_texture && storage->frame.current_rt->buffers.active) {
glActiveTexture(GL_TEXTURE0 + storage->config.max_texture_image_units - 7);
glBindTexture(GL_TEXTURE_2D, storage->frame.current_rt->effects.mip_maps[0].color);
}
@@ -4161,7 +4238,7 @@ void RasterizerSceneGLES3::render_scene(const Transform &p_cam_transform, const
glEnable(GL_DEPTH_TEST);
glDisable(GL_SCISSOR_TEST);
- render_list.sort_by_depth(true);
+ render_list.sort_by_reverse_depth(true);
if (state.directional_light_count == 0) {
directional_light = NULL;
@@ -4226,8 +4303,14 @@ void RasterizerSceneGLES3::render_scene(const Transform &p_cam_transform, const
storage->canvas->canvas_begin();
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, env_radiance_tex);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
storage->canvas->draw_generic_textured_rect(Rect2(0, 0, storage->frame.current_rt->width / 2, storage->frame.current_rt->height / 2), Rect2(0, 0, 1, 1));
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
}
+
+ //disable all stuff
}
void RasterizerSceneGLES3::render_shadow(RID p_light, RID p_shadow_atlas, int p_pass, InstanceBase **p_cull_result, int p_cull_count) {
@@ -4252,6 +4335,8 @@ void RasterizerSceneGLES3::render_shadow(RID p_light, RID p_shadow_atlas, int p_
float bias = 0;
float normal_bias = 0;
+ state.using_contact_shadows = false;
+
CameraMatrix light_projection;
Transform light_transform;
@@ -4593,7 +4678,7 @@ void RasterizerSceneGLES3::initialize() {
glBufferData(GL_UNIFORM_BUFFER, sizeof(State::EnvironmentRadianceUBO), &state.env_radiance_ubo, GL_DYNAMIC_DRAW);
glBindBuffer(GL_UNIFORM_BUFFER, 0);
- render_list.max_elements = GLOBAL_DEF("rendering/gles3/max_renderable_elements", (int)RenderList::DEFAULT_MAX_ELEMENTS);
+ render_list.max_elements = GLOBAL_DEF("rendering/limits/rendering/max_renderable_elements", (int)RenderList::DEFAULT_MAX_ELEMENTS);
if (render_list.max_elements > 1000000)
render_list.max_elements = 1000000;
if (render_list.max_elements < 1024)
@@ -4667,7 +4752,7 @@ void RasterizerSceneGLES3::initialize() {
{
//directional light shadow
directional_shadow.light_count = 0;
- directional_shadow.size = nearest_power_of_2(GLOBAL_DEF("rendering/shadows/directional_shadow_size", 4096));
+ directional_shadow.size = nearest_power_of_2(GLOBAL_GET("rendering/quality/directional_shadow/size"));
glGenFramebuffers(1, &directional_shadow.fbo);
glBindFramebuffer(GL_FRAMEBUFFER, directional_shadow.fbo);
glGenTextures(1, &directional_shadow.depth);
@@ -4734,8 +4819,6 @@ void RasterizerSceneGLES3::initialize() {
state.scene_shader.add_custom_define("#define MAX_SKELETON_BONES " + itos(state.max_skeleton_bones) + "\n");
}
- GLOBAL_DEF("rendering/gles3/shadow_filter_mode", 1);
- GlobalConfig::get_singleton()->set_custom_property_info("rendering/gles3/shadow_filter_mode", PropertyInfo(Variant::INT, "rendering/gles3/shadow_filter_mode", PROPERTY_HINT_ENUM, "Disabled,PCF5,PCF13"));
shadow_filter_mode = SHADOW_FILTER_NEAREST;
{ //reflection cubemaps
@@ -4799,7 +4882,7 @@ void RasterizerSceneGLES3::initialize() {
{
- uint32_t immediate_buffer_size = GLOBAL_DEF("rendering/buffers/immediate_buffer_size_kb", 2048);
+ uint32_t immediate_buffer_size = GLOBAL_DEF("rendering/limits/buffers/immediate_buffer_size_kb", 2048);
glGenBuffers(1, &state.immediate_buffer);
glBindBuffer(GL_ARRAY_BUFFER, state.immediate_buffer);
@@ -4826,13 +4909,13 @@ void RasterizerSceneGLES3::initialize() {
state.tonemap_shader.init();
{
- GLOBAL_DEF("rendering/ssurf_scattering/quality", 1);
- GlobalConfig::get_singleton()->set_custom_property_info("rendering/ssurf_scattering/quality", PropertyInfo(Variant::INT, "rendering/ssurf_scattering/quality", PROPERTY_HINT_ENUM, "Low,Medium,High"));
- GLOBAL_DEF("rendering/ssurf_scattering/max_size", 1.0);
- GlobalConfig::get_singleton()->set_custom_property_info("rendering/ssurf_scattering/max_size", PropertyInfo(Variant::INT, "rendering/ssurf_scattering/max_size", PROPERTY_HINT_RANGE, "0.01,8,0.01"));
- GLOBAL_DEF("rendering/ssurf_scattering/follow_surface", false);
+ GLOBAL_DEF("rendering/quality/subsurface_scattering/quality", 1);
+ ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/subsurface_scattering/quality", PropertyInfo(Variant::INT, "rendering/quality/subsurface_scattering/quality", PROPERTY_HINT_ENUM, "Low,Medium,High"));
+ GLOBAL_DEF("rendering/quality/subsurface_scattering/scale", 1.0);
+ ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/subsurface_scattering/scale", PropertyInfo(Variant::INT, "rendering/quality/subsurface_scattering/scale", PROPERTY_HINT_RANGE, "0.01,8,0.01"));
+ GLOBAL_DEF("rendering/quality/subsurface_scattering/follow_surface", false);
- GLOBAL_DEF("rendering/reflections/high_quality_vct_gi", true);
+ GLOBAL_DEF("rendering/quality/voxel_cone_tracing/high_quality", true);
}
exposure_shrink_size = 243;
@@ -4871,12 +4954,12 @@ void RasterizerSceneGLES3::initialize() {
void RasterizerSceneGLES3::iteration() {
- shadow_filter_mode = ShadowFilterMode(int(GlobalConfig::get_singleton()->get("rendering/gles3/shadow_filter_mode")));
- subsurface_scatter_follow_surface = GlobalConfig::get_singleton()->get("rendering/ssurf_scattering/follow_surface");
- subsurface_scatter_quality = SubSurfaceScatterQuality(int(GlobalConfig::get_singleton()->get("rendering/ssurf_scattering/quality")));
- subsurface_scatter_size = GlobalConfig::get_singleton()->get("rendering/ssurf_scattering/max_size");
+ shadow_filter_mode = ShadowFilterMode(int(ProjectSettings::get_singleton()->get("rendering/quality/shadows/filter_mode")));
+ subsurface_scatter_follow_surface = ProjectSettings::get_singleton()->get("rendering/quality/subsurface_scattering/follow_surface");
+ subsurface_scatter_quality = SubSurfaceScatterQuality(int(ProjectSettings::get_singleton()->get("rendering/quality/subsurface_scattering/quality")));
+ subsurface_scatter_size = ProjectSettings::get_singleton()->get("rendering/quality/subsurface_scattering/scale");
- state.scene_shader.set_conditional(SceneShaderGLES3::VCT_QUALITY_HIGH, GlobalConfig::get_singleton()->get("rendering/reflections/high_quality_vct_gi"));
+ state.scene_shader.set_conditional(SceneShaderGLES3::VCT_QUALITY_HIGH, ProjectSettings::get_singleton()->get("rendering/quality/voxel_cone_tracing/high_quality"));
}
void RasterizerSceneGLES3::finalize() {
diff --git a/drivers/gles3/rasterizer_scene_gles3.h b/drivers/gles3/rasterizer_scene_gles3.h
index 5f0db446a9..f6509e0041 100644
--- a/drivers/gles3/rasterizer_scene_gles3.h
+++ b/drivers/gles3/rasterizer_scene_gles3.h
@@ -187,6 +187,7 @@ public:
bool cull_front;
bool used_sss;
bool used_screen_texture;
+ bool using_contact_shadows;
VS::ViewportDebugDraw debug_draw;
} state;
@@ -381,7 +382,7 @@ public:
float glow_strength;
float glow_bloom;
VS::EnvironmentGlowBlendMode glow_blend_mode;
- float glow_hdr_bleed_treshold;
+ float glow_hdr_bleed_threshold;
float glow_hdr_bleed_scale;
bool glow_bicubic_upscale;
@@ -467,7 +468,7 @@ public:
glow_strength = 1.0;
glow_bloom = 0.0;
glow_blend_mode = VS::GLOW_BLEND_MODE_SOFTLIGHT;
- glow_hdr_bleed_treshold = 1.0;
+ glow_hdr_bleed_threshold = 1.0;
glow_hdr_bleed_scale = 2.0;
glow_bicubic_upscale = false;
@@ -522,7 +523,7 @@ public:
virtual void environment_set_dof_blur_near(RID p_env, bool p_enable, float p_distance, float p_transition, float p_far_amount, VS::EnvironmentDOFBlurQuality p_quality);
virtual void environment_set_dof_blur_far(RID p_env, bool p_enable, float p_distance, float p_transition, float p_far_amount, VS::EnvironmentDOFBlurQuality p_quality);
- virtual void environment_set_glow(RID p_env, bool p_enable, int p_level_flags, float p_intensity, float p_strength, float p_bloom_treshold, VS::EnvironmentGlowBlendMode p_blend_mode, float p_hdr_bleed_treshold, float p_hdr_bleed_scale, bool p_bicubic_upscale);
+ virtual void environment_set_glow(RID p_env, bool p_enable, int p_level_flags, float p_intensity, float p_strength, float p_bloom_threshold, VS::EnvironmentGlowBlendMode p_blend_mode, float p_hdr_bleed_threshold, float p_hdr_bleed_scale, bool p_bicubic_upscale);
virtual void environment_set_fog(RID p_env, bool p_enable, float p_begin, float p_end, RID p_gradient_texture);
virtual void environment_set_ssr(RID p_env, bool p_enable, int p_max_steps, float p_fade_in, float p_fade_out, float p_depth_tolerance, bool p_roughness);
@@ -645,8 +646,9 @@ public:
#define SORT_KEY_UNSHADED_FLAG (uint64_t(1) << 59)
#define SORT_KEY_NO_DIRECTIONAL_FLAG (uint64_t(1) << 58)
#define SORT_KEY_GI_PROBES_FLAG (uint64_t(1) << 57)
- SORT_KEY_SHADING_SHIFT = 57,
- SORT_KEY_SHADING_MASK = 7,
+#define SORT_KEY_VERTEX_LIT_FLAG (uint64_t(1) << 56)
+ SORT_KEY_SHADING_SHIFT = 56,
+ SORT_KEY_SHADING_MASK = 15,
SORT_KEY_MATERIAL_INDEX_SHIFT = 40,
SORT_KEY_GEOMETRY_INDEX_SHIFT = 20,
SORT_KEY_GEOMETRY_TYPE_SHIFT = 15,
@@ -666,7 +668,7 @@ public:
uint64_t sort_key;
};
- Element *_elements;
+ Element *base_elements;
Element **elements;
int element_count;
@@ -700,11 +702,11 @@ public:
struct SortByDepth {
_FORCE_INLINE_ bool operator()(const Element *A, const Element *B) const {
- return A->instance->depth > B->instance->depth;
+ return A->instance->depth < B->instance->depth;
}
};
- void sort_by_depth(bool p_alpha) {
+ void sort_by_depth(bool p_alpha) { //used for shadows
SortArray<Element *, SortByDepth> sorter;
if (p_alpha) {
@@ -714,11 +716,28 @@ public:
}
}
+ struct SortByReverseDepth {
+
+ _FORCE_INLINE_ bool operator()(const Element *A, const Element *B) const {
+ return A->instance->depth > B->instance->depth;
+ }
+ };
+
+ void sort_by_reverse_depth(bool p_alpha) { //used for alpha
+
+ SortArray<Element *, SortByReverseDepth> sorter;
+ if (p_alpha) {
+ sorter.sort(&elements[max_elements - alpha_element_count], alpha_element_count);
+ } else {
+ sorter.sort(elements, element_count);
+ }
+ }
+
_FORCE_INLINE_ Element *add_element() {
if (element_count + alpha_element_count >= max_elements)
return NULL;
- elements[element_count] = &_elements[element_count];
+ elements[element_count] = &base_elements[element_count];
return elements[element_count++];
}
@@ -727,7 +746,7 @@ public:
if (element_count + alpha_element_count >= max_elements)
return NULL;
int idx = max_elements - alpha_element_count - 1;
- elements[idx] = &_elements[idx];
+ elements[idx] = &base_elements[idx];
alpha_element_count++;
return elements[idx];
}
@@ -737,9 +756,9 @@ public:
element_count = 0;
alpha_element_count = 0;
elements = memnew_arr(Element *, max_elements);
- _elements = memnew_arr(Element, max_elements);
+ base_elements = memnew_arr(Element, max_elements);
for (int i = 0; i < max_elements; i++)
- elements[i] = &_elements[i]; // assign elements
+ elements[i] = &base_elements[i]; // assign elements
}
RenderList() {
@@ -749,7 +768,7 @@ public:
~RenderList() {
memdelete_arr(elements);
- memdelete_arr(_elements);
+ memdelete_arr(base_elements);
}
};
@@ -769,6 +788,8 @@ public:
_FORCE_INLINE_ void _add_geometry(RasterizerStorageGLES3::Geometry *p_geometry, InstanceBase *p_instance, RasterizerStorageGLES3::GeometryOwner *p_owner, int p_material, bool p_shadow);
+ _FORCE_INLINE_ void _add_geometry_with_material(RasterizerStorageGLES3::Geometry *p_geometry, InstanceBase *p_instance, RasterizerStorageGLES3::GeometryOwner *p_owner, RasterizerStorageGLES3::Material *p_material, bool p_shadow);
+
void _draw_sky(RasterizerStorageGLES3::Sky *p_sky, const CameraMatrix &p_projection, const Transform &p_transform, bool p_vflip, float p_scale, float p_energy);
void _setup_environment(Environment *env, const CameraMatrix &p_cam_projection, const Transform &p_cam_transform);
@@ -776,7 +797,7 @@ public:
void _setup_lights(RID *p_light_cull_result, int p_light_cull_count, const Transform &p_camera_inverse_transform, const CameraMatrix &p_camera_projection, RID p_shadow_atlas);
void _setup_reflections(RID *p_reflection_probe_cull_result, int p_reflection_probe_cull_count, const Transform &p_camera_inverse_transform, const CameraMatrix &p_camera_projection, RID p_reflection_atlas, Environment *p_env);
- void _copy_screen();
+ void _copy_screen(bool p_invalidate_color = false, bool p_invalidate_depth = false);
void _copy_to_front_buffer(Environment *env);
void _copy_texture_to_front_buffer(GLuint p_texture); //used for debug
diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp
index b1dc32e1c0..89bea1e8cc 100644
--- a/drivers/gles3/rasterizer_storage_gles3.cpp
+++ b/drivers/gles3/rasterizer_storage_gles3.cpp
@@ -28,7 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "rasterizer_storage_gles3.h"
-#include "global_config.h"
+#include "project_settings.h"
#include "rasterizer_canvas_gles3.h"
#include "rasterizer_scene_gles3.h"
@@ -99,6 +99,21 @@
#define _EXT_COMPRESSED_RGB_BPTC_SIGNED_FLOAT 0x8E8E
#define _EXT_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT 0x8E8F
+void glTexStorage2DCustom(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type) {
+
+#ifdef GLES_OVER_GL
+
+ for (int i = 0; i < levels; i++) {
+ glTexImage2D(target, i, internalformat, width, height, 0, format, type, NULL);
+ width = MAX(1, (width / 2));
+ height = MAX(1, (height / 2));
+ }
+
+#else
+ glTexStorage2D(target, levels, internalformat, width, height);
+#endif
+}
+
GLuint RasterizerStorageGLES3::system_fbo = 0;
Ref<Image> RasterizerStorageGLES3::_get_gl_image_and_format(const Ref<Image> &p_image, Image::Format p_format, uint32_t p_flags, GLenum &r_gl_format, GLenum &r_gl_internal_format, GLenum &r_gl_type, bool &r_compressed, bool &srgb) {
@@ -1260,6 +1275,10 @@ void RasterizerStorageGLES3::sky_set_texture(RID p_sky, RID p_panorama, int p_ra
glActiveTexture(GL_TEXTURE0);
glBindTexture(texture->target, texture->tex_id);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); //need this for proper sampling
if (config.srgb_decode_supported && texture->srgb && !texture->using_srgb) {
@@ -1275,87 +1294,192 @@ void RasterizerStorageGLES3::sky_set_texture(RID p_sky, RID p_panorama, int p_ra
glActiveTexture(GL_TEXTURE1);
glGenTextures(1, &sky->radiance);
- glBindTexture(GL_TEXTURE_2D, sky->radiance);
- GLuint tmp_fb;
+ if (config.use_texture_array_environment) {
- glGenFramebuffers(1, &tmp_fb);
- glBindFramebuffer(GL_FRAMEBUFFER, tmp_fb);
+ //texture3D
+ glBindTexture(GL_TEXTURE_2D_ARRAY, sky->radiance);
- int size = p_radiance_size;
+ GLuint tmp_fb;
- int lod = 0;
+ glGenFramebuffers(1, &tmp_fb);
+ glBindFramebuffer(GL_FRAMEBUFFER, tmp_fb);
- int mipmaps = 6;
+ int size = p_radiance_size;
- int mm_level = mipmaps;
+ int array_level = 6;
- bool use_float = config.hdr_supported;
+ bool use_float = config.hdr_supported;
- GLenum internal_format = use_float ? GL_RGBA16F : GL_RGB10_A2;
- GLenum format = GL_RGBA;
- GLenum type = use_float ? GL_HALF_FLOAT : GL_UNSIGNED_INT_2_10_10_10_REV;
+ GLenum internal_format = use_float ? GL_RGBA16F : GL_RGB10_A2;
+ GLenum format = GL_RGBA;
+ GLenum type = use_float ? GL_HALF_FLOAT : GL_UNSIGNED_INT_2_10_10_10_REV;
- while (mm_level) {
+ glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, internal_format, size, size * 2, array_level, 0, format, type, NULL);
- glTexImage2D(GL_TEXTURE_2D, lod, internal_format, size, size * 2, 0, format, type, NULL);
- lod++;
- mm_level--;
+ glTexParameterf(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameterf(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- if (size > 1)
- size >>= 1;
- }
+ GLuint tmp_fb2;
+ GLuint tmp_tex;
+ {
+ //generate another one for rendering, as can't read and write from a single texarray it seems
+ glGenFramebuffers(1, &tmp_fb2);
+ glBindFramebuffer(GL_FRAMEBUFFER, tmp_fb2);
+ glGenTextures(1, &tmp_tex);
+ glBindTexture(GL_TEXTURE_2D, tmp_tex);
+ glTexImage2D(GL_TEXTURE_2D, 0, internal_format, size, size * 2, 0, format, type, NULL);
+ glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tmp_tex, 0);
+ glTexParameterf(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameterf(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+#ifdef DEBUG_ENABLED
+ GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
+ ERR_FAIL_COND(status != GL_FRAMEBUFFER_COMPLETE);
+#endif
+ }
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, lod - 1);
+ for (int j = 0; j < array_level; j++) {
- lod = 0;
- mm_level = mipmaps;
+ glBindFramebuffer(GL_FRAMEBUFFER, tmp_fb2);
- size = p_radiance_size;
+ if (j == 0) {
- shaders.cubemap_filter.set_conditional(CubemapFilterShaderGLES3::USE_DUAL_PARABOLOID, true);
- shaders.cubemap_filter.set_conditional(CubemapFilterShaderGLES3::USE_PANORAMA, true);
- shaders.cubemap_filter.bind();
+ shaders.cubemap_filter.set_conditional(CubemapFilterShaderGLES3::USE_DUAL_PARABOLOID, true);
+ shaders.cubemap_filter.set_conditional(CubemapFilterShaderGLES3::USE_SOURCE_PANORAMA, true);
+ shaders.cubemap_filter.set_conditional(CubemapFilterShaderGLES3::USE_DIRECT_WRITE, true);
+ shaders.cubemap_filter.set_conditional(CubemapFilterShaderGLES3::USE_SOURCE_DUAL_PARABOLOID_ARRAY, false);
+ shaders.cubemap_filter.bind();
+ glActiveTexture(GL_TEXTURE0);
+ glBindTexture(texture->target, texture->tex_id);
+ } else {
- while (mm_level) {
+ shaders.cubemap_filter.set_conditional(CubemapFilterShaderGLES3::USE_DUAL_PARABOLOID, true);
+ shaders.cubemap_filter.set_conditional(CubemapFilterShaderGLES3::USE_SOURCE_PANORAMA, false);
+ shaders.cubemap_filter.set_conditional(CubemapFilterShaderGLES3::USE_SOURCE_DUAL_PARABOLOID_ARRAY, true);
+ shaders.cubemap_filter.set_conditional(CubemapFilterShaderGLES3::USE_DIRECT_WRITE, false);
+ shaders.cubemap_filter.bind();
+ glActiveTexture(GL_TEXTURE0);
+ glBindTexture(GL_TEXTURE_2D_ARRAY, sky->radiance);
+ shaders.cubemap_filter.set_uniform(CubemapFilterShaderGLES3::SOURCE_ARRAY_INDEX, j - 1); //read from previous to ensure better blur
+ }
+
+ for (int i = 0; i < 2; i++) {
+ glViewport(0, i * size, size, size);
+ glBindVertexArray(resources.quadie_array);
- glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, sky->radiance, lod);
+ shaders.cubemap_filter.set_uniform(CubemapFilterShaderGLES3::Z_FLIP, i > 0);
+ shaders.cubemap_filter.set_uniform(CubemapFilterShaderGLES3::ROUGHNESS, j / float(array_level - 1));
+
+ glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
+ glBindVertexArray(0);
+ }
+
+ glBindFramebuffer(GL_DRAW_FRAMEBUFFER, tmp_fb);
+ glFramebufferTextureLayer(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, sky->radiance, 0, j);
+ glBindFramebuffer(GL_READ_FRAMEBUFFER, tmp_fb2);
+ glReadBuffer(GL_COLOR_ATTACHMENT0);
+ glBlitFramebuffer(0, 0, size, size * 2, 0, 0, size, size * 2, GL_COLOR_BUFFER_BIT, GL_NEAREST);
+ glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
+ glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
+ }
+
+ shaders.cubemap_filter.set_conditional(CubemapFilterShaderGLES3::USE_SOURCE_PANORAMA, false);
+ shaders.cubemap_filter.set_conditional(CubemapFilterShaderGLES3::USE_DUAL_PARABOLOID, false);
+ shaders.cubemap_filter.set_conditional(CubemapFilterShaderGLES3::USE_SOURCE_DUAL_PARABOLOID_ARRAY, false);
+ shaders.cubemap_filter.set_conditional(CubemapFilterShaderGLES3::USE_DIRECT_WRITE, false);
+
+ //restore ranges
+ glActiveTexture(GL_TEXTURE0);
+ glBindTexture(GL_TEXTURE_2D_ARRAY, sky->radiance);
+
+ glGenerateMipmap(GL_TEXTURE_2D_ARRAY);
+
+ glTexParameterf(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
+ glTexParameterf(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameterf(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameterf(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+
+ glBindFramebuffer(GL_FRAMEBUFFER, RasterizerStorageGLES3::system_fbo);
+ glDeleteFramebuffers(1, &tmp_fb);
+ glDeleteFramebuffers(1, &tmp_fb2);
+ glDeleteTextures(1, &tmp_tex);
+
+ } else {
+ //regular single texture with mipmaps
+ glBindTexture(GL_TEXTURE_2D, sky->radiance);
+
+ GLuint tmp_fb;
+
+ glGenFramebuffers(1, &tmp_fb);
+ glBindFramebuffer(GL_FRAMEBUFFER, tmp_fb);
+
+ int size = p_radiance_size;
+
+ int lod = 0;
+
+ int mipmaps = 6;
+
+ int mm_level = mipmaps;
+
+ bool use_float = config.hdr_supported;
+
+ GLenum internal_format = use_float ? GL_RGBA16F : GL_RGB10_A2;
+ GLenum format = GL_RGBA;
+ GLenum type = use_float ? GL_HALF_FLOAT : GL_UNSIGNED_INT_2_10_10_10_REV;
+
+ glTexStorage2DCustom(GL_TEXTURE_2D, mipmaps, internal_format, size, size * 2.0, format, type);
+
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, mipmaps - 1);
+
+ lod = 0;
+ mm_level = mipmaps;
+
+ size = p_radiance_size;
+
+ shaders.cubemap_filter.set_conditional(CubemapFilterShaderGLES3::USE_DUAL_PARABOLOID, true);
+ shaders.cubemap_filter.set_conditional(CubemapFilterShaderGLES3::USE_SOURCE_PANORAMA, true);
+ shaders.cubemap_filter.bind();
+
+ while (mm_level) {
+
+ glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, sky->radiance, lod);
#ifdef DEBUG_ENABLED
- GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
- ERR_CONTINUE(status != GL_FRAMEBUFFER_COMPLETE);
+ GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
+ ERR_CONTINUE(status != GL_FRAMEBUFFER_COMPLETE);
#endif
- for (int i = 0; i < 2; i++) {
- glViewport(0, i * size, size, size);
- glBindVertexArray(resources.quadie_array);
+ for (int i = 0; i < 2; i++) {
+ glViewport(0, i * size, size, size);
+ glBindVertexArray(resources.quadie_array);
- shaders.cubemap_filter.set_uniform(CubemapFilterShaderGLES3::Z_FLIP, i > 0);
- shaders.cubemap_filter.set_uniform(CubemapFilterShaderGLES3::ROUGHNESS, lod / float(mipmaps - 1));
+ shaders.cubemap_filter.set_uniform(CubemapFilterShaderGLES3::Z_FLIP, i > 0);
+ shaders.cubemap_filter.set_uniform(CubemapFilterShaderGLES3::ROUGHNESS, lod / float(mipmaps - 1));
- glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
- glBindVertexArray(0);
- }
+ glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
+ glBindVertexArray(0);
+ }
- if (size > 1)
- size >>= 1;
- lod++;
- mm_level--;
- }
- shaders.cubemap_filter.set_conditional(CubemapFilterShaderGLES3::USE_DUAL_PARABOLOID, false);
- shaders.cubemap_filter.set_conditional(CubemapFilterShaderGLES3::USE_PANORAMA, false);
+ if (size > 1)
+ size >>= 1;
+ lod++;
+ mm_level--;
+ }
+ shaders.cubemap_filter.set_conditional(CubemapFilterShaderGLES3::USE_DUAL_PARABOLOID, false);
+ shaders.cubemap_filter.set_conditional(CubemapFilterShaderGLES3::USE_SOURCE_PANORAMA, false);
- //restore ranges
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, lod - 1);
+ //restore ranges
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, lod - 1);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- glBindFramebuffer(GL_FRAMEBUFFER, RasterizerStorageGLES3::system_fbo);
- glDeleteFramebuffers(1, &tmp_fb);
+ glBindFramebuffer(GL_FRAMEBUFFER, RasterizerStorageGLES3::system_fbo);
+ glDeleteFramebuffers(1, &tmp_fb);
+ }
}
/* SHADER API */
@@ -1476,6 +1600,7 @@ void RasterizerStorageGLES3::_update_shader(Shader *p_shader) const {
p_shader->spatial.unshaded = false;
p_shader->spatial.ontop = false;
p_shader->spatial.uses_sss = false;
+ p_shader->spatial.uses_vertex_lighting = false;
p_shader->spatial.uses_screen_texture = false;
p_shader->spatial.uses_vertex = false;
p_shader->spatial.writes_modelview_or_projection = false;
@@ -1497,6 +1622,8 @@ void RasterizerStorageGLES3::_update_shader(Shader *p_shader) const {
shaders.actions_scene.render_mode_flags["unshaded"] = &p_shader->spatial.unshaded;
shaders.actions_scene.render_mode_flags["ontop"] = &p_shader->spatial.ontop;
+ shaders.actions_scene.render_mode_flags["vertex_lighting"] = &p_shader->spatial.uses_vertex_lighting;
+
shaders.actions_scene.usage_flag_pointers["ALPHA"] = &p_shader->spatial.uses_alpha;
shaders.actions_scene.usage_flag_pointers["VERTEX"] = &p_shader->spatial.uses_vertex;
@@ -1753,6 +1880,14 @@ void RasterizerStorageGLES3::material_set_line_width(RID p_material, float p_wid
material->line_width = p_width;
}
+void RasterizerStorageGLES3::material_set_next_pass(RID p_material, RID p_next_material) {
+
+ Material *material = material_owner.get(p_material);
+ ERR_FAIL_COND(!material);
+
+ material->next_pass = p_next_material;
+}
+
bool RasterizerStorageGLES3::material_is_animated(RID p_material) {
Material *material = material_owner.get(p_material);
@@ -1761,7 +1896,11 @@ bool RasterizerStorageGLES3::material_is_animated(RID p_material) {
_update_material(material);
}
- return material->is_animated_cache;
+ bool animated = material->is_animated_cache;
+ if (!animated && material->next_pass.is_valid()) {
+ animated = material_is_animated(material->next_pass);
+ }
+ return animated;
}
bool RasterizerStorageGLES3::material_casts_shadows(RID p_material) {
@@ -1771,7 +1910,13 @@ bool RasterizerStorageGLES3::material_casts_shadows(RID p_material) {
_update_material(material);
}
- return material->can_cast_shadow_cache;
+ bool casts_shadows = material->can_cast_shadow_cache;
+
+ if (!casts_shadows && material->next_pass.is_valid()) {
+ casts_shadows = material_casts_shadows(material->next_pass);
+ }
+
+ return casts_shadows;
}
void RasterizerStorageGLES3::material_add_instance_owner(RID p_material, RasterizerScene::InstanceBase *p_instance) {
@@ -4731,6 +4876,7 @@ RID RasterizerStorageGLES3::gi_probe_create() {
gip->energy = 1.0;
gip->propagation = 1.0;
gip->bias = 0.4;
+ gip->normal_bias = 0.4;
gip->interior = false;
gip->compress = false;
gip->version = 1;
@@ -4837,6 +4983,14 @@ void RasterizerStorageGLES3::gi_probe_set_bias(RID p_probe, float p_range) {
gip->bias = p_range;
}
+void RasterizerStorageGLES3::gi_probe_set_normal_bias(RID p_probe, float p_range) {
+
+ GIProbe *gip = gi_probe_owner.getornull(p_probe);
+ ERR_FAIL_COND(!gip);
+
+ gip->normal_bias = p_range;
+}
+
void RasterizerStorageGLES3::gi_probe_set_propagation(RID p_probe, float p_range) {
GIProbe *gip = gi_probe_owner.getornull(p_probe);
@@ -4892,6 +5046,14 @@ float RasterizerStorageGLES3::gi_probe_get_bias(RID p_probe) const {
return gip->bias;
}
+float RasterizerStorageGLES3::gi_probe_get_normal_bias(RID p_probe) const {
+
+ const GIProbe *gip = gi_probe_owner.getornull(p_probe);
+ ERR_FAIL_COND_V(!gip, 0);
+
+ return gip->normal_bias;
+}
+
float RasterizerStorageGLES3::gi_probe_get_propagation(RID p_probe) const {
const GIProbe *gip = gi_probe_owner.getornull(p_probe);
@@ -5666,17 +5828,20 @@ void RasterizerStorageGLES3::_render_target_clear(RenderTarget *rt) {
rt->fbo = 0;
}
- if (rt->buffers.fbo) {
+ if (rt->buffers.active) {
glDeleteFramebuffers(1, &rt->buffers.fbo);
glDeleteRenderbuffers(1, &rt->buffers.depth);
glDeleteRenderbuffers(1, &rt->buffers.diffuse);
- glDeleteRenderbuffers(1, &rt->buffers.specular);
- glDeleteRenderbuffers(1, &rt->buffers.normal_rough);
- glDeleteRenderbuffers(1, &rt->buffers.sss);
- glDeleteFramebuffers(1, &rt->buffers.effect_fbo);
- glDeleteTextures(1, &rt->buffers.effect);
+ if (rt->buffers.effects_active) {
+ glDeleteRenderbuffers(1, &rt->buffers.specular);
+ glDeleteRenderbuffers(1, &rt->buffers.normal_rough);
+ glDeleteRenderbuffers(1, &rt->buffers.sss);
+ glDeleteFramebuffers(1, &rt->buffers.effect_fbo);
+ glDeleteTextures(1, &rt->buffers.effect);
+ }
- rt->buffers.fbo = 0;
+ rt->buffers.effects_active = false;
+ rt->buffers.active = false;
}
if (rt->depth) {
@@ -5714,13 +5879,15 @@ void RasterizerStorageGLES3::_render_target_clear(RenderTarget *rt) {
tex->active = false;
for (int i = 0; i < 2; i++) {
- for (int j = 0; j < rt->effects.mip_maps[i].sizes.size(); j++) {
- glDeleteFramebuffers(1, &rt->effects.mip_maps[i].sizes[j].fbo);
- }
+ if (rt->effects.mip_maps[i].color) {
+ for (int j = 0; j < rt->effects.mip_maps[i].sizes.size(); j++) {
+ glDeleteFramebuffers(1, &rt->effects.mip_maps[i].sizes[j].fbo);
+ }
- glDeleteTextures(1, &rt->effects.mip_maps[i].color);
- rt->effects.mip_maps[i].sizes.clear();
- rt->effects.mip_maps[i].levels = 0;
+ glDeleteTextures(1, &rt->effects.mip_maps[i].color);
+ rt->effects.mip_maps[i].sizes.clear();
+ rt->effects.mip_maps[i].levels = 0;
+ }
}
/*
@@ -5747,10 +5914,20 @@ void RasterizerStorageGLES3::_render_target_allocate(RenderTarget *rt) {
if (!hdr || rt->flags[RENDER_TARGET_NO_3D]) {
- color_internal_format = GL_RGBA8;
- color_format = GL_RGBA;
- color_type = GL_UNSIGNED_BYTE;
- image_format = Image::FORMAT_RGBA8;
+ if (rt->flags[RENDER_TARGET_NO_3D_EFFECTS] && !rt->flags[RENDER_TARGET_TRANSPARENT]) {
+ //if this is not used, linear colorspace looks pretty bad
+ //this is the default mode used for mobile
+ color_internal_format = GL_RGB10_A2;
+ color_format = GL_RGBA;
+ color_type = GL_UNSIGNED_INT_2_10_10_10_REV;
+ image_format = Image::FORMAT_RGBA8;
+ } else {
+
+ color_internal_format = GL_RGBA8;
+ color_format = GL_RGBA;
+ color_type = GL_UNSIGNED_BYTE;
+ image_format = Image::FORMAT_RGBA8;
+ }
} else {
color_internal_format = GL_RGBA16F;
color_format = GL_RGBA;
@@ -5815,11 +5992,20 @@ void RasterizerStorageGLES3::_render_target_allocate(RenderTarget *rt) {
/* BACK FBO */
- if (!rt->flags[RENDER_TARGET_NO_3D]) {
+ if (!rt->flags[RENDER_TARGET_NO_3D] && (!rt->flags[RENDER_TARGET_NO_3D_EFFECTS] || rt->msaa != VS::VIEWPORT_MSAA_DISABLED)) {
+
+ rt->buffers.active = true;
static const int msaa_value[] = { 0, 2, 4, 8, 16 };
int msaa = msaa_value[rt->msaa];
+ int max_samples = 0;
+ glGetIntegerv(GL_MAX_SAMPLES, &max_samples);
+ if (msaa > max_samples) {
+ WARN_PRINTS("MSAA must be <= GL_MAX_SAMPLES, falling-back to GL_MAX_SAMPLES = " + itos(max_samples));
+ msaa = max_samples;
+ }
+
//regular fbo
glGenFramebuffers(1, &rt->buffers.fbo);
glBindFramebuffer(GL_FRAMEBUFFER, rt->buffers.fbo);
@@ -5845,6 +6031,7 @@ void RasterizerStorageGLES3::_render_target_allocate(RenderTarget *rt) {
if (!rt->flags[RENDER_TARGET_NO_3D_EFFECTS]) {
+ rt->buffers.effects_active = true;
glGenRenderbuffers(1, &rt->buffers.specular);
glBindRenderbuffer(GL_RENDERBUFFER, rt->buffers.specular);
@@ -5902,15 +6089,11 @@ void RasterizerStorageGLES3::_render_target_allocate(RenderTarget *rt) {
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
GL_TEXTURE_2D, rt->buffers.effect, 0);
- if (status != GL_FRAMEBUFFER_COMPLETE) {
- printf("err status: %x\n", status);
- _render_target_clear(rt);
- ERR_FAIL_COND(status != GL_FRAMEBUFFER_COMPLETE);
- }
-
+ status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
glBindFramebuffer(GL_FRAMEBUFFER, RasterizerStorageGLES3::system_fbo);
if (status != GL_FRAMEBUFFER_COMPLETE) {
+ printf("err status: %x\n", status);
_render_target_clear(rt);
ERR_FAIL_COND(status != GL_FRAMEBUFFER_COMPLETE);
}
@@ -5988,7 +6171,12 @@ void RasterizerStorageGLES3::_render_target_allocate(RenderTarget *rt) {
_render_target_clear(rt);
ERR_FAIL_COND(status != GL_FRAMEBUFFER_COMPLETE);
}
+ } else {
+ rt->buffers.effects_active = false;
}
+ } else {
+ rt->buffers.active = false;
+ rt->buffers.effects_active = true;
}
if (!rt->flags[RENDER_TARGET_NO_SAMPLING]) {
@@ -6008,12 +6196,12 @@ void RasterizerStorageGLES3::_render_target_allocate(RenderTarget *rt) {
glBindTexture(GL_TEXTURE_2D, rt->effects.mip_maps[i].color);
int level = 0;
+ int fb_w = w;
+ int fb_h = h;
while (true) {
RenderTarget::Effects::MipMaps::Size mm;
-
- glTexImage2D(GL_TEXTURE_2D, level, color_internal_format, w, h, 0, color_format, color_type, NULL);
mm.width = w;
mm.height = h;
rt->effects.mip_maps[i].sizes.push_back(mm);
@@ -6027,8 +6215,15 @@ void RasterizerStorageGLES3::_render_target_allocate(RenderTarget *rt) {
level++;
}
+ glTexStorage2DCustom(GL_TEXTURE_2D, level + 1, color_internal_format, fb_w, fb_h, color_format, color_type);
+
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, level);
+ glDisable(GL_SCISSOR_TEST);
+ glColorMask(1, 1, 1, 1);
+ if (rt->buffers.active == false) {
+ glDepthMask(GL_TRUE);
+ }
for (int j = 0; j < rt->effects.mip_maps[i].sizes.size(); j++) {
@@ -6037,6 +6232,11 @@ void RasterizerStorageGLES3::_render_target_allocate(RenderTarget *rt) {
glGenFramebuffers(1, &mm.fbo);
glBindFramebuffer(GL_FRAMEBUFFER, mm.fbo);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, rt->effects.mip_maps[i].color, j);
+ bool used_depth = false;
+ if (j == 0 && i == 0 && rt->buffers.active == false && !rt->flags[RENDER_TARGET_NO_3D]) { //will use this one for rendering 3D
+ glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, rt->depth, 0);
+ used_depth = true;
+ }
GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
if (status != GL_FRAMEBUFFER_COMPLETE) {
@@ -6045,7 +6245,11 @@ void RasterizerStorageGLES3::_render_target_allocate(RenderTarget *rt) {
}
float zero[4] = { 1, 0, 1, 0 };
+ glViewport(0, 0, rt->effects.mip_maps[i].sizes[j].width, rt->effects.mip_maps[i].sizes[j].height);
glClearBufferfv(GL_COLOR, 0, zero);
+ if (used_depth) {
+ glClearBufferfi(GL_DEPTH_STENCIL, 0, 1.0, 0);
+ }
}
glBindFramebuffer(GL_FRAMEBUFFER, RasterizerStorageGLES3::system_fbo);
@@ -6686,7 +6890,6 @@ void RasterizerStorageGLES3::initialize() {
int max_extensions = 0;
glGetIntegerv(GL_NUM_EXTENSIONS, &max_extensions);
- print_line("GLES3: max extensions: " + itos(max_extensions));
for (int i = 0; i < max_extensions; i++) {
const GLubyte *s = glGetStringi(GL_EXTENSIONS, i);
if (!s)
@@ -6696,8 +6899,8 @@ void RasterizerStorageGLES3::initialize() {
}
config.shrink_textures_x2 = false;
- config.use_fast_texture_filter = int(GlobalConfig::get_singleton()->get("rendering/quality/use_nearest_mipmap_filter"));
- config.use_anisotropic_filter = config.extensions.has("GL_EXT_texture_filter_anisotropic");
+ config.use_fast_texture_filter = int(ProjectSettings::get_singleton()->get("rendering/quality/filters/use_nearest_mipmap_filter"));
+ config.use_anisotropic_filter = config.extensions.has("rendering/quality/filters/anisotropic_filter_level");
config.s3tc_supported = config.extensions.has("GL_EXT_texture_compression_dxt1") || config.extensions.has("GL_EXT_texture_compression_s3tc") || config.extensions.has("WEBGL_compressed_texture_s3tc");
config.etc_supported = config.extensions.has("GL_OES_compressed_ETC1_RGB8_texture");
@@ -6712,7 +6915,6 @@ void RasterizerStorageGLES3::initialize() {
config.hdr_supported = false;
#endif
- print_line("hdr supported: " + itos(config.hdr_supported));
config.pvrtc_supported = config.extensions.has("GL_IMG_texture_compression_pvrtc");
config.srgb_decode_supported = config.extensions.has("GL_EXT_texture_sRGB_decode");
@@ -6720,7 +6922,7 @@ void RasterizerStorageGLES3::initialize() {
config.use_anisotropic_filter = config.extensions.has("GL_EXT_texture_filter_anisotropic");
if (config.use_anisotropic_filter) {
glGetFloatv(_GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &config.anisotropic_level);
- config.anisotropic_level = MIN(int(GlobalConfig::get_singleton()->get("rendering/quality/anisotropic_filter_level")), config.anisotropic_level);
+ config.anisotropic_level = MIN(int(ProjectSettings::get_singleton()->get("rendering/quality/filters/anisotropic_filter_level")), config.anisotropic_level);
}
frame.clear_request = false;
@@ -6831,7 +7033,7 @@ void RasterizerStorageGLES3::initialize() {
{
//transform feedback buffers
- uint32_t xf_feedback_size = GLOBAL_DEF("rendering/buffers/blend_shape_max_buffer_size_kb", 4096);
+ uint32_t xf_feedback_size = GLOBAL_DEF("rendering/limits/buffers/blend_shape_max_buffer_size_kb", 4096);
for (int i = 0; i < 2; i++) {
glGenBuffers(1, &resources.transform_feedback_buffers[i]);
@@ -6845,6 +7047,8 @@ void RasterizerStorageGLES3::initialize() {
}
shaders.cubemap_filter.init();
+ bool ggx_hq = GLOBAL_GET("rendering/quality/reflections/high_quality_ggx.mobile");
+ shaders.cubemap_filter.set_conditional(CubemapFilterShaderGLES3::LOW_QUALITY, !ggx_hq);
shaders.particles.init();
#ifdef GLES_OVER_GL
@@ -6857,6 +7061,29 @@ void RasterizerStorageGLES3::initialize() {
frame.current_rt = NULL;
config.keep_original_textures = false;
config.generate_wireframes = false;
+ config.use_texture_array_environment = GLOBAL_GET("rendering/quality/reflections/texture_array_reflections");
+
+ config.force_vertex_shading = GLOBAL_GET("rendering/quality/shading/force_vertex_shading");
+
+ GLOBAL_DEF("rendering/quality/depth_prepass/disable", false);
+
+ String renderer = (const char *)glGetString(GL_RENDERER);
+
+ config.no_depth_prepass = !bool(GLOBAL_GET("rendering/quality/depth_prepass/enable"));
+ if (!config.no_depth_prepass) {
+
+ String vendors = GLOBAL_GET("rendering/quality/depth_prepass/disable_for_vendors");
+ Vector<String> vendor_match = vendors.split(",");
+ for (int i = 0; i < vendor_match.size(); i++) {
+ String v = vendor_match[i].strip_edges();
+ if (v == String())
+ continue;
+
+ if (renderer.findn(v) != -1) {
+ config.no_depth_prepass = true;
+ }
+ }
+ }
}
void RasterizerStorageGLES3::finalize() {
diff --git a/drivers/gles3/rasterizer_storage_gles3.h b/drivers/gles3/rasterizer_storage_gles3.h
index 3f8055d613..b536c9841c 100644
--- a/drivers/gles3/rasterizer_storage_gles3.h
+++ b/drivers/gles3/rasterizer_storage_gles3.h
@@ -48,6 +48,8 @@ class RasterizerSceneGLES3;
#define _DECODE_EXT 0x8A49
#define _SKIP_DECODE_EXT 0x8A4A
+void glTexStorage2DCustom(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type);
+
class RasterizerStorageGLES3 : public RasterizerStorage {
public:
RasterizerCanvasGLES3 *canvas;
@@ -86,9 +88,14 @@ public:
bool generate_wireframes;
+ bool use_texture_array_environment;
+
Set<String> extensions;
bool keep_original_textures;
+
+ bool no_depth_prepass;
+ bool force_vertex_shading;
} config;
mutable struct Shaders {
@@ -442,6 +449,7 @@ public:
bool uses_sss;
bool uses_screen_texture;
bool writes_modelview_or_projection;
+ bool uses_vertex_lighting;
} spatial;
@@ -494,6 +502,8 @@ public:
Vector<RID> textures;
float line_width;
+ RID next_pass;
+
uint32_t index;
uint64_t last_pass;
@@ -531,6 +541,7 @@ public:
virtual Variant material_get_param(RID p_material, const StringName &p_param) const;
virtual void material_set_line_width(RID p_material, float p_width);
+ virtual void material_set_next_pass(RID p_material, RID p_next_material);
virtual bool material_is_animated(RID p_material);
virtual bool material_casts_shadows(RID p_material);
@@ -967,6 +978,7 @@ public:
int dynamic_range;
float energy;
float bias;
+ float normal_bias;
float propagation;
bool interior;
bool compress;
@@ -1001,6 +1013,9 @@ public:
virtual void gi_probe_set_bias(RID p_probe, float p_range);
virtual float gi_probe_get_bias(RID p_probe) const;
+ virtual void gi_probe_set_normal_bias(RID p_probe, float p_range);
+ virtual float gi_probe_get_normal_bias(RID p_probe) const;
+
virtual void gi_probe_set_propagation(RID p_probe, float p_range);
virtual float gi_probe_get_propagation(RID p_probe) const;
@@ -1184,6 +1199,9 @@ public:
GLuint depth;
struct Buffers {
+
+ bool active;
+ bool effects_active;
GLuint fbo;
GLuint depth;
GLuint specular;
@@ -1267,13 +1285,14 @@ public:
buffers.fbo = 0;
used_in_frame = false;
- flags[RENDER_TARGET_VFLIP] = false;
- flags[RENDER_TARGET_TRANSPARENT] = false;
- flags[RENDER_TARGET_NO_3D_EFFECTS] = false;
- flags[RENDER_TARGET_NO_3D] = false;
- flags[RENDER_TARGET_NO_SAMPLING] = false;
+ for (int i = 0; i < RENDER_TARGET_FLAG_MAX; i++) {
+ flags[i] = false;
+ }
flags[RENDER_TARGET_HDR] = true;
+ buffers.active = false;
+ buffers.effects_active = false;
+
last_exposure_tick = 0;
}
};
diff --git a/drivers/gles3/shader_compiler_gles3.cpp b/drivers/gles3/shader_compiler_gles3.cpp
index 6c568714f8..206f270f68 100644
--- a/drivers/gles3/shader_compiler_gles3.cpp
+++ b/drivers/gles3/shader_compiler_gles3.cpp
@@ -304,6 +304,7 @@ String ShaderCompilerGLES3::_dump_node_code(SL::Node *p_node, int p_level, Gener
uniform_sizes.resize(max_uniforms);
uniform_alignments.resize(max_uniforms);
uniform_defines.resize(max_uniforms);
+ bool uses_uniforms = false;
for (Map<StringName, SL::ShaderNode::Uniform>::Element *E = pnode->uniforms.front(); E; E = E->next()) {
@@ -323,9 +324,10 @@ String ShaderCompilerGLES3::_dump_node_code(SL::Node *p_node, int p_level, Gener
r_gen_code.texture_uniforms[E->get().texture_order] = _mkid(E->key());
r_gen_code.texture_hints[E->get().texture_order] = E->get().hint;
} else {
- if (r_gen_code.uniforms.empty()) {
+ if (!uses_uniforms) {
r_gen_code.defines.push_back(String("#define USE_MATERIAL\n").ascii());
+ uses_uniforms = true;
}
uniform_defines[E->get().order] = ucode;
uniform_sizes[E->get().order] = _get_datatype_size(E->get().type);
@@ -651,6 +653,14 @@ Error ShaderCompilerGLES3::compile(VS::ShaderMode p_mode, const String &p_code,
_dump_node_code(parser.get_shader(), 1, r_gen_code, *p_actions, actions[p_mode]);
+ if (r_gen_code.uniform_total_size) { //uniforms used?
+ int md = sizeof(float) * 4;
+ if (r_gen_code.uniform_total_size % md) {
+ r_gen_code.uniform_total_size += md - (r_gen_code.uniform_total_size % md);
+ }
+ r_gen_code.uniform_total_size += md; //pad just in case
+ }
+
return OK;
}
@@ -700,7 +710,7 @@ ShaderCompilerGLES3::ShaderCompilerGLES3() {
actions[VS::SHADER_CANVAS_ITEM].usage_defines["NORMALMAP"] = "#define NORMALMAP_USED\n";
actions[VS::SHADER_CANVAS_ITEM].usage_defines["SHADOW_COLOR"] = "#define SHADOW_COLOR_USED\n";
- actions[VS::SHADER_CANVAS_ITEM].render_mode_defines["skip_transform"] = "#define SKIP_TRANSFORM_USED\n";
+ actions[VS::SHADER_CANVAS_ITEM].render_mode_defines["skip_vertex_transform"] = "#define SKIP_TRANSFORM_USED\n";
/** SPATIAL SHADER **/
@@ -775,11 +785,18 @@ ShaderCompilerGLES3::ShaderCompilerGLES3() {
actions[VS::SHADER_SPATIAL].renames["SSS_STRENGTH"] = "sss_strength";
- actions[VS::SHADER_SPATIAL].render_mode_defines["skip_default_transform"] = "#define SKIP_TRANSFORM_USED\n";
+ actions[VS::SHADER_SPATIAL].render_mode_defines["skip_vertex_transform"] = "#define SKIP_TRANSFORM_USED\n";
+ actions[VS::SHADER_SPATIAL].render_mode_defines["world_vertex_coords"] = "#define VERTEX_WORLD_COORDS_USED\n";
actions[VS::SHADER_SPATIAL].render_mode_defines["diffuse_burley"] = "#define DIFFUSE_BURLEY\n";
actions[VS::SHADER_SPATIAL].render_mode_defines["diffuse_oren_nayar"] = "#define DIFFUSE_OREN_NAYAR\n";
actions[VS::SHADER_SPATIAL].render_mode_defines["diffuse_half_lambert"] = "#define DIFFUSE_HALF_LAMBERT\n";
+ actions[VS::SHADER_SPATIAL].render_mode_defines["diffuse_toon"] = "#define DIFFUSE_TOON\n";
+
+ actions[VS::SHADER_SPATIAL].render_mode_defines["specular_blinn"] = "#define SPECULAR_BLINN\n";
+ actions[VS::SHADER_SPATIAL].render_mode_defines["specular_phong"] = "#define SPECULAR_PHONG\n";
+ actions[VS::SHADER_SPATIAL].render_mode_defines["specular_toon"] = "#define SPECULAR_TOON\n";
+ actions[VS::SHADER_SPATIAL].render_mode_defines["specular_disabled"] = "#define SPECULAR_DISABLED\n";
/* PARTICLES SHADER */
diff --git a/drivers/gles3/shader_gles3.cpp b/drivers/gles3/shader_gles3.cpp
index c821acadf5..f1077e2d20 100644
--- a/drivers/gles3/shader_gles3.cpp
+++ b/drivers/gles3/shader_gles3.cpp
@@ -208,6 +208,7 @@ ShaderGLES3::Version *ShaderGLES3::get_current_version() {
Vector<const char *> strings;
#ifdef GLES_OVER_GL
strings.push_back("#version 330\n");
+ strings.push_back("#define GLES_OVER_GL\n");
#else
strings.push_back("#version 300 es\n");
#endif
@@ -416,7 +417,8 @@ ShaderGLES3::Version *ShaderGLES3::get_current_version() {
strings.push_back(fragment_code4.get_data());
#ifdef DEBUG_SHADER
- DEBUG_PRINT("\nFragment Code:\n\n" + String(code_string.get_data()));
+ DEBUG_PRINT("\nFragment Globals:\n\n" + String(code_globals.get_data()));
+ DEBUG_PRINT("\nFragment Code:\n\n" + String(code_string2.get_data()));
for (int i = 0; i < strings.size(); i++) {
//print_line("frag strings "+itos(i)+":"+String(strings[i]));
diff --git a/drivers/gles3/shaders/copy.glsl b/drivers/gles3/shaders/copy.glsl
index a7c388815d..d33193ee50 100644
--- a/drivers/gles3/shaders/copy.glsl
+++ b/drivers/gles3/shaders/copy.glsl
@@ -49,6 +49,9 @@ void main() {
#define M_PI 3.14159265359
+#if !defined(USE_GLES_OVER_GL)
+precision mediump float;
+#endif
#if defined(USE_CUBEMAP) || defined(USE_PANORAMA)
in vec3 cube_interp;
@@ -87,14 +90,6 @@ vec4 texturePanorama(vec3 normal,sampler2D pano ) {
#endif
-float sRGB_gamma_correct(float c){
- float a = 0.055;
- if(c < 0.0031308)
- return 12.92*c;
- else
- return (1.0+a)*pow(c, 1.0/2.4) - a;
-}
-
uniform float stuff;
uniform vec2 pixel_size;
@@ -131,7 +126,7 @@ void main() {
vec4 color = texture( source_cube, normalize(cube_interp) );
#else
- vec4 color = texture( source, uv_interp );
+ vec4 color = textureLod( source, uv_interp,0.0 );
#endif
diff --git a/drivers/gles3/shaders/cubemap_filter.glsl b/drivers/gles3/shaders/cubemap_filter.glsl
index 2aec6380f5..485fbb6ee0 100644
--- a/drivers/gles3/shaders/cubemap_filter.glsl
+++ b/drivers/gles3/shaders/cubemap_filter.glsl
@@ -19,9 +19,16 @@ void main() {
precision highp float;
precision highp int;
-#ifdef USE_PANORAMA
+#ifdef USE_SOURCE_PANORAMA
uniform sampler2D source_panorama; //texunit:0
-#else
+#endif
+
+#ifdef USE_SOURCE_DUAL_PARABOLOID_ARRAY
+uniform sampler2DArray source_dual_paraboloid_array; //texunit:0
+uniform int source_array_index;
+#endif
+
+#if !defined(USE_SOURCE_DUAL_PARABOLOID_ARRAY) && !defined(USE_SOURCE_PANORAMA)
uniform samplerCube source_cube; //texunit:0
#endif
@@ -169,7 +176,7 @@ vec2 Hammersley(uint i, uint N) {
uniform bool z_flip;
-#ifdef USE_PANORAMA
+#ifdef USE_SOURCE_PANORAMA
vec4 texturePanorama(vec3 normal,sampler2D pano ) {
@@ -189,6 +196,23 @@ vec4 texturePanorama(vec3 normal,sampler2D pano ) {
#endif
+#ifdef USE_SOURCE_DUAL_PARABOLOID_ARRAY
+
+
+vec4 textureDualParaboloidArray(vec3 normal) {
+
+ vec3 norm = normalize(normal);
+ norm.xy/=1.0+abs(norm.z);
+ norm.xy=norm.xy * vec2(0.5,0.25) + vec2(0.5,0.25);
+ if (norm.z<0.0) {
+ norm.y=0.5-norm.y+0.5;
+ }
+ return textureLod(source_dual_paraboloid_array, vec3(norm.xy, float(source_array_index) ), 0.0);
+
+}
+
+#endif
+
void main() {
#ifdef USE_DUAL_PARABOLOID
@@ -197,9 +221,8 @@ void main() {
N.z = 0.5 - 0.5*((N.x * N.x) + (N.y * N.y));
N = normalize(N);
- if (!z_flip) {
+ if (z_flip) {
N.y=-N.y; //y is flipped to improve blending between both sides
- } else {
N.z=-N.z;
}
@@ -212,13 +235,25 @@ void main() {
#ifdef USE_DIRECT_WRITE
-#ifdef USE_PANORAMA
+#ifdef USE_SOURCE_PANORAMA
frag_color=vec4(texturePanorama(N,source_panorama).rgb,1.0);
-#else
+#endif
+
+#ifdef USE_SOURCE_DUAL_PARABOLOID_ARRAY
+
+ frag_color=vec4(textureDualParaboloidArray(N).rgb,1.0);
+#endif
+
+#if !defined(USE_SOURCE_DUAL_PARABOLOID_ARRAY) && !defined(USE_SOURCE_PANORAMA)
+
+ N.y=-N.y;
frag_color=vec4(texture(N,source_cube).rgb,1.0);
#endif
+
+
+
#else
vec4 sum = vec4(0.0, 0.0, 0.0, 0.0);
@@ -233,9 +268,17 @@ void main() {
float ndotl = clamp(dot(N, L),0.0,1.0);
if (ndotl>0.0) {
-#ifdef USE_PANORAMA
+#ifdef USE_SOURCE_PANORAMA
sum.rgb += texturePanorama(H,source_panorama).rgb *ndotl;
-#else
+#endif
+
+#ifdef USE_SOURCE_DUAL_PARABOLOID_ARRAY
+
+ sum.rgb += textureDualParaboloidArray(H).rgb *ndotl;
+#endif
+
+#if !defined(USE_SOURCE_DUAL_PARABOLOID_ARRAY) && !defined(USE_SOURCE_PANORAMA)
+ H.y=-H.y;
sum.rgb += textureLod(source_cube, H, 0.0).rgb *ndotl;
#endif
sum.a += ndotl;
diff --git a/drivers/gles3/shaders/effect_blur.glsl b/drivers/gles3/shaders/effect_blur.glsl
index 8ca8e21f11..09e522866c 100644
--- a/drivers/gles3/shaders/effect_blur.glsl
+++ b/drivers/gles3/shaders/effect_blur.glsl
@@ -14,7 +14,7 @@ uniform vec4 blur_section;
void main() {
- uv_interp = uv_in;
+ uv_interp = uv_in;
gl_Position = vertex_attrib;
#ifdef USE_BLUR_SECTION
@@ -25,6 +25,9 @@ void main() {
[fragment]
+#if !defined(GLES_OVER_GL)
+precision mediump float;
+#endif
in vec2 uv_interp;
uniform sampler2D source_color; //texunit:0
@@ -99,7 +102,7 @@ uniform highp float auto_exposure_grey;
#endif
uniform float glow_bloom;
-uniform float glow_hdr_treshold;
+uniform float glow_hdr_threshold;
uniform float glow_hdr_scale;
#endif
@@ -262,7 +265,7 @@ void main() {
frag_color*=exposure;
float luminance = max(frag_color.r,max(frag_color.g,frag_color.b));
- float feedback = max( smoothstep(glow_hdr_treshold,glow_hdr_treshold+glow_hdr_scale,luminance), glow_bloom );
+ float feedback = max( smoothstep(glow_hdr_threshold,glow_hdr_threshold+glow_hdr_scale,luminance), glow_bloom );
frag_color *= feedback;
@@ -285,4 +288,3 @@ void main() {
}
-
diff --git a/drivers/gles3/shaders/particles.glsl b/drivers/gles3/shaders/particles.glsl
index 6a977a201e..a62c124dfe 100644
--- a/drivers/gles3/shaders/particles.glsl
+++ b/drivers/gles3/shaders/particles.glsl
@@ -178,7 +178,7 @@ VERTEX_SHADER_CODE
#if !defined(DISABLE_FORCE)
- if (true) {
+ if (false) {
vec3 force = vec3(0.0);
for(int i=0;i<attractor_count;i++) {
@@ -187,7 +187,7 @@ VERTEX_SHADER_CODE
float dist = length(rel_vec);
if (attractors[i].radius < dist)
continue;
- if (attractors[i].eat_radius>0 && attractors[i].eat_radius > dist) {
+ if (attractors[i].eat_radius>0.0 && attractors[i].eat_radius > dist) {
out_velocity_active.a=0.0;
}
diff --git a/drivers/gles3/shaders/resolve.glsl b/drivers/gles3/shaders/resolve.glsl
index 181a3c99ec..0b50a9c57b 100644
--- a/drivers/gles3/shaders/resolve.glsl
+++ b/drivers/gles3/shaders/resolve.glsl
@@ -15,6 +15,9 @@ void main() {
[fragment]
+#if !defined(GLES_OVER_GL)
+precision mediump float;
+#endif
in vec2 uv_interp;
uniform sampler2D source_specular; //texunit:0
diff --git a/drivers/gles3/shaders/scene.glsl b/drivers/gles3/shaders/scene.glsl
index 40a295bc83..340a1f24d2 100644
--- a/drivers/gles3/shaders/scene.glsl
+++ b/drivers/gles3/shaders/scene.glsl
@@ -64,44 +64,45 @@ layout(std140) uniform SceneData { //ubo:0
highp mat4 camera_inverse_matrix;
highp mat4 camera_matrix;
- highp vec4 ambient_light_color;
- highp vec4 bg_color;
+ mediump vec4 ambient_light_color;
+ mediump vec4 bg_color;
- vec4 fog_color_enabled;
- vec4 fog_sun_color_amount;
+ mediump vec4 fog_color_enabled;
+ mediump vec4 fog_sun_color_amount;
- float ambient_energy;
- float bg_energy;
+ mediump float ambient_energy;
+ mediump float bg_energy;
- float z_offset;
- float z_slope_scale;
- float shadow_dual_paraboloid_render_zfar;
- float shadow_dual_paraboloid_render_side;
+ mediump float z_offset;
+ mediump float z_slope_scale;
+ highp float shadow_dual_paraboloid_render_zfar;
+ highp float shadow_dual_paraboloid_render_side;
highp vec2 screen_pixel_size;
- vec2 shadow_atlas_pixel_size;
- vec2 directional_shadow_pixel_size;
+ highp vec2 shadow_atlas_pixel_size;
+ highp vec2 directional_shadow_pixel_size;
- float time;
- float z_far;
- float reflection_multiplier;
- float subsurface_scatter_width;
- float ambient_occlusion_affect_light;
+ highp float time;
+ highp float z_far;
+ mediump float reflection_multiplier;
+ mediump float subsurface_scatter_width;
+ mediump float ambient_occlusion_affect_light;
bool fog_depth_enabled;
- float fog_depth_begin;
- float fog_depth_curve;
+ highp float fog_depth_begin;
+ highp float fog_depth_curve;
bool fog_transmit_enabled;
- float fog_transmit_curve;
+ highp float fog_transmit_curve;
bool fog_height_enabled;
- float fog_height_min;
- float fog_height_max;
- float fog_height_curve;
+ highp float fog_height_min;
+ highp float fog_height_max;
+ highp float fog_height_curve;
};
uniform highp mat4 world_transform;
+
#ifdef USE_LIGHT_DIRECTIONAL
layout(std140) uniform DirectionalLightData { //ubo:3
@@ -121,6 +122,90 @@ layout(std140) uniform DirectionalLightData { //ubo:3
#endif
+#ifdef USE_VERTEX_LIGHTING
+//omni and spot
+
+struct LightData {
+
+ highp vec4 light_pos_inv_radius;
+ mediump vec4 light_direction_attenuation;
+ mediump vec4 light_color_energy;
+ mediump vec4 light_params; //cone attenuation, angle, specular, shadow enabled,
+ mediump vec4 light_clamp;
+ mediump vec4 shadow_color_contact;
+ highp mat4 shadow_matrix;
+
+};
+
+
+layout(std140) uniform OmniLightData { //ubo:4
+
+ LightData omni_lights[MAX_LIGHT_DATA_STRUCTS];
+};
+
+layout(std140) uniform SpotLightData { //ubo:5
+
+ LightData spot_lights[MAX_LIGHT_DATA_STRUCTS];
+};
+
+#ifdef USE_FORWARD_LIGHTING
+
+
+uniform int omni_light_indices[MAX_FORWARD_LIGHTS];
+uniform int omni_light_count;
+
+uniform int spot_light_indices[MAX_FORWARD_LIGHTS];
+uniform int spot_light_count;
+
+#endif
+
+out vec4 diffuse_light_interp;
+out vec4 specular_light_interp;
+
+void light_compute(vec3 N, vec3 L,vec3 V, vec3 light_color,float roughness,inout vec3 diffuse, inout vec3 specular) {
+
+ float dotNL = max(dot(N,L), 0.0 );
+ diffuse += dotNL * light_color;
+
+ if (roughness > 0.0) {
+
+ vec3 H = normalize(V + L);
+ float dotNH = max(dot(N,H), 0.0 );
+ float intensity = pow( dotNH, (1.0-roughness) * 256.0);
+ specular += light_color * intensity;
+
+ }
+}
+
+void light_process_omni(int idx, vec3 vertex, vec3 eye_vec,vec3 normal, float roughness,inout vec3 diffuse, inout vec3 specular) {
+
+ vec3 light_rel_vec = omni_lights[idx].light_pos_inv_radius.xyz-vertex;
+ float light_length = length( light_rel_vec );
+ float normalized_distance = light_length*omni_lights[idx].light_pos_inv_radius.w;
+ vec3 light_attenuation = vec3(pow( max(1.0 - normalized_distance, 0.0), omni_lights[idx].light_direction_attenuation.w ));
+
+ light_compute(normal,normalize(light_rel_vec),eye_vec,omni_lights[idx].light_color_energy.rgb * light_attenuation,roughness,diffuse,specular);
+
+}
+
+void light_process_spot(int idx, vec3 vertex, vec3 eye_vec, vec3 normal, float roughness, inout vec3 diffuse, inout vec3 specular) {
+
+ vec3 light_rel_vec = spot_lights[idx].light_pos_inv_radius.xyz-vertex;
+ float light_length = length( light_rel_vec );
+ float normalized_distance = light_length*spot_lights[idx].light_pos_inv_radius.w;
+ vec3 light_attenuation = vec3(pow( max(1.0 - normalized_distance, 0.001), spot_lights[idx].light_direction_attenuation.w ));
+ vec3 spot_dir = spot_lights[idx].light_direction_attenuation.xyz;
+ float spot_cutoff=spot_lights[idx].light_params.y;
+ float scos = max(dot(-normalize(light_rel_vec), spot_dir),spot_cutoff);
+ float spot_rim = (1.0 - scos) / (1.0 - spot_cutoff);
+ light_attenuation *= 1.0 - pow( max(spot_rim,0.001), spot_lights[idx].light_params.x);
+
+
+ light_compute(normal,normalize(light_rel_vec),eye_vec,spot_lights[idx].light_color_energy.rgb*light_attenuation,roughness,diffuse,specular);
+}
+
+
+#endif
/* Varyings */
@@ -275,6 +360,21 @@ void main() {
highp mat4 modelview = camera_inverse_matrix * world_matrix;
highp mat4 local_projection = projection_matrix;
+//using world coordinates
+#if !defined(SKIP_TRANSFORM_USED) && defined(VERTEX_WORLD_COORDS_USED)
+
+ vertex = world_matrix * vertex;
+ normal = normalize((world_matrix * vec4(normal,0.0)).xyz);
+
+#if defined(ENABLE_TANGENT_INTERP) || defined(ENABLE_NORMALMAP) || defined(LIGHT_USE_ANISOTROPY)
+
+ tangent = normalize((world_matrix * vec4(tangent,0.0)).xyz);
+ binormal = normalize((world_matrix * vec4(binormal,0.0)).xyz);
+#endif
+#endif
+
+ float roughness=0.0;
+
//defines that make writing custom shaders easier
#define projection_matrix local_projection
#define world_transform world_matrix
@@ -286,29 +386,42 @@ VERTEX_SHADER_CODE
-
-#if !defined(SKIP_TRANSFORM_USED)
+//using local coordinates (default)
+#if !defined(SKIP_TRANSFORM_USED) && !defined(VERTEX_WORLD_COORDS_USED)
vertex = modelview * vertex;
normal = normalize((modelview * vec4(normal,0.0)).xyz);
+
+#if defined(ENABLE_TANGENT_INTERP) || defined(ENABLE_NORMALMAP) || defined(LIGHT_USE_ANISOTROPY)
+
+ tangent = normalize((modelview * vec4(tangent,0.0)).xyz);
+ binormal = normalize((modelview * vec4(binormal,0.0)).xyz);
+#endif
#endif
+//using world coordinates
+#if !defined(SKIP_TRANSFORM_USED) && defined(VERTEX_WORLD_COORDS_USED)
- vertex_interp = vertex.xyz;
- normal_interp = normal;
+ vertex = camera_inverse_matrix * vertex;
+ normal = normalize((camera_inverse_matrix * vec4(normal,0.0)).xyz);
#if defined(ENABLE_TANGENT_INTERP) || defined(ENABLE_NORMALMAP) || defined(LIGHT_USE_ANISOTROPY)
-#if !defined(SKIP_TRANSFORM_USED)
+ tangent = normalize((camera_inverse_matrix * vec4(tangent,0.0)).xyz);
+ binormal = normalize((camera_inverse_matrix * vec4(binormal,0.0)).xyz);
+#endif
+#endif
- tangent = normalize((modelview * vec4(tangent,0.0)).xyz);
- binormal = normalize((modelview * vec4(binormal,0.0)).xyz);
+ vertex_interp = vertex.xyz;
+ normal_interp = normal;
-#endif
+
+#if defined(ENABLE_TANGENT_INTERP) || defined(ENABLE_NORMALMAP) || defined(LIGHT_USE_ANISOTROPY)
tangent_interp = tangent;
binormal_interp = binormal;
#endif
+
#ifdef RENDER_DEPTH
@@ -350,6 +463,54 @@ VERTEX_SHADER_CODE
#endif
position_interp=gl_Position;
+
+#ifdef USE_VERTEX_LIGHTING
+
+ diffuse_light_interp=vec4(0.0);
+ specular_light_interp=vec4(0.0);
+
+#ifdef USE_FORWARD_LIGHTING
+
+ for(int i=0;i<omni_light_count;i++) {
+ light_process_omni(omni_light_indices[i],vertex_interp,-normalize( vertex_interp ),normal_interp,roughness,diffuse_light_interp.rgb,specular_light_interp.rgb);
+ }
+
+ for(int i=0;i<spot_light_count;i++) {
+ light_process_spot(spot_light_indices[i],vertex_interp,-normalize( vertex_interp ),normal_interp,roughness,diffuse_light_interp.rgb,specular_light_interp.rgb);
+ }
+#endif
+
+#ifdef USE_LIGHT_DIRECTIONAL
+
+ vec3 directional_diffuse = vec3(0.0);
+ vec3 directional_specular = vec3(0.0);
+ light_compute(normal_interp,-light_direction_attenuation.xyz,-normalize( vertex_interp ),normal_interp,roughness,directional_diffuse,directional_specular);
+
+ float diff_avg = dot(diffuse_light_interp.rgb,vec3(0.33333));
+ float diff_dir_avg = dot(directional_diffuse,vec3(0.33333));
+ if (diff_avg>0.0) {
+ diffuse_light_interp.a=diff_dir_avg/(diff_avg+diff_dir_avg);
+ } else {
+ diffuse_light_interp.a=1.0;
+ }
+
+ diffuse_light_interp.rgb+=directional_diffuse;
+
+ float spec_avg = dot(specular_light_interp.rgb,vec3(0.33333));
+ float spec_dir_avg = dot(directional_specular,vec3(0.33333));
+ if (spec_avg>0.0) {
+ specular_light_interp.a=spec_dir_avg/(spec_avg+spec_dir_avg);
+ } else {
+ specular_light_interp.a=1.0;
+ }
+
+ specular_light_interp.rgb+=directional_specular;
+
+#endif //USE_LIGHT_DIRECTIONAL
+
+
+#endif // USE_VERTEX_LIGHTING
+
}
@@ -405,7 +566,6 @@ uniform bool no_ambient_light;
#ifdef USE_RADIANCE_MAP
-uniform sampler2D radiance_map; //texunit:-2
layout(std140) uniform Radiance { //ubo:2
@@ -415,6 +575,53 @@ layout(std140) uniform Radiance { //ubo:2
};
+#define RADIANCE_MAX_LOD 5.0
+
+#ifdef USE_RADIANCE_MAP_ARRAY
+
+uniform sampler2DArray radiance_map; //texunit:-2
+
+vec3 textureDualParaboloid(sampler2DArray p_tex, vec3 p_vec,float p_roughness) {
+
+ vec3 norm = normalize(p_vec);
+ norm.xy/=1.0+abs(norm.z);
+ norm.xy=norm.xy * vec2(0.5,0.25) + vec2(0.5,0.25);
+
+ // we need to lie the derivatives (normg) and assume that DP side is always the same
+ // to get proper texure filtering
+ vec2 normg=norm.xy;
+ if (norm.z>0.0) {
+ norm.y=0.5-norm.y+0.5;
+ }
+
+ // thanks to OpenGL spec using floor(layer + 0.5) for texture arrays,
+ // it's easy to have precision errors using fract() to interpolate layers
+ // as such, using fixed point to ensure it works.
+
+ float index = p_roughness * RADIANCE_MAX_LOD;
+ int indexi = int(index * 256.0);
+ vec3 base = textureGrad(p_tex, vec3(norm.xy, float(indexi/256)),dFdx(normg),dFdy(normg)).xyz;
+ vec3 next = textureGrad(p_tex, vec3(norm.xy, float(indexi/256+1)),dFdx(normg),dFdy(normg)).xyz;
+ return mix(base,next,float(indexi%256)/256.0);
+}
+
+#else
+
+uniform sampler2D radiance_map; //texunit:-2
+
+vec3 textureDualParaboloid(sampler2D p_tex, vec3 p_vec,float p_roughness) {
+
+ vec3 norm = normalize(p_vec);
+ norm.xy/=1.0+abs(norm.z);
+ norm.xy=norm.xy * vec2(0.5,0.25) + vec2(0.5,0.25);
+ if (norm.z>0.0) {
+ norm.y=0.5-norm.y+0.5;
+ }
+ return textureLod(p_tex, norm.xy, p_roughness * RADIANCE_MAX_LOD).xyz;
+}
+
+#endif
+
#endif
/* Material Uniforms */
@@ -439,39 +646,39 @@ layout(std140) uniform SceneData {
highp mat4 camera_inverse_matrix;
highp mat4 camera_matrix;
- highp vec4 ambient_light_color;
- highp vec4 bg_color;
+ mediump vec4 ambient_light_color;
+ mediump vec4 bg_color;
- vec4 fog_color_enabled;
- vec4 fog_sun_color_amount;
+ mediump vec4 fog_color_enabled;
+ mediump vec4 fog_sun_color_amount;
- float ambient_energy;
- float bg_energy;
+ mediump float ambient_energy;
+ mediump float bg_energy;
- float z_offset;
- float z_slope_scale;
- float shadow_dual_paraboloid_render_zfar;
- float shadow_dual_paraboloid_render_side;
+ mediump float z_offset;
+ mediump float z_slope_scale;
+ highp float shadow_dual_paraboloid_render_zfar;
+ highp float shadow_dual_paraboloid_render_side;
highp vec2 screen_pixel_size;
- vec2 shadow_atlas_pixel_size;
- vec2 directional_shadow_pixel_size;
+ highp vec2 shadow_atlas_pixel_size;
+ highp vec2 directional_shadow_pixel_size;
- float time;
- float z_far;
- float reflection_multiplier;
- float subsurface_scatter_width;
- float ambient_occlusion_affect_light;
+ highp float time;
+ highp float z_far;
+ mediump float reflection_multiplier;
+ mediump float subsurface_scatter_width;
+ mediump float ambient_occlusion_affect_light;
bool fog_depth_enabled;
- float fog_depth_begin;
- float fog_depth_curve;
+ highp float fog_depth_begin;
+ highp float fog_depth_curve;
bool fog_transmit_enabled;
- float fog_transmit_curve;
+ highp float fog_transmit_curve;
bool fog_height_enabled;
- float fog_height_min;
- float fog_height_max;
- float fog_height_curve;
+ highp float fog_height_min;
+ highp float fog_height_max;
+ highp float fog_height_curve;
};
//directional light data
@@ -498,6 +705,10 @@ uniform highp sampler2DShadow directional_shadow; //texunit:-4
#endif
+#ifdef USE_VERTEX_LIGHTING
+in vec4 diffuse_light_interp;
+in vec4 specular_light_interp;
+#endif
//omni and spot
struct LightData {
@@ -583,6 +794,8 @@ layout(location=0) out vec4 frag_color;
in highp vec4 position_interp;
uniform highp sampler2D depth_buffer; //texunit:-8
+#ifdef USE_CONTACT_SHADOWS
+
float contact_shadow_compute(vec3 pos, vec3 dir, float max_distance) {
if (abs(dir.z)>0.99)
@@ -597,6 +810,9 @@ float contact_shadow_compute(vec3 pos, vec3 dir, float max_distance) {
vec2 screen_rel = to_screen - from_screen;
+ if (length(screen_rel)<0.00001)
+ return 1.0; //too small, don't do anything
+
/*float pixel_size; //approximate pixel size
if (screen_rel.x > screen_rel.y) {
@@ -612,15 +828,16 @@ float contact_shadow_compute(vec3 pos, vec3 dir, float max_distance) {
vec2 pixel_incr = normalize(screen_rel)*screen_pixel_size;
- float steps = length(screen_rel) / length(pixel_incr);
+ float steps = length(screen_rel) / length(pixel_incr);
+ steps = min(2000.0,steps); //put a limit to avoid freezing in some strange situation
//steps=10.0;
vec4 incr = (dest - source)/steps;
float ratio=0.0;
float ratio_incr = 1.0/steps;
- do {
+ while(steps>0.0) {
source += incr*2.0;
bias+=incr*2.0;
@@ -638,11 +855,13 @@ float contact_shadow_compute(vec3 pos, vec3 dir, float max_distance) {
ratio+=ratio_incr;
steps-=1.0;
- } while (steps>0.0);
+ }
return 1.0;
}
+#endif
+
// GGX Specular
// Source: http://www.filmicworlds.com/images/ggx-opt/optimized-ggx.hlsl
float G1V(float dotNV, float k)
@@ -703,6 +922,10 @@ LIGHT_SHADER_CODE
diffuse += diffuse_color * max(0.0, NdotL) * (A + vec3(B) * s / t) / M_PI;
}
+#elif defined(DIFFUSE_TOON)
+
+ diffuse += smoothstep(-roughness,max(roughness,0.01),dot(N,L)) * light_color * diffuse_color;
+
#elif defined(DIFFUSE_BURLEY)
{
@@ -733,6 +956,37 @@ LIGHT_SHADER_CODE
if (roughness > 0.0) {
+
+ // D
+
+#if defined(SPECULAR_BLINN)
+
+ vec3 H = normalize(V + L);
+ float dotNH = max(dot(N,H), 0.0 );
+ float intensity = pow( dotNH, (1.0-roughness) * 256.0);
+ specular += light_color * intensity * specular_blob_intensity;
+
+#elif defined(SPECULAR_PHONG)
+
+ vec3 R = normalize(-reflect(L,N));
+ float dotNV = max(0.0,dot(R,V));
+ float intensity = pow( dotNV, (1.0-roughness) * 256.0);
+ specular += light_color * intensity * specular_blob_intensity;
+
+#elif defined(SPECULAR_TOON)
+
+ vec3 R = normalize(-reflect(L,N));
+ float dotNV = dot(R,V);
+ float mid = 1.0-roughness;
+ mid*=mid;
+ float intensity = smoothstep(mid-roughness*0.5,mid+roughness*0.5,dotNV) * mid;
+ diffuse += light_color * intensity * specular_blob_intensity; //write to diffuse, as in toon shading you generally want no reflection
+
+#elif defined(SPECULAR_DISABLED)
+ //none..
+
+#else
+ // shlick+ggx as default
float alpha = roughness * roughness;
vec3 H = normalize(V + L);
@@ -740,7 +994,6 @@ LIGHT_SHADER_CODE
float dotNH = max(dot(N,H), 0.0 );
float dotLH = max(dot(L,H), 0.0 );
- // D
#if defined(LIGHT_USE_ANISOTROPY)
float aspect = sqrt(1.0-anisotropy*0.9);
@@ -772,6 +1025,7 @@ LIGHT_SHADER_CODE
float speci = dotNL * D * F * vis;
specular += speci * light_color * specular_blob_intensity;
+#endif
#if defined(LIGHT_USE_CLEARCOAT)
float Dr = GTR1(dotNH, mix(.1,.001,clearcoat_gloss));
@@ -862,7 +1116,7 @@ vec3 light_transmittance(float translucency,vec3 light_vec, vec3 normal, vec3 po
}
#endif
-void light_process_omni(int idx, vec3 vertex, vec3 eye_vec,vec3 normal,vec3 binormal, vec3 tangent, vec3 albedo, float roughness, float rim, float rim_tint, float clearcoat, float clearcoat_gloss,float anisotropy,inout vec3 diffuse_light, inout vec3 specular_light) {
+void light_process_omni(int idx, vec3 vertex, vec3 eye_vec,vec3 normal,vec3 binormal, vec3 tangent, vec3 albedo, float roughness, float rim, float rim_tint, float clearcoat, float clearcoat_gloss,float anisotropy,float p_blob_intensity,inout vec3 diffuse_light, inout vec3 specular_light) {
vec3 light_rel_vec = omni_lights[idx].light_pos_inv_radius.xyz-vertex;
float light_length = length( light_rel_vec );
@@ -903,31 +1157,34 @@ void light_process_omni(int idx, vec3 vertex, vec3 eye_vec,vec3 normal,vec3 bino
splane.xy = clamp_rect.xy+splane.xy*clamp_rect.zw;
float shadow = sample_shadow(shadow_atlas,shadow_atlas_pixel_size,splane.xy,splane.z,clamp_rect);
+
+#ifdef USE_CONTACT_SHADOWS
+
if (shadow>0.01 && omni_lights[idx].shadow_color_contact.a>0.0) {
float contact_shadow = contact_shadow_compute(vertex,normalize(light_rel_vec),min(light_length,omni_lights[idx].shadow_color_contact.a));
shadow=min(shadow,contact_shadow);
-
}
+#endif
light_attenuation*=mix(omni_lights[idx].shadow_color_contact.rgb,vec3(1.0),shadow);
}
- light_compute(normal,normalize(light_rel_vec),eye_vec,binormal,tangent,omni_lights[idx].light_color_energy.rgb*light_attenuation,albedo,omni_lights[idx].light_params.z,roughness,rim,rim_tint,clearcoat,clearcoat_gloss,anisotropy,diffuse_light,specular_light);
+ light_compute(normal,normalize(light_rel_vec),eye_vec,binormal,tangent,omni_lights[idx].light_color_energy.rgb*light_attenuation,albedo,omni_lights[idx].light_params.z*p_blob_intensity,roughness,rim,rim_tint,clearcoat,clearcoat_gloss,anisotropy,diffuse_light,specular_light);
}
-void light_process_spot(int idx, vec3 vertex, vec3 eye_vec, vec3 normal, vec3 binormal, vec3 tangent,vec3 albedo, float roughness, float rim,float rim_tint, float clearcoat, float clearcoat_gloss,float anisotropy, inout vec3 diffuse_light, inout vec3 specular_light) {
+void light_process_spot(int idx, vec3 vertex, vec3 eye_vec, vec3 normal, vec3 binormal, vec3 tangent,vec3 albedo, float roughness, float rim,float rim_tint, float clearcoat, float clearcoat_gloss,float anisotropy,float p_blob_intensity, inout vec3 diffuse_light, inout vec3 specular_light) {
vec3 light_rel_vec = spot_lights[idx].light_pos_inv_radius.xyz-vertex;
float light_length = length( light_rel_vec );
float normalized_distance = light_length*spot_lights[idx].light_pos_inv_radius.w;
- vec3 light_attenuation = vec3(pow( max(1.0 - normalized_distance, 0.0), spot_lights[idx].light_direction_attenuation.w ));
+ vec3 light_attenuation = vec3(pow( max(1.0 - normalized_distance, 0.001), spot_lights[idx].light_direction_attenuation.w ));
vec3 spot_dir = spot_lights[idx].light_direction_attenuation.xyz;
float spot_cutoff=spot_lights[idx].light_params.y;
float scos = max(dot(-normalize(light_rel_vec), spot_dir),spot_cutoff);
float spot_rim = (1.0 - scos) / (1.0 - spot_cutoff);
- light_attenuation *= 1.0 - pow( spot_rim, spot_lights[idx].light_params.x);
+ light_attenuation *= 1.0 - pow( max(spot_rim,0.001), spot_lights[idx].light_params.x);
if (spot_lights[idx].light_params.w>0.5) {
//there is a shadowmap
@@ -936,17 +1193,18 @@ void light_process_spot(int idx, vec3 vertex, vec3 eye_vec, vec3 normal, vec3 bi
float shadow = sample_shadow(shadow_atlas,shadow_atlas_pixel_size,splane.xy,splane.z,spot_lights[idx].light_clamp);
+#ifdef USE_CONTACT_SHADOWS
if (shadow>0.01 && spot_lights[idx].shadow_color_contact.a>0.0) {
float contact_shadow = contact_shadow_compute(vertex,normalize(light_rel_vec),min(light_length,spot_lights[idx].shadow_color_contact.a));
shadow=min(shadow,contact_shadow);
}
-
+#endif
light_attenuation*=mix(spot_lights[idx].shadow_color_contact.rgb,vec3(1.0),shadow);
}
- light_compute(normal,normalize(light_rel_vec),eye_vec,binormal,tangent,spot_lights[idx].light_color_energy.rgb*light_attenuation,albedo,spot_lights[idx].light_params.z,roughness,rim,rim_tint,clearcoat,clearcoat_gloss,anisotropy,diffuse_light,specular_light);
+ light_compute(normal,normalize(light_rel_vec),eye_vec,binormal,tangent,spot_lights[idx].light_color_energy.rgb*light_attenuation,albedo,spot_lights[idx].light_params.z*p_blob_intensity,roughness,rim,rim_tint,clearcoat,clearcoat_gloss,anisotropy,diffuse_light,specular_light);
}
@@ -986,27 +1244,19 @@ void reflection_process(int idx, vec3 vertex, vec3 normal,vec3 binormal, vec3 ta
}
-
- vec3 splane=normalize(local_ref_vec);
vec4 clamp_rect=reflections[idx].atlas_clamp;
-
- splane.z*=-1.0;
- if (splane.z>=0.0) {
- splane.z+=1.0;
- clamp_rect.y+=clamp_rect.w;
- } else {
- splane.z=1.0 - splane.z;
- splane.y=-splane.y;
+ vec3 norm = normalize(local_ref_vec);
+ norm.xy/=1.0+abs(norm.z);
+ norm.xy=norm.xy * vec2(0.5,0.25) + vec2(0.5,0.25);
+ if (norm.z>0.0) {
+ norm.y=0.5-norm.y+0.5;
}
- splane.xy/=splane.z;
- splane.xy=splane.xy * 0.5 + 0.5;
-
- splane.xy = splane.xy * clamp_rect.zw + clamp_rect.xy;
- splane.xy = clamp(splane.xy,clamp_rect.xy,clamp_rect.xy+clamp_rect.zw);
+ vec2 atlas_uv = norm.xy * clamp_rect.zw + clamp_rect.xy;
+ atlas_uv = clamp(atlas_uv,clamp_rect.xy,clamp_rect.xy+clamp_rect.zw);
highp vec4 reflection;
- reflection.rgb = textureLod(reflection_atlas,splane.xy,roughness*5.0).rgb;
+ reflection.rgb = textureLod(reflection_atlas,atlas_uv,roughness*5.0).rgb;
if (reflections[idx].params.z < 0.5) {
reflection.rgb = mix(skybox,reflection.rgb,blend);
@@ -1073,6 +1323,7 @@ uniform highp vec3 gi_probe_bounds1;
uniform highp vec3 gi_probe_cell_size1;
uniform highp float gi_probe_multiplier1;
uniform highp float gi_probe_bias1;
+uniform highp float gi_probe_normal_bias1;
uniform bool gi_probe_blend_ambient1;
uniform mediump sampler3D gi_probe2; //texunit:-10
@@ -1081,12 +1332,12 @@ uniform highp vec3 gi_probe_bounds2;
uniform highp vec3 gi_probe_cell_size2;
uniform highp float gi_probe_multiplier2;
uniform highp float gi_probe_bias2;
+uniform highp float gi_probe_normal_bias2;
uniform bool gi_probe2_enabled;
uniform bool gi_probe_blend_ambient2;
vec3 voxel_cone_trace(sampler3D probe, vec3 cell_size, vec3 pos, vec3 ambient, bool blend_ambient, vec3 direction, float tan_half_angle, float max_distance, float p_bias) {
-
float dist = p_bias;//1.0; //dot(direction,mix(vec3(-1.0),vec3(1.0),greaterThan(direction,vec3(0.0))))*2.0;
float alpha=0.0;
vec3 color = vec3(0.0);
@@ -1107,27 +1358,30 @@ vec3 voxel_cone_trace(sampler3D probe, vec3 cell_size, vec3 pos, vec3 ambient, b
return color;
}
-void gi_probe_compute(sampler3D probe, mat4 probe_xform, vec3 bounds,vec3 cell_size,vec3 pos, vec3 ambient, vec3 environment, bool blend_ambient,float multiplier, mat3 normal_mtx,vec3 ref_vec, float roughness,float p_bias, out vec4 out_spec, out vec4 out_diff) {
+void gi_probe_compute(sampler3D probe, mat4 probe_xform, vec3 bounds,vec3 cell_size,vec3 pos, vec3 ambient, vec3 environment, bool blend_ambient,float multiplier, mat3 normal_mtx,vec3 ref_vec, float roughness,float p_bias,float p_normal_bias, inout vec4 out_spec, inout vec4 out_diff) {
vec3 probe_pos = (probe_xform * vec4(pos,1.0)).xyz;
vec3 ref_pos = (probe_xform * vec4(pos+ref_vec,1.0)).xyz;
-
ref_vec = normalize(ref_pos - probe_pos);
+ probe_pos+=(probe_xform * vec4(normal_mtx[2],0.0)).xyz*p_normal_bias;
+
/* out_diff.rgb = voxel_cone_trace(probe,cell_size,probe_pos,normalize((probe_xform * vec4(ref_vec,0.0)).xyz),0.0 ,100.0);
out_diff.a = 1.0;
return;*/
//out_diff = vec4(textureLod(probe,probe_pos*cell_size,3.0).rgb,1.0);
//return;
- if (any(bvec2(any(lessThan(probe_pos,vec3(0.0))),any(greaterThan(probe_pos,bounds)))))
+ //this causes corrupted pixels, i have no idea why..
+ if (any(bvec2(any(lessThan(probe_pos,vec3(0.0))),any(greaterThan(probe_pos,bounds))))) {
return;
+ }
- vec3 blendv = probe_pos/bounds * 2.0 - 1.0;
- float blend = 1.001-max(blendv.x,max(blendv.y,blendv.z));
- blend=1.0;
+ //vec3 blendv = probe_pos/bounds * 2.0 - 1.0;
+ //float blend = 1.001-max(blendv.x,max(blendv.y,blendv.z));
+ float blend=1.0;
float max_distance = length(bounds);
@@ -1174,7 +1428,7 @@ void gi_probe_compute(sampler3D probe, mat4 probe_xform, vec3 bounds,vec3 cell_s
light*=multiplier;
- out_diff = vec4(light*blend,blend);
+ out_diff += vec4(light*blend,blend);
//irradiance
@@ -1183,7 +1437,8 @@ void gi_probe_compute(sampler3D probe, mat4 probe_xform, vec3 bounds,vec3 cell_s
irr_light *= multiplier;
//irr_light=vec3(0.0);
- out_spec = vec4(irr_light*blend,blend);
+ out_spec += vec4(irr_light*blend,blend);
+
}
@@ -1209,11 +1464,11 @@ void gi_probes_compute(vec3 pos, vec3 normal, float roughness, inout vec3 out_sp
out_specular = vec3(0.0);
- gi_probe_compute(gi_probe1,gi_probe_xform1,gi_probe_bounds1,gi_probe_cell_size1,pos,ambient,environment,gi_probe_blend_ambient1,gi_probe_multiplier1,normal_mat,ref_vec,roughness,gi_probe_bias1,spec_accum,diff_accum);
+ gi_probe_compute(gi_probe1,gi_probe_xform1,gi_probe_bounds1,gi_probe_cell_size1,pos,ambient,environment,gi_probe_blend_ambient1,gi_probe_multiplier1,normal_mat,ref_vec,roughness,gi_probe_bias1,gi_probe_normal_bias1,spec_accum,diff_accum);
if (gi_probe2_enabled) {
- gi_probe_compute(gi_probe2,gi_probe_xform2,gi_probe_bounds2,gi_probe_cell_size2,pos,ambient,environment,gi_probe_blend_ambient2,gi_probe_multiplier2,normal_mat,ref_vec,roughness,gi_probe_bias2,spec_accum,diff_accum);
+ gi_probe_compute(gi_probe2,gi_probe_xform2,gi_probe_bounds2,gi_probe_cell_size2,pos,ambient,environment,gi_probe_blend_ambient2,gi_probe_multiplier2,normal_mat,ref_vec,roughness,gi_probe_bias2,gi_probe_normal_bias2,spec_accum,diff_accum);
}
if (diff_accum.a>0.0) {
@@ -1231,23 +1486,7 @@ void gi_probes_compute(vec3 pos, vec3 normal, float roughness, inout vec3 out_sp
#endif
-vec3 textureDualParabolod(sampler2D p_tex, vec3 p_vec,float p_lod) {
-
- vec3 norm = normalize(p_vec);
- float y_ofs=0.0;
- if (norm.z>=0.0) {
- norm.z+=1.0;
- y_ofs+=0.5;
- } else {
- norm.z=1.0 - norm.z;
- norm.y=-norm.y;
- }
-
- norm.xy/=norm.z;
- norm.xy=norm.xy * vec2(0.5,0.25) + vec2(0.5,0.25+y_ofs);
- return textureLod(p_tex, norm.xy, p_lod).xyz;
-}
void main() {
@@ -1372,10 +1611,20 @@ FRAGMENT_SHADER_CODE
//apply energy conservation
+#ifdef USE_VERTEX_LIGHTING
+
+ vec3 specular_light = specular_light_interp.rgb;
+ vec3 diffuse_light = diffuse_light_interp.rgb;
+#else
+
vec3 specular_light = vec3(0.0,0.0,0.0);
- vec3 ambient_light;
vec3 diffuse_light = vec3(0.0,0.0,0.0);
+#endif
+
+ vec3 ambient_light;
+ vec3 env_reflection_light = vec3(0.0,0.0,0.0);
+
vec3 eye_vec = -normalize( vertex_interp );
@@ -1387,16 +1636,12 @@ FRAGMENT_SHADER_CODE
} else {
{
-
-#define RADIANCE_MAX_LOD 5.0
- float lod = roughness * RADIANCE_MAX_LOD;
-
{ //read radiance from dual paraboloid
vec3 ref_vec = reflect(-eye_vec,normal); //2.0 * ndotv * normal - view; // reflect(v, n);
ref_vec=normalize((radiance_inverse_xform * vec4(ref_vec,0.0)).xyz);
- vec3 radiance = textureDualParabolod(radiance_map,ref_vec,lod) * bg_energy;
- specular_light = radiance;
+ vec3 radiance = textureDualParaboloid(radiance_map,ref_vec,roughness) * bg_energy;
+ env_reflection_light = radiance;
}
//no longer a cubemap
@@ -1407,7 +1652,7 @@ FRAGMENT_SHADER_CODE
{
vec3 ambient_dir=normalize((radiance_inverse_xform * vec4(normal,0.0)).xyz);
- vec3 env_ambient=textureDualParabolod(radiance_map,ambient_dir,RADIANCE_MAX_LOD) * bg_energy;
+ vec3 env_ambient=textureDualParaboloid(radiance_map,ambient_dir,1.0) * bg_energy;
ambient_light=mix(ambient_light_color.rgb,env_ambient,radiance_ambient_contribution);
//ambient_light=vec3(0.0,0.0,0.0);
@@ -1425,7 +1670,12 @@ FRAGMENT_SHADER_CODE
ambient_light*=ambient_energy;
-#ifdef USE_LIGHT_DIRECTIONAL
+ float specular_blob_intensity=1.0;
+#if defined(SPECULAR_TOON)
+ specular_blob_intensity*=specular * 2.0;
+#endif
+
+#if defined(USE_LIGHT_DIRECTIONAL)
vec3 light_attenuation=vec3(1.0);
@@ -1550,13 +1800,14 @@ FRAGMENT_SHADER_CODE
}
#endif
+#ifdef USE_CONTACT_SHADOWS
if (shadow>0.01 && shadow_color_contact.a>0.0) {
float contact_shadow = contact_shadow_compute(vertex,-light_direction_attenuation.xyz,shadow_color_contact.a);
shadow=min(shadow,contact_shadow);
}
-
+#endif
light_attenuation=mix(shadow_color_contact.rgb,vec3(1.0),shadow);
@@ -1564,52 +1815,63 @@ FRAGMENT_SHADER_CODE
#endif //LIGHT_DIRECTIONAL_SHADOW
- light_compute(normal,-light_direction_attenuation.xyz,eye_vec,binormal,tangent,light_color_energy.rgb*light_attenuation,albedo,light_params.z,roughness,rim,rim_tint,clearcoat,clearcoat_gloss,anisotropy,diffuse_light,specular_light);
+#ifdef USE_VERTEX_LIGHTING
+ diffuse_light*=mix(vec3(1.0),light_attenuation,diffuse_light_interp.a);
+ specular_light*=mix(vec3(1.0),light_attenuation,specular_light_interp.a);
+
+#else
+ light_compute(normal,-light_direction_attenuation.xyz,eye_vec,binormal,tangent,light_color_energy.rgb*light_attenuation,albedo,light_params.z*specular_blob_intensity,roughness,rim,rim_tint,clearcoat,clearcoat_gloss,anisotropy,diffuse_light,specular_light);
+#endif
#endif //#USE_LIGHT_DIRECTIONAL
#ifdef USE_GI_PROBES
- gi_probes_compute(vertex,normal,roughness,specular_light,ambient_light);
+ gi_probes_compute(vertex,normal,roughness,env_reflection_light,ambient_light);
#endif
-
#ifdef USE_FORWARD_LIGHTING
+
highp vec4 reflection_accum = vec4(0.0,0.0,0.0,0.0);
highp vec4 ambient_accum = vec4(0.0,0.0,0.0,0.0);
-
-
-
for(int i=0;i<reflection_count;i++) {
- reflection_process(reflection_indices[i],vertex,normal,binormal,tangent,roughness,anisotropy,ambient_light,specular_light,reflection_accum,ambient_accum);
+ reflection_process(reflection_indices[i],vertex,normal,binormal,tangent,roughness,anisotropy,ambient_light,env_reflection_light,reflection_accum,ambient_accum);
}
if (reflection_accum.a>0.0) {
specular_light+=reflection_accum.rgb/reflection_accum.a;
+ } else {
+ specular_light+=env_reflection_light;
}
+
if (ambient_accum.a>0.0) {
ambient_light+=ambient_accum.rgb/ambient_accum.a;
}
+
+
+#ifdef USE_VERTEX_LIGHTING
+
+ diffuse_light*=albedo;
+#else
+
for(int i=0;i<omni_light_count;i++) {
- light_process_omni(omni_light_indices[i],vertex,eye_vec,normal,binormal,tangent,albedo,roughness,rim,rim_tint,clearcoat,clearcoat_gloss,anisotropy,diffuse_light,specular_light);
+ light_process_omni(omni_light_indices[i],vertex,eye_vec,normal,binormal,tangent,albedo,roughness,rim,rim_tint,clearcoat,clearcoat_gloss,anisotropy,specular_blob_intensity,diffuse_light,specular_light);
}
for(int i=0;i<spot_light_count;i++) {
- light_process_spot(spot_light_indices[i],vertex,eye_vec,normal,binormal,tangent,albedo,roughness,rim,rim_tint,clearcoat,clearcoat_gloss,anisotropy,diffuse_light,specular_light);
+ light_process_spot(spot_light_indices[i],vertex,eye_vec,normal,binormal,tangent,albedo,roughness,rim,rim_tint,clearcoat,clearcoat_gloss,anisotropy,specular_blob_intensity,diffuse_light,specular_light);
}
-
+#endif //USE_VERTEX_LIGHTING
#endif
-
-
#ifdef RENDER_DEPTH
//nothing happens, so a tree-ssa optimizer will result in no fragment shader :)
#else
@@ -1622,19 +1884,21 @@ FRAGMENT_SHADER_CODE
#endif
-
-
-
-
//energu conservation
diffuse_light=mix(diffuse_light,vec3(0.0),metallic);
ambient_light=mix(ambient_light,vec3(0.0),metallic);
+
+
{
+
+#if defined(DIFFUSE_TOON)
+ //simplify for toon, as
+ specular_light *= specular * metallic * albedo * 2.0;
+#else
//brdf approximation (Lazarov 2013)
float ndotv = clamp(dot(normal,eye_vec),0.0,1.0);
-
+ vec3 dielectric = vec3(0.034) * specular * 2.0;
//energy conservation
- vec3 dielectric = vec3(0.034) * 0.5 * 2.0;
vec3 f0 = mix(dielectric, albedo, metallic);
const vec4 c0 = vec4(-1.0, -0.0275, -0.572, 0.022);
const vec4 c1 = vec4( 1.0, 0.0425, 1.04, -0.04);
@@ -1643,11 +1907,13 @@ FRAGMENT_SHADER_CODE
vec2 brdf = vec2( -1.04, 1.04 ) * a004 + r.zw;
specular_light *= min(1.0,50.0 * f0.g) * brdf.y + brdf.x * f0;
+#endif
+
}
if (fog_color_enabled.a > 0.5) {
- float fog_amount=0;
+ float fog_amount=0.0;
diff --git a/drivers/gles3/shaders/tonemap.glsl b/drivers/gles3/shaders/tonemap.glsl
index 3ce2edf4e9..988e31d1ea 100644
--- a/drivers/gles3/shaders/tonemap.glsl
+++ b/drivers/gles3/shaders/tonemap.glsl
@@ -18,6 +18,10 @@ void main() {
[fragment]
+#if !defined(GLES_OVER_GL)
+precision mediump float;
+#endif
+
in vec2 uv_interp;
@@ -140,6 +144,38 @@ vec4 texture2D_bicubic(sampler2D tex, vec2 uv,int p_lod)
#endif
+vec3 tonemap_filmic(vec3 color,float white) {
+
+ float A = 0.15;
+ float B = 0.50;
+ float C = 0.10;
+ float D = 0.20;
+ float E = 0.02;
+ float F = 0.30;
+ float W = 11.2;
+
+ vec3 coltn = ((color*(A*color+C*B)+D*E)/(color*(A*color+B)+D*F))-E/F;
+ float whitetn = ((white*(A*white+C*B)+D*E)/(white*(A*white+B)+D*F))-E/F;
+
+ return coltn/whitetn;
+
+}
+
+vec3 tonemap_aces(vec3 color) {
+ float a = 2.51f;
+ float b = 0.03f;
+ float c = 2.43f;
+ float d = 0.59f;
+ float e = 0.14f;
+ return color = clamp((color*(a*color+b))/(color*(c*color+d)+e),vec3(0.0),vec3(1.0));
+}
+
+vec3 tonemap_reindhart(vec3 color,vec3 white) {
+
+ return ( color * ( 1.0 + ( color / ( white) ) ) ) / ( 1.0 + color );
+}
+
+
void main() {
ivec2 coord = ivec2(gl_FragCoord.xy);
@@ -153,8 +189,11 @@ void main() {
color*=exposure;
-
#if defined(USE_GLOW_LEVEL1) || defined(USE_GLOW_LEVEL2) || defined(USE_GLOW_LEVEL3) || defined(USE_GLOW_LEVEL4) || defined(USE_GLOW_LEVEL5) || defined(USE_GLOW_LEVEL6) || defined(USE_GLOW_LEVEL7)
+#define USING_GLOW
+#endif
+
+#if defined(USING_GLOW)
vec3 glow = vec3(0.0);
#ifdef USE_GLOW_LEVEL1
@@ -189,85 +228,83 @@ void main() {
glow *= glow_intensity;
+#endif
-#ifdef USE_GLOW_REPLACE
+#ifdef USE_REINDHART_TONEMAPPER
- color.rgb = glow;
+ color.rgb = tonemap_reindhart(color.rgb,white);
+
+# if defined(USING_GLOW)
+ glow = tonemap_reindhart(glow,white);
+# endif
#endif
-#ifdef USE_GLOW_SCREEN
+#ifdef USE_FILMIC_TONEMAPPER
- color.rgb = clamp((color.rgb + glow) - (color.rgb * glow), 0.0, 1.0);
+ color.rgb = tonemap_filmic(color.rgb,white);
+
+# if defined(USING_GLOW)
+ glow = tonemap_filmic(glow,white);
+# endif
#endif
-#ifdef USE_GLOW_SOFTLIGHT
+#ifdef USE_ACES_TONEMAPPER
- {
+ color.rgb = tonemap_aces(color.rgb);
- glow = (glow * 0.5) + 0.5;
- color.r = (glow.r <= 0.5) ? (color.r - (1.0 - 2.0 * glow.r) * color.r * (1.0 - color.r)) : (((glow.r > 0.5) && (color.r <= 0.25)) ? (color.r + (2.0 * glow.r - 1.0) * (4.0 * color.r * (4.0 * color.r + 1.0) * (color.r - 1.0) + 7.0 * color.r)) : (color.r + (2.0 * glow.r - 1.0) * (sqrt(color.r) - color.r)));
- color.g = (glow.g <= 0.5) ? (color.g - (1.0 - 2.0 * glow.g) * color.g * (1.0 - color.g)) : (((glow.g > 0.5) && (color.g <= 0.25)) ? (color.g + (2.0 * glow.g - 1.0) * (4.0 * color.g * (4.0 * color.g + 1.0) * (color.g - 1.0) + 7.0 * color.g)) : (color.g + (2.0 * glow.g - 1.0) * (sqrt(color.g) - color.g)));
- color.b = (glow.b <= 0.5) ? (color.b - (1.0 - 2.0 * glow.b) * color.b * (1.0 - color.b)) : (((glow.b > 0.5) && (color.b <= 0.25)) ? (color.b + (2.0 * glow.b - 1.0) * (4.0 * color.b * (4.0 * color.b + 1.0) * (color.b - 1.0) + 7.0 * color.b)) : (color.b + (2.0 * glow.b - 1.0) * (sqrt(color.b) - color.b)));
- }
-
-#endif
+# if defined(USING_GLOW)
+ glow = tonemap_aces(glow);
+# endif
-#if !defined(USE_GLOW_SCREEN) && !defined(USE_GLOW_SOFTLIGHT) && !defined(USE_GLOW_REPLACE)
- color.rgb+=glow;
#endif
+ //regular Linear -> SRGB conversion
+ vec3 a = vec3(0.055);
+ color.rgb = mix( (vec3(1.0)+a)*pow(color.rgb,vec3(1.0/2.4))-a , 12.92*color.rgb , lessThan(color.rgb,vec3(0.0031308)));
+#if defined(USING_GLOW)
+ glow = mix( (vec3(1.0)+a)*pow(glow,vec3(1.0/2.4))-a , 12.92*glow , lessThan(glow,vec3(0.0031308)));
#endif
+//glow needs to be added in SRGB space (together with image space effects)
-#ifdef USE_REINDHART_TONEMAPPER
-
- {
- color.rgb = ( color.rgb * ( 1.0 + ( color.rgb / ( white) ) ) ) / ( 1.0 + color.rgb );
+ color.rgb = clamp(color.rgb,0.0,1.0);
- }
+#if defined(USING_GLOW)
+ glow = clamp(glow,0.0,1.0);
#endif
-#ifdef USE_FILMIC_TONEMAPPER
+#ifdef USE_GLOW_REPLACE
- {
+ color.rgb = glow;
- float A = 0.15;
- float B = 0.50;
- float C = 0.10;
- float D = 0.20;
- float E = 0.02;
- float F = 0.30;
- float W = 11.2;
+#endif
- vec3 coltn = ((color.rgb*(A*color.rgb+C*B)+D*E)/(color.rgb*(A*color.rgb+B)+D*F))-E/F;
- float whitetn = ((white*(A*white+C*B)+D*E)/(white*(A*white+B)+D*F))-E/F;
+#ifdef USE_GLOW_SCREEN
- color.rgb=coltn/whitetn;
+ color.rgb = max((color.rgb + glow) - (color.rgb * glow), vec3(0.0));
- }
#endif
-#ifdef USE_ACES_TONEMAPPER
+#ifdef USE_GLOW_SOFTLIGHT
{
- float a = 2.51f;
- float b = 0.03f;
- float c = 2.43f;
- float d = 0.59f;
- float e = 0.14f;
- color.rgb = clamp((color.rgb*(a*color.rgb+b))/(color.rgb*(c*color.rgb+d)+e),vec3(0.0),vec3(1.0));
+
+ glow = (glow * 0.5) + 0.5;
+ color.r = (glow.r <= 0.5) ? (color.r - (1.0 - 2.0 * glow.r) * color.r * (1.0 - color.r)) : (((glow.r > 0.5) && (color.r <= 0.25)) ? (color.r + (2.0 * glow.r - 1.0) * (4.0 * color.r * (4.0 * color.r + 1.0) * (color.r - 1.0) + 7.0 * color.r)) : (color.r + (2.0 * glow.r - 1.0) * (sqrt(color.r) - color.r)));
+ color.g = (glow.g <= 0.5) ? (color.g - (1.0 - 2.0 * glow.g) * color.g * (1.0 - color.g)) : (((glow.g > 0.5) && (color.g <= 0.25)) ? (color.g + (2.0 * glow.g - 1.0) * (4.0 * color.g * (4.0 * color.g + 1.0) * (color.g - 1.0) + 7.0 * color.g)) : (color.g + (2.0 * glow.g - 1.0) * (sqrt(color.g) - color.g)));
+ color.b = (glow.b <= 0.5) ? (color.b - (1.0 - 2.0 * glow.b) * color.b * (1.0 - color.b)) : (((glow.b > 0.5) && (color.b <= 0.25)) ? (color.b + (2.0 * glow.b - 1.0) * (4.0 * color.b * (4.0 * color.b + 1.0) * (color.b - 1.0) + 7.0 * color.b)) : (color.b + (2.0 * glow.b - 1.0) * (sqrt(color.b) - color.b)));
}
#endif
- //regular Linear -> SRGB conversion
- vec3 a = vec3(0.055);
- color.rgb = mix( (vec3(1.0)+a)*pow(color.rgb,vec3(1.0/2.4))-a , 12.92*color.rgb , lessThan(color.rgb,vec3(0.0031308)));
-
+#if defined(USING_GLOW) && !defined(USE_GLOW_SCREEN) && !defined(USE_GLOW_SOFTLIGHT) && !defined(USE_GLOW_REPLACE)
+ //additive
+ color.rgb+=glow;
+#endif
#ifdef USE_BCS
diff --git a/drivers/png/resource_saver_png.cpp b/drivers/png/resource_saver_png.cpp
index 0d7e1d9d72..4f1f318aee 100644
--- a/drivers/png/resource_saver_png.cpp
+++ b/drivers/png/resource_saver_png.cpp
@@ -30,8 +30,8 @@
#include "resource_saver_png.h"
#include "core/image.h"
-#include "global_config.h"
#include "os/file_access.h"
+#include "project_settings.h"
#include "scene/resources/texture.h"
#include <png.h>
diff --git a/drivers/pulseaudio/audio_driver_pulseaudio.cpp b/drivers/pulseaudio/audio_driver_pulseaudio.cpp
index 45827ee4f7..fb04ef0088 100644
--- a/drivers/pulseaudio/audio_driver_pulseaudio.cpp
+++ b/drivers/pulseaudio/audio_driver_pulseaudio.cpp
@@ -33,7 +33,7 @@
#include <pulse/error.h>
-#include "global_config.h"
+#include "project_settings.h"
Error AudioDriverPulseAudio::init() {
diff --git a/drivers/rtaudio/audio_driver_rtaudio.cpp b/drivers/rtaudio/audio_driver_rtaudio.cpp
index 0cbe145b41..da998db66f 100644
--- a/drivers/rtaudio/audio_driver_rtaudio.cpp
+++ b/drivers/rtaudio/audio_driver_rtaudio.cpp
@@ -29,8 +29,8 @@
/*************************************************************************/
#include "audio_driver_rtaudio.h"
-#include "global_config.h"
#include "os/os.h"
+#include "project_settings.h"
#ifdef RTAUDIO_ENABLED
diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp
index 75f40cacca..e424590881 100644
--- a/drivers/unix/os_unix.cpp
+++ b/drivers/unix/os_unix.cpp
@@ -50,10 +50,10 @@
#include <mach-o/dyld.h>
#endif
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__OpenBSD__)
#include <sys/param.h>
#endif
-#include "global_config.h"
+#include "project_settings.h"
#include <assert.h>
#include <dlfcn.h>
#include <errno.h>
@@ -453,7 +453,7 @@ Error OS_Unix::close_dynamic_library(void *p_library_handle) {
return OK;
}
-Error OS_Unix::get_dynamic_library_symbol_handle(void *p_library_handle, const String p_name, void *&p_symbol_handle) {
+Error OS_Unix::get_dynamic_library_symbol_handle(void *p_library_handle, const String p_name, void *&p_symbol_handle, bool p_optional) {
const char *error;
dlerror(); // Clear existing errors
@@ -461,8 +461,12 @@ Error OS_Unix::get_dynamic_library_symbol_handle(void *p_library_handle, const S
error = dlerror();
if (error != NULL) {
- ERR_EXPLAIN("Can't resolve symbol " + p_name + ". Error: " + error);
- ERR_FAIL_V(ERR_CANT_RESOLVE);
+ if (!p_optional) {
+ ERR_EXPLAIN("Can't resolve symbol " + p_name + ". Error: " + error);
+ ERR_FAIL_V(ERR_CANT_RESOLVE);
+ } else {
+ return ERR_CANT_RESOLVE;
+ }
}
return OK;
}
@@ -494,7 +498,7 @@ String OS_Unix::get_data_dir() const {
if (has_environment("HOME")) {
- bool use_godot = GlobalConfig::get_singleton()->get("application/use_shared_user_dir");
+ bool use_godot = ProjectSettings::get_singleton()->get("application/config/use_shared_user_dir");
if (use_godot)
return get_environment("HOME") + "/.godot/app_userdata/" + an;
else
@@ -502,12 +506,7 @@ String OS_Unix::get_data_dir() const {
}
}
- return GlobalConfig::get_singleton()->get_resource_path();
-}
-
-bool OS_Unix::check_feature_support(const String &p_feature) {
-
- return VisualServer::get_singleton()->has_os_feature(p_feature);
+ return ProjectSettings::get_singleton()->get_resource_path();
}
String OS_Unix::get_installed_templates_path() const {
@@ -532,7 +531,7 @@ String OS_Unix::get_executable_path() const {
return OS::get_executable_path();
}
return b;
-#elif defined(__FreeBSD__)
+#elif defined(__FreeBSD__) || defined(__OpenBSD__)
char resolved_path[MAXPATHLEN];
realpath(OS::get_executable_path().utf8().get_data(), resolved_path);
diff --git a/drivers/unix/os_unix.h b/drivers/unix/os_unix.h
index 67eb5cefdf..fdc6d6e28f 100644
--- a/drivers/unix/os_unix.h
+++ b/drivers/unix/os_unix.h
@@ -85,7 +85,7 @@ public:
virtual Error open_dynamic_library(const String p_path, void *&p_library_handle);
virtual Error close_dynamic_library(void *p_library_handle);
- virtual Error get_dynamic_library_symbol_handle(void *p_library_handle, const String p_name, void *&p_symbol_handle);
+ virtual Error get_dynamic_library_symbol_handle(void *p_library_handle, const String p_name, void *&p_symbol_handle, bool p_optional = false);
virtual Error set_cwd(const String &p_cwd);
@@ -117,8 +117,6 @@ public:
virtual String get_executable_path() const;
virtual String get_data_dir() const;
- virtual bool check_feature_support(const String &p_feature);
-
//virtual void run( MainLoop * p_main_loop );
};
diff --git a/drivers/xaudio2/audio_driver_xaudio2.cpp b/drivers/xaudio2/audio_driver_xaudio2.cpp
index 23ba177824..a1ca2c678e 100644
--- a/drivers/xaudio2/audio_driver_xaudio2.cpp
+++ b/drivers/xaudio2/audio_driver_xaudio2.cpp
@@ -29,8 +29,8 @@
/*************************************************************************/
#include "audio_driver_xaudio2.h"
-#include "global_config.h"
#include "os/os.h"
+#include "project_settings.h"
const char *AudioDriverXAudio2::get_name() const {
return "XAudio2";
diff --git a/editor/SCsub b/editor/SCsub
index ffdeed1523..fd56c9d772 100644
--- a/editor/SCsub
+++ b/editor/SCsub
@@ -143,6 +143,9 @@ def make_translations_header(target, source, env):
def make_authors_header(target, source, env):
+ sections = ["Project Founders", "Lead Developer", "Project Manager", "Developers"]
+ sections_id = ["dev_founders", "dev_lead", "dev_manager", "dev_names"]
+
src = source[0].srcnode().abspath
dst = target[0].srcnode().abspath
f = open(src, "rb")
@@ -151,19 +154,196 @@ def make_authors_header(target, source, env):
g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
g.write("#ifndef _EDITOR_AUTHORS_H\n")
g.write("#define _EDITOR_AUTHORS_H\n")
- g.write("static const char *dev_names[] = {\n")
+ current_section = ""
name_count = -1
+
+ def close_section():
+ g.write("\t0\n")
+ g.write("};\n")
+ g.write("#define " + current_section.upper() + "_COUNT " + str(name_count) + "\n")
+
for line in f:
if name_count >= 0:
if line.startswith(" "):
g.write("\t\"" + line.strip() + "\",\n")
name_count += 1
- elif line.strip() == "## Developers":
- name_count = 0
+ continue
+ if line.startswith("## "):
+ if name_count >= 0:
+ close_section()
+ name_count = -1
+ for i in range(len(sections)):
+ if line.strip().endswith(sections[i]):
+ current_section = sections_id[i]
+ name_count = 0
+ g.write("static const char *" + current_section + "[] = {\n")
+ break
+
+ if name_count >= 0:
+ close_section()
+
+ g.write("#endif\n")
+
+def make_license_header(target, source, env):
+
+ src_copyright = source[0].srcnode().abspath
+ src_license = source[1].srcnode().abspath
+ dst = target[0].srcnode().abspath
+ f = open(src_license, "rb")
+ fc = open(src_copyright, "rb")
+ g = open(dst, "wb")
+
+ g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
+ g.write("#ifndef _EDITOR_LICENSE_H\n")
+ g.write("#define _EDITOR_LICENSE_H\n")
+ g.write("static const char *about_license =")
+
+ for line in f:
+ g.write("\n\t\"" + line.strip().replace("\"", "\\\"") + "\\n\"")
+
+ g.write(";\n")
+
+ tp_current = 0
+ tp_file = ""
+ tp_comment = ""
+ tp_copyright = ""
+ tp_license = ""
+
+ tp_licensename = ""
+ tp_licensebody = ""
+
+ tp = []
+ tp_licensetext = []
+ for line in fc:
+ if line.startswith("#"):
+ continue
+
+ if line.startswith("Files:"):
+ tp_file = line[6:].strip()
+ tp_current = 1
+ elif line.startswith("Comment:"):
+ tp_comment = line[8:].strip()
+ tp_current = 2
+ elif line.startswith("Copyright:"):
+ tp_copyright = line[10:].strip()
+ tp_current = 3
+ elif line.startswith("License:"):
+ if tp_current != 0:
+ tp_license = line[8:].strip()
+ tp_current = 4
+ else:
+ tp_licensename = line[8:].strip()
+ tp_current = 5
+ elif line.startswith(" "):
+ if tp_current == 1:
+ tp_file += "\n" + line.strip()
+ elif tp_current == 3:
+ tp_copyright += "\n" + line.strip()
+ elif tp_current == 5:
+ if line.strip() == ".":
+ tp_licensebody += "\n"
+ else:
+ tp_licensebody += line[1:]
+ else:
+ if tp_current != 0:
+ if tp_current == 5:
+ tp_licensetext.append([tp_licensename, tp_licensebody])
+
+ tp_licensename = ""
+ tp_licensebody = ""
+ else:
+ added = False
+ for i in tp:
+ if i[0] == tp_comment:
+ i[1].append([tp_file, tp_copyright, tp_license])
+ added = True
+ break
+ if not added:
+ tp.append([tp_comment,[[tp_file, tp_copyright, tp_license]]])
+
+ tp_file = []
+ tp_comment = ""
+ tp_copyright = []
+ tp_license = ""
+ tp_current = 0
+
+ tp_licensetext.append([tp_licensename, tp_licensebody])
+
+ about_thirdparty = ""
+ about_tp_copyright_count = ""
+ about_tp_license = ""
+ about_tp_copyright = ""
+ about_tp_file = ""
+
+ for i in tp:
+ about_thirdparty += "\t\"" + i[0] + "\",\n"
+ about_tp_copyright_count += str(len(i[1])) + ", "
+ for j in i[1]:
+ file_body = ""
+ copyright_body = ""
+ for k in j[0].split("\n"):
+ if file_body != "":
+ file_body += "\\n\"\n"
+ file_body += "\t\"" + k.strip().replace("\"", "\\\"")
+ for k in j[1].split("\n"):
+ if copyright_body != "":
+ copyright_body += "\\n\"\n"
+ copyright_body += "\t\"" + k.strip().replace("\"", "\\\"")
+
+ about_tp_file += "\t" + file_body + "\",\n"
+ about_tp_copyright += "\t" + copyright_body + "\",\n"
+ about_tp_license += "\t\"" + j[2] + "\",\n"
+
+ about_license_name = ""
+ about_license_body = ""
+
+ for i in tp_licensetext:
+ body = ""
+ for j in i[1].split("\n"):
+ if body != "":
+ body += "\\n\"\n"
+ body += "\t\"" + j.strip().replace("\"", "\\\"")
+
+ about_license_name += "\t\"" + i[0] + "\",\n"
+ about_license_body += "\t" + body + "\",\n"
+
+ g.write("static const char *about_thirdparty[] = {\n")
+ g.write(about_thirdparty)
+ g.write("\t0\n")
+ g.write("};\n")
+ g.write("#define THIRDPARTY_COUNT " + str(len(tp)) + "\n")
+
+ g.write("static const int about_tp_copyright_count[] = {\n\t")
+ g.write(about_tp_copyright_count)
+ g.write("0\n};\n")
+
+ g.write("static const char *about_tp_file[] = {\n")
+ g.write(about_tp_file)
+ g.write("\t0\n")
+ g.write("};\n")
+
+ g.write("static const char *about_tp_copyright[] = {\n")
+ g.write(about_tp_copyright)
+ g.write("\t0\n")
+ g.write("};\n")
+
+ g.write("static const char *about_tp_license[] = {\n")
+ g.write(about_tp_license)
g.write("\t0\n")
g.write("};\n")
- g.write("#define AUTHORS_COUNT " + str(name_count) + "\n")
+
+ g.write("static const char *about_license_name[] = {\n")
+ g.write(about_license_name)
+ g.write("\t0\n")
+ g.write("};\n")
+ g.write("#define LICENSE_COUNT " + str(len(tp_licensetext)) + "\n")
+
+ g.write("static const char *about_license_body[] = {\n")
+ g.write(about_license_body)
+ g.write("\t0\n")
+ g.write("};\n")
+
g.write("#endif\n")
if (env["tools"] == "yes"):
@@ -216,6 +396,10 @@ if (env["tools"] == "yes"):
env.Depends('#editor/authors.gen.h', "../AUTHORS.md")
env.Command('#editor/authors.gen.h', "../AUTHORS.md", make_authors_header)
+ # License
+ env.Depends('#editor/license.gen.h', ["../COPYRIGHT.txt", "../LICENSE.txt"])
+ env.Command('#editor/license.gen.h', ["../COPYRIGHT.txt", "../LICENSE.txt"], make_license_header)
+
env.add_source_files(env.editor_sources, "*.cpp")
diff --git a/editor/animation_editor.cpp b/editor/animation_editor.cpp
index 1798e66e8a..45da365695 100644
--- a/editor/animation_editor.cpp
+++ b/editor/animation_editor.cpp
@@ -3774,6 +3774,7 @@ AnimationKeyEditor::AnimationKeyEditor() {
zoom->set_max(2.0);
zoom->set_value(1.0);
zoom->set_h_size_flags(SIZE_EXPAND_FILL);
+ zoom->set_v_size_flags(SIZE_EXPAND_FILL);
zoom->set_stretch_ratio(2);
hb->add_child(zoom);
zoom->connect("value_changed", this, "_scroll_changed");
diff --git a/editor/animation_editor.h b/editor/animation_editor.h
index 128481c837..88cc446853 100644
--- a/editor/animation_editor.h
+++ b/editor/animation_editor.h
@@ -45,7 +45,6 @@
#include "scene/animation/animation_cache.h"
#include "scene/resources/animation.h"
#include "scene_tree_editor.h"
-#include "scene_tree_editor.h"
class AnimationKeyEdit;
class AnimationCurveEdit;
diff --git a/editor/asset_library_editor_plugin.cpp b/editor/asset_library_editor_plugin.cpp
index fcb92e13b4..f92b70d0c0 100644
--- a/editor/asset_library_editor_plugin.cpp
+++ b/editor/asset_library_editor_plugin.cpp
@@ -98,10 +98,10 @@ EditorAssetLibraryItem::EditorAssetLibraryItem() {
Ref<StyleBoxEmpty> border;
border.instance();
- /*border->set_default_margin(MARGIN_LEFT,5);
- border->set_default_margin(MARGIN_RIGHT,5);
- border->set_default_margin(MARGIN_BOTTOM,5);
- border->set_default_margin(MARGIN_TOP,5);*/
+ border->set_default_margin(MARGIN_LEFT, 5);
+ border->set_default_margin(MARGIN_RIGHT, 5);
+ border->set_default_margin(MARGIN_BOTTOM, 5);
+ border->set_default_margin(MARGIN_TOP, 5);
add_style_override("panel", border);
HBoxContainer *hb = memnew(HBoxContainer);
@@ -1228,8 +1228,8 @@ void EditorAssetLibrary::_asset_open() {
void EditorAssetLibrary::_manage_plugins() {
- ProjectSettings::get_singleton()->popup_project_settings();
- ProjectSettings::get_singleton()->set_plugins_page();
+ ProjectSettingsEditor::get_singleton()->popup_project_settings();
+ ProjectSettingsEditor::get_singleton()->set_plugins_page();
}
void EditorAssetLibrary::_install_external_asset(String p_zip_path, String p_title) {
@@ -1261,15 +1261,6 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
templates_only = p_templates_only;
- Ref<StyleBoxEmpty> border;
- border.instance();
- border->set_default_margin(MARGIN_LEFT, 15);
- border->set_default_margin(MARGIN_RIGHT, 15);
- border->set_default_margin(MARGIN_BOTTOM, 5);
- border->set_default_margin(MARGIN_TOP, 5);
-
- add_style_override("panel", border);
-
VBoxContainer *library_main = memnew(VBoxContainer);
add_child(library_main);
@@ -1343,10 +1334,13 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
search_hb2->add_child(memnew(Label(TTR("Site:") + " ")));
repository = memnew(OptionButton);
+ // FIXME: Reenable me once GH-7147 is fixed.
+ /*
repository->add_item("godotengine.org");
repository->set_item_metadata(0, "https://godotengine.org/asset-library/api");
- repository->add_item("localhost"); // TODO: Maybe remove?
- repository->set_item_metadata(1, "http://127.0.0.1/asset-library/api");
+ */
+ repository->add_item("localhost");
+ repository->set_item_metadata(/*1*/ 0, "http://127.0.0.1/asset-library/api");
repository->connect("item_selected", this, "_repository_changed");
search_hb2->add_child(repository);
diff --git a/editor/collada/collada.cpp b/editor/collada/collada.cpp
index 2f234c441a..ab1e397ccc 100644
--- a/editor/collada/collada.cpp
+++ b/editor/collada/collada.cpp
@@ -306,7 +306,7 @@ void Collada::_parse_image(XMLParser &parser) {
String path = parser.get_attribute_value("source").strip_edges();
if (path.find("://") == -1 && path.is_rel_path()) {
// path is relative to file being loaded, so convert to a resource path
- image.path = GlobalConfig::get_singleton()->localize_path(state.local_path.get_base_dir() + "/" + path.percent_decode());
+ image.path = ProjectSettings::get_singleton()->localize_path(state.local_path.get_base_dir() + "/" + path.percent_decode());
}
} else {
@@ -323,11 +323,11 @@ void Collada::_parse_image(XMLParser &parser) {
if (path.find("://") == -1 && path.is_rel_path()) {
// path is relative to file being loaded, so convert to a resource path
- path = GlobalConfig::get_singleton()->localize_path(state.local_path.get_base_dir() + "/" + path);
+ path = ProjectSettings::get_singleton()->localize_path(state.local_path.get_base_dir() + "/" + path);
} else if (path.find("file:///") == 0) {
path = path.replace_first("file:///", "");
- path = GlobalConfig::get_singleton()->localize_path(path);
+ path = ProjectSettings::get_singleton()->localize_path(path);
}
image.path = path;
@@ -2556,7 +2556,7 @@ Error Collada::load(const String &p_path, int p_flags) {
Error err = parser.open(p_path);
ERR_FAIL_COND_V(err, err);
- state.local_path = GlobalConfig::get_singleton()->localize_path(p_path);
+ state.local_path = ProjectSettings::get_singleton()->localize_path(p_path);
state.import_flags = p_flags;
/* Skip headers */
err = OK;
diff --git a/editor/collada/collada.h b/editor/collada/collada.h
index ca60c392dd..8945e14cce 100644
--- a/editor/collada/collada.h
+++ b/editor/collada/collada.h
@@ -32,9 +32,9 @@
#ifndef COLLADA_H
#define COLLADA_H
-#include "global_config.h"
#include "io/xml_parser.h"
#include "map.h"
+#include "project_settings.h"
#include "scene/resources/material.h"
class Collada {
diff --git a/editor/doc/doc_data.cpp b/editor/doc/doc_data.cpp
index 6a79f99354..69d7475f4c 100644
--- a/editor/doc/doc_data.cpp
+++ b/editor/doc/doc_data.cpp
@@ -29,10 +29,10 @@
/*************************************************************************/
#include "doc_data.h"
-#include "global_config.h"
#include "global_constants.h"
#include "io/compression.h"
#include "io/marshalls.h"
+#include "project_settings.h"
#include "scene/resources/theme.h"
#include "script_language.h"
#include "version.h"
@@ -568,14 +568,14 @@ void DocData::generate(bool p_basic_types) {
c.constants.push_back(cd);
}
- List<GlobalConfig::Singleton> singletons;
- GlobalConfig::get_singleton()->get_singletons(&singletons);
+ List<ProjectSettings::Singleton> singletons;
+ ProjectSettings::get_singleton()->get_singletons(&singletons);
//servers (this is kind of hackish)
- for (List<GlobalConfig::Singleton>::Element *E = singletons.front(); E; E = E->next()) {
+ for (List<ProjectSettings::Singleton>::Element *E = singletons.front(); E; E = E->next()) {
PropertyDoc pd;
- GlobalConfig::Singleton &s = E->get();
+ ProjectSettings::Singleton &s = E->get();
pd.name = s.name;
pd.type = s.ptr->get_class();
while (String(ClassDB::get_parent_class(pd.type)) != "Object")
diff --git a/editor/editor_about.cpp b/editor/editor_about.cpp
new file mode 100644
index 0000000000..fd90c766fd
--- /dev/null
+++ b/editor/editor_about.cpp
@@ -0,0 +1,209 @@
+/*************************************************************************/
+/* editor_about.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+#include "editor_about.h"
+
+#include "authors.gen.h"
+#include "license.gen.h"
+#include "version.h"
+#include "version_hash.gen.h"
+
+void EditorAbout::_license_tree_selected() {
+
+ TreeItem *selected = _tpl_tree->get_selected();
+ _tpl_text->select(0, 0, 0, 0);
+ _tpl_text->set_text(selected->get_metadata(0));
+}
+
+void EditorAbout::_bind_methods() {
+
+ ClassDB::bind_method(D_METHOD("_license_tree_selected"), &EditorAbout::_license_tree_selected);
+}
+
+TextureRect *EditorAbout::get_logo() const {
+
+ return _logo;
+}
+
+EditorAbout::EditorAbout() {
+
+ set_title(TTR("Thanks from the Godot community!"));
+ get_ok()->set_text(TTR("Thanks!"));
+ set_hide_on_ok(true);
+ set_resizable(true);
+
+ VBoxContainer *vbc = memnew(VBoxContainer);
+ HBoxContainer *hbc = memnew(HBoxContainer);
+ hbc->set_h_size_flags(Control::SIZE_EXPAND_FILL);
+ hbc->set_alignment(BoxContainer::ALIGN_CENTER);
+ hbc->add_constant_override("separation", 30 * EDSCALE);
+ add_child(vbc);
+ vbc->add_child(hbc);
+
+ _logo = memnew(TextureRect);
+ hbc->add_child(_logo);
+
+ String hash = String(VERSION_HASH);
+ if (hash.length() != 0)
+ hash = "." + hash.left(7);
+
+ Label *about_text = memnew(Label);
+ about_text->set_v_size_flags(Control::SIZE_SHRINK_CENTER);
+ about_text->set_text(VERSION_FULL_NAME + hash + String::utf8("\n\u00A9 2007-2017 Juan Linietsky, Ariel Manzur.\n\u00A9 2014-2017 ") +
+ TTR("Godot Engine contributors") + "\n");
+ hbc->add_child(about_text);
+
+ TabContainer *tc = memnew(TabContainer);
+ tc->set_custom_minimum_size(Size2(630, 240) * EDSCALE);
+ tc->set_v_size_flags(Control::SIZE_EXPAND_FILL);
+ vbc->add_child(tc);
+
+ ScrollContainer *dev_base = memnew(ScrollContainer);
+ dev_base->set_name(TTR("Authors"));
+ dev_base->set_v_size_flags(Control::SIZE_EXPAND);
+ tc->add_child(dev_base);
+
+ VBoxContainer *dev_vbc = memnew(VBoxContainer);
+ dev_vbc->set_h_size_flags(Control::SIZE_EXPAND_FILL);
+ dev_base->add_child(dev_vbc);
+
+ List<String> dev_sections;
+ dev_sections.push_back(TTR("Project Founders"));
+ dev_sections.push_back(TTR("Lead Developer"));
+ dev_sections.push_back(TTR("Project Manager"));
+ dev_sections.push_back(TTR("Developers"));
+
+ const char **dev_src[] = { dev_founders, dev_lead, dev_manager, dev_names };
+
+ for (int i = 0; i < dev_sections.size(); i++) {
+
+ Label *lbl = memnew(Label);
+ lbl->set_text(dev_sections[i]);
+ dev_vbc->add_child(lbl);
+
+ ItemList *il = memnew(ItemList);
+ il->set_max_columns(16);
+ il->set_h_size_flags(Control::SIZE_EXPAND_FILL);
+ il->set_fixed_column_width(230 * EDSCALE);
+ il->set_auto_height(true);
+ const char **dev_names_ptr = dev_src[i];
+ while (*dev_names_ptr)
+ il->add_item(String::utf8(*dev_names_ptr++), NULL, false);
+ dev_vbc->add_child(il);
+
+ HSeparator *hs = memnew(HSeparator);
+ hs->set_modulate(Color(0, 0, 0, 0));
+ dev_vbc->add_child(hs);
+ }
+
+ TextEdit *license = memnew(TextEdit);
+ license->set_name(TTR("License"));
+ license->set_h_size_flags(Control::SIZE_EXPAND_FILL);
+ license->set_v_size_flags(Control::SIZE_EXPAND_FILL);
+ license->set_wrap(true);
+ license->set_readonly(true);
+ license->set_text(String::utf8(about_license));
+ tc->add_child(license);
+
+ VBoxContainer *license_thirdparty = memnew(VBoxContainer);
+ license_thirdparty->set_name(TTR("Thirdparty License"));
+ license_thirdparty->set_h_size_flags(Control::SIZE_EXPAND_FILL);
+ tc->add_child(license_thirdparty);
+
+ Label *tpl_label = memnew(Label);
+ tpl_label->set_h_size_flags(Control::SIZE_EXPAND_FILL);
+ tpl_label->set_autowrap(true);
+ tpl_label->set_text(TTR("Godot Engine relies on a number of thirdparty free and open source libraries, all compatible with the terms of its MIT license. The following is an exhaustive list of all such thirdparty components with their respective copyright statements and license terms."));
+ license_thirdparty->add_child(tpl_label);
+
+ HSplitContainer *tpl_hbc = memnew(HSplitContainer);
+ tpl_hbc->set_h_size_flags(Control::SIZE_EXPAND_FILL);
+ tpl_hbc->set_v_size_flags(Control::SIZE_EXPAND_FILL);
+ tpl_hbc->set_split_offset(240 * EDSCALE);
+ license_thirdparty->add_child(tpl_hbc);
+
+ _tpl_tree = memnew(Tree);
+ _tpl_tree->set_hide_root(true);
+ TreeItem *root = _tpl_tree->create_item();
+ TreeItem *tpl_ti_all = _tpl_tree->create_item(root);
+ tpl_ti_all->set_text(0, TTR("All Components"));
+ TreeItem *tpl_ti_tp = _tpl_tree->create_item(root);
+ tpl_ti_tp->set_text(0, TTR("Components"));
+ tpl_ti_tp->set_selectable(0, false);
+ TreeItem *tpl_ti_lc = _tpl_tree->create_item(root);
+ tpl_ti_lc->set_text(0, TTR("Licenses"));
+ tpl_ti_lc->set_selectable(0, false);
+ int read_idx = 0;
+ String long_text = "";
+ for (int i = 0; i < THIRDPARTY_COUNT; i++) {
+
+ TreeItem *ti = _tpl_tree->create_item(tpl_ti_tp);
+ String thirdparty = String(about_thirdparty[i]);
+ ti->set_text(0, thirdparty);
+ String text = thirdparty + "\n";
+ long_text += "- " + thirdparty + "\n\n";
+ for (int j = 0; j < about_tp_copyright_count[i]; j++) {
+
+ text += "\n Files:\n " + String(about_tp_file[read_idx]).replace("\n", "\n ") + "\n";
+ String copyright = String::utf8(" \u00A9 ") + String::utf8(about_tp_copyright[read_idx]).replace("\n", String::utf8("\n \u00A9 "));
+ text += copyright;
+ long_text += copyright;
+ String license = "\n License: " + String(about_tp_license[read_idx]) + "\n";
+ text += license;
+ long_text += license + "\n";
+ read_idx++;
+ }
+ ti->set_metadata(0, text);
+ }
+ for (int i = 0; i < LICENSE_COUNT; i++) {
+
+ TreeItem *ti = _tpl_tree->create_item(tpl_ti_lc);
+ String licensename = String(about_license_name[i]);
+ ti->set_text(0, licensename);
+ long_text += "- " + licensename + "\n\n";
+ String licensebody = String(about_license_body[i]);
+ ti->set_metadata(0, licensebody);
+ long_text += " " + licensebody.replace("\n", "\n ") + "\n\n";
+ }
+ tpl_ti_all->set_metadata(0, long_text);
+ tpl_hbc->add_child(_tpl_tree);
+
+ _tpl_text = memnew(TextEdit);
+ _tpl_text->set_h_size_flags(Control::SIZE_EXPAND_FILL);
+ _tpl_text->set_v_size_flags(Control::SIZE_EXPAND_FILL);
+ _tpl_text->set_wrap(true);
+ _tpl_text->set_readonly(true);
+ tpl_hbc->add_child(_tpl_text);
+
+ _tpl_tree->connect("item_selected", this, "_license_tree_selected");
+ tpl_ti_all->select(0);
+ _tpl_text->set_text(tpl_ti_all->get_metadata(0));
+}
+
+EditorAbout::~EditorAbout() {}
diff --git a/editor/editor_about.h b/editor/editor_about.h
new file mode 100644
index 0000000000..0bde94531a
--- /dev/null
+++ b/editor/editor_about.h
@@ -0,0 +1,70 @@
+/*************************************************************************/
+/* editor_about.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+#ifndef EDITOR_ABOUT_H
+#define EDITOR_ABOUT_H
+
+#include "scene/gui/control.h"
+#include "scene/gui/dialogs.h"
+#include "scene/gui/item_list.h"
+#include "scene/gui/scroll_container.h"
+#include "scene/gui/separator.h"
+#include "scene/gui/split_container.h"
+#include "scene/gui/tab_container.h"
+#include "scene/gui/text_edit.h"
+#include "scene/gui/texture_rect.h"
+#include "scene/gui/tree.h"
+
+#include "editor_scale.h"
+/**
+ @author Juan Linietsky <reduzio@gmail.com>
+*/
+
+class EditorAbout : public AcceptDialog {
+
+ GDCLASS(EditorAbout, AcceptDialog);
+
+private:
+ void _license_tree_selected();
+
+ Tree *_tpl_tree;
+ TextEdit *_tpl_text;
+ TextureRect *_logo;
+
+protected:
+ static void _bind_methods();
+
+public:
+ TextureRect *get_logo() const;
+
+ EditorAbout();
+ ~EditorAbout();
+};
+
+#endif
diff --git a/editor/editor_audio_buses.cpp b/editor/editor_audio_buses.cpp
index e3e5793ec8..08b093aecb 100644
--- a/editor/editor_audio_buses.cpp
+++ b/editor/editor_audio_buses.cpp
@@ -47,6 +47,10 @@ void EditorAudioBus::_notification(int p_what) {
disabled_vu = get_icon("BusVuFrozen", "EditorIcons");
+ solo->set_icon(get_icon("AudioBusSolo", "EditorIcons"));
+ mute->set_icon(get_icon("AudioBusMute", "EditorIcons"));
+ bypass->set_icon(get_icon("AudioBusBypass", "EditorIcons"));
+
prev_active = true;
update_bus();
set_process(true);
@@ -630,24 +634,24 @@ EditorAudioBus::EditorAudioBus(EditorAudioBuses *p_buses) {
vb->add_child(hbc);
hbc->add_spacer();
solo = memnew(ToolButton);
- solo->set_text("S");
solo->set_toggle_mode(true);
+ solo->set_tooltip(TTR("Solo"));
solo->add_color_override("font_color_pressed", Color(0.2, 0.9, 0.2));
solo->add_color_override("font_color_hover", Color(0.6, 0.9, 0.6));
solo->set_focus_mode(FOCUS_NONE);
solo->connect("pressed", this, "_solo_toggled");
hbc->add_child(solo);
mute = memnew(ToolButton);
- mute->set_text("M");
mute->set_toggle_mode(true);
+ mute->set_tooltip(TTR("Mute"));
mute->add_color_override("font_color_pressed", Color(0.9, 0.2, 0.2));
mute->add_color_override("font_color_hover", Color(0.9, 0.6, 0.6));
mute->set_focus_mode(FOCUS_NONE);
mute->connect("pressed", this, "_mute_toggled");
hbc->add_child(mute);
bypass = memnew(ToolButton);
- bypass->set_text("B");
bypass->set_toggle_mode(true);
+ bypass->set_tooltip(TTR("Bypass"));
bypass->add_color_override("font_color_pressed", Color(0.9, 0.9, 0.2));
bypass->add_color_override("font_color_hover", Color(0.9, 0.9, 0.6));
bypass->set_focus_mode(FOCUS_NONE);
diff --git a/editor/editor_autoload_settings.cpp b/editor/editor_autoload_settings.cpp
index b83ac69141..dde94cb334 100644
--- a/editor/editor_autoload_settings.cpp
+++ b/editor/editor_autoload_settings.cpp
@@ -30,8 +30,8 @@
#include "editor_autoload_settings.h"
#include "editor_node.h"
-#include "global_config.h"
#include "global_constants.h"
+#include "project_settings.h"
#define PREVIEW_LIST_MAX_SIZE 10
@@ -115,12 +115,12 @@ void EditorAutoloadSettings::_autoload_add() {
UndoRedo *undo_redo = EditorNode::get_singleton()->get_undo_redo();
undo_redo->create_action(TTR("Add AutoLoad"));
- undo_redo->add_do_property(GlobalConfig::get_singleton(), name, "*" + path);
+ undo_redo->add_do_property(ProjectSettings::get_singleton(), name, "*" + path);
- if (GlobalConfig::get_singleton()->has(name)) {
- undo_redo->add_undo_property(GlobalConfig::get_singleton(), name, GlobalConfig::get_singleton()->get(name));
+ if (ProjectSettings::get_singleton()->has(name)) {
+ undo_redo->add_undo_property(ProjectSettings::get_singleton(), name, ProjectSettings::get_singleton()->get(name));
} else {
- undo_redo->add_undo_property(GlobalConfig::get_singleton(), name, Variant());
+ undo_redo->add_undo_property(ProjectSettings::get_singleton(), name, Variant());
}
undo_redo->add_do_method(this, "update_autoload");
@@ -169,7 +169,7 @@ void EditorAutoloadSettings::_autoload_edited() {
return;
}
- if (GlobalConfig::get_singleton()->has("autoload/" + name)) {
+ if (ProjectSettings::get_singleton()->has("autoload/" + name)) {
ti->set_text(0, old_name);
EditorNode::get_singleton()->show_warning(vformat(TTR("Autoload '%s' already exists!"), name));
return;
@@ -179,18 +179,18 @@ void EditorAutoloadSettings::_autoload_edited() {
name = "autoload/" + name;
- int order = GlobalConfig::get_singleton()->get_order(selected_autoload);
- String path = GlobalConfig::get_singleton()->get(selected_autoload);
+ int order = ProjectSettings::get_singleton()->get_order(selected_autoload);
+ String path = ProjectSettings::get_singleton()->get(selected_autoload);
undo_redo->create_action(TTR("Rename Autoload"));
- undo_redo->add_do_property(GlobalConfig::get_singleton(), name, path);
- undo_redo->add_do_method(GlobalConfig::get_singleton(), "set_order", name, order);
- undo_redo->add_do_method(GlobalConfig::get_singleton(), "clear", selected_autoload);
+ undo_redo->add_do_property(ProjectSettings::get_singleton(), name, path);
+ undo_redo->add_do_method(ProjectSettings::get_singleton(), "set_order", name, order);
+ undo_redo->add_do_method(ProjectSettings::get_singleton(), "clear", selected_autoload);
- undo_redo->add_undo_property(GlobalConfig::get_singleton(), selected_autoload, path);
- undo_redo->add_undo_method(GlobalConfig::get_singleton(), "set_order", selected_autoload, order);
- undo_redo->add_undo_method(GlobalConfig::get_singleton(), "clear", name);
+ undo_redo->add_undo_property(ProjectSettings::get_singleton(), selected_autoload, path);
+ undo_redo->add_undo_method(ProjectSettings::get_singleton(), "set_order", selected_autoload, order);
+ undo_redo->add_undo_method(ProjectSettings::get_singleton(), "clear", name);
undo_redo->add_do_method(this, "update_autoload");
undo_redo->add_undo_method(this, "update_autoload");
@@ -207,8 +207,8 @@ void EditorAutoloadSettings::_autoload_edited() {
bool checked = ti->is_checked(2);
String base = "autoload/" + ti->get_text(0);
- int order = GlobalConfig::get_singleton()->get_order(base);
- String path = GlobalConfig::get_singleton()->get(base);
+ int order = ProjectSettings::get_singleton()->get_order(base);
+ String path = ProjectSettings::get_singleton()->get(base);
if (path.begins_with("*"))
path = path.substr(1, path.length());
@@ -218,11 +218,11 @@ void EditorAutoloadSettings::_autoload_edited() {
undo_redo->create_action(TTR("Toggle AutoLoad Globals"));
- undo_redo->add_do_property(GlobalConfig::get_singleton(), base, path);
- undo_redo->add_undo_property(GlobalConfig::get_singleton(), base, GlobalConfig::get_singleton()->get(base));
+ undo_redo->add_do_property(ProjectSettings::get_singleton(), base, path);
+ undo_redo->add_undo_property(ProjectSettings::get_singleton(), base, ProjectSettings::get_singleton()->get(base));
- undo_redo->add_do_method(GlobalConfig::get_singleton(), "set_order", base, order);
- undo_redo->add_undo_method(GlobalConfig::get_singleton(), "set_order", base, order);
+ undo_redo->add_do_method(ProjectSettings::get_singleton(), "set_order", base, order);
+ undo_redo->add_undo_method(ProjectSettings::get_singleton(), "set_order", base, order);
undo_redo->add_do_method(this, "update_autoload");
undo_redo->add_undo_method(this, "update_autoload");
@@ -262,16 +262,16 @@ void EditorAutoloadSettings::_autoload_button_pressed(Object *p_item, int p_colu
String swap_name = "autoload/" + swap->get_text(0);
- int order = GlobalConfig::get_singleton()->get_order(name);
- int swap_order = GlobalConfig::get_singleton()->get_order(swap_name);
+ int order = ProjectSettings::get_singleton()->get_order(name);
+ int swap_order = ProjectSettings::get_singleton()->get_order(swap_name);
undo_redo->create_action(TTR("Move Autoload"));
- undo_redo->add_do_method(GlobalConfig::get_singleton(), "set_order", name, swap_order);
- undo_redo->add_undo_method(GlobalConfig::get_singleton(), "set_order", name, order);
+ undo_redo->add_do_method(ProjectSettings::get_singleton(), "set_order", name, swap_order);
+ undo_redo->add_undo_method(ProjectSettings::get_singleton(), "set_order", name, order);
- undo_redo->add_do_method(GlobalConfig::get_singleton(), "set_order", swap_name, order);
- undo_redo->add_undo_method(GlobalConfig::get_singleton(), "set_order", swap_name, swap_order);
+ undo_redo->add_do_method(ProjectSettings::get_singleton(), "set_order", swap_name, order);
+ undo_redo->add_undo_method(ProjectSettings::get_singleton(), "set_order", swap_name, swap_order);
undo_redo->add_do_method(this, "update_autoload");
undo_redo->add_undo_method(this, "update_autoload");
@@ -283,15 +283,15 @@ void EditorAutoloadSettings::_autoload_button_pressed(Object *p_item, int p_colu
} break;
case BUTTON_DELETE: {
- int order = GlobalConfig::get_singleton()->get_order(name);
+ int order = ProjectSettings::get_singleton()->get_order(name);
undo_redo->create_action(TTR("Remove Autoload"));
- undo_redo->add_do_property(GlobalConfig::get_singleton(), name, Variant());
+ undo_redo->add_do_property(ProjectSettings::get_singleton(), name, Variant());
- undo_redo->add_undo_property(GlobalConfig::get_singleton(), name, GlobalConfig::get_singleton()->get(name));
- undo_redo->add_undo_method(GlobalConfig::get_singleton(), "set_persisting", name, true);
- undo_redo->add_undo_method(GlobalConfig::get_singleton(), "set_order", order);
+ undo_redo->add_undo_property(ProjectSettings::get_singleton(), name, ProjectSettings::get_singleton()->get(name));
+ undo_redo->add_undo_method(ProjectSettings::get_singleton(), "set_persisting", name, true);
+ undo_redo->add_undo_method(ProjectSettings::get_singleton(), "set_order", order);
undo_redo->add_do_method(this, "update_autoload");
undo_redo->add_undo_method(this, "update_autoload");
@@ -322,7 +322,7 @@ void EditorAutoloadSettings::update_autoload() {
TreeItem *root = tree->create_item();
List<PropertyInfo> props;
- GlobalConfig::get_singleton()->get_property_list(&props);
+ ProjectSettings::get_singleton()->get_property_list(&props);
for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) {
@@ -332,14 +332,14 @@ void EditorAutoloadSettings::update_autoload() {
continue;
String name = pi.name.get_slice("/", 1);
- String path = GlobalConfig::get_singleton()->get(pi.name);
+ String path = ProjectSettings::get_singleton()->get(pi.name);
if (name.empty())
continue;
AutoLoadInfo info;
info.name = pi.name;
- info.order = GlobalConfig::get_singleton()->get_order(pi.name);
+ info.order = ProjectSettings::get_singleton()->get_order(pi.name);
autoload_cache.push_back(info);
@@ -459,7 +459,7 @@ void EditorAutoloadSettings::drop_data_fw(const Point2 &p_point, const Variant &
move_to_back = true;
}
- int order = GlobalConfig::get_singleton()->get_order("autoload/" + name);
+ int order = ProjectSettings::get_singleton()->get_order("autoload/" + name);
AutoLoadInfo aux;
List<AutoLoadInfo>::Element *E = NULL;
@@ -476,7 +476,7 @@ void EditorAutoloadSettings::drop_data_fw(const Point2 &p_point, const Variant &
orders.resize(autoload_cache.size());
for (int i = 0; i < autoloads.size(); i++) {
- aux.order = GlobalConfig::get_singleton()->get_order("autoload/" + autoloads[i]);
+ aux.order = ProjectSettings::get_singleton()->get_order("autoload/" + autoloads[i]);
List<AutoLoadInfo>::Element *I = autoload_cache.find(aux);
@@ -506,8 +506,8 @@ void EditorAutoloadSettings::drop_data_fw(const Point2 &p_point, const Variant &
i = 0;
for (List<AutoLoadInfo>::Element *E = autoload_cache.front(); E; E = E->next()) {
- undo_redo->add_do_method(GlobalConfig::get_singleton(), "set_order", E->get().name, orders[i++]);
- undo_redo->add_undo_method(GlobalConfig::get_singleton(), "set_order", E->get().name, E->get().order);
+ undo_redo->add_do_method(ProjectSettings::get_singleton(), "set_order", E->get().name, orders[i++]);
+ undo_redo->add_undo_method(ProjectSettings::get_singleton(), "set_order", E->get().name, E->get().order);
}
orders.clear();
diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp
index 58ffa223fb..c82e8f1226 100644
--- a/editor/editor_data.cpp
+++ b/editor/editor_data.cpp
@@ -31,10 +31,10 @@
#include "editor_node.h"
#include "editor_settings.h"
-#include "global_config.h"
#include "io/resource_loader.h"
#include "os/dir_access.h"
#include "os/file_access.h"
+#include "project_settings.h"
#include "scene/resources/packed_scene.h"
void EditorHistory::_cleanup_history() {
@@ -353,6 +353,7 @@ void EditorData::notify_edited_scene_changed() {
for (int i = 0; i < editor_plugins.size(); i++) {
editor_plugins[i]->edited_scene_changed();
+ editor_plugins[i]->notify_scene_changed(get_edited_scene_root());
}
}
@@ -488,8 +489,14 @@ void EditorData::move_edited_scene_index(int p_idx, int p_to_idx) {
}
void EditorData::remove_scene(int p_idx) {
ERR_FAIL_INDEX(p_idx, edited_scene.size());
- if (edited_scene[p_idx].root)
+ if (edited_scene[p_idx].root) {
+
+ for (int i = 0; i < editor_plugins.size(); i++) {
+ editor_plugins[i]->notify_scene_closed(edited_scene[p_idx].root->get_filename());
+ }
+
memdelete(edited_scene[p_idx].root);
+ }
if (current_edited_scene > p_idx)
current_edited_scene--;
@@ -615,6 +622,17 @@ int EditorData::get_edited_scene_count() const {
return edited_scene.size();
}
+Vector<EditorData::EditedScene> EditorData::get_edited_scenes() const {
+
+ Vector<EditedScene> out_edited_scenes_list = Vector<EditedScene>();
+
+ for (int i = 0; i < edited_scene.size(); i++) {
+ out_edited_scenes_list.push_back(edited_scene[i]);
+ }
+
+ return out_edited_scenes_list;
+}
+
void EditorData::set_edited_scene_version(uint64_t version, int scene_idx) {
ERR_FAIL_INDEX(current_edited_scene, edited_scene.size());
if (scene_idx < 0) {
diff --git a/editor/editor_data.h b/editor/editor_data.h
index 50f0d5fd41..a601b5019d 100644
--- a/editor/editor_data.h
+++ b/editor/editor_data.h
@@ -31,6 +31,7 @@
#define EDITOR_DATA_H
#include "editor/editor_plugin.h"
+#include "editor/plugins/script_editor_plugin.h"
#include "list.h"
#include "pair.h"
#include "scene/resources/texture.h"
@@ -109,6 +110,17 @@ public:
Ref<Texture> icon;
};
+ struct EditedScene {
+ Node *root;
+ Dictionary editor_states;
+ List<Node *> selection;
+ Vector<EditorHistory::History> history_stored;
+ int history_current;
+ Dictionary custom_state;
+ uint64_t version;
+ NodePath live_edit_root;
+ };
+
private:
Vector<EditorPlugin *> editor_plugins;
@@ -124,17 +136,6 @@ private:
void _cleanup_history();
- struct EditedScene {
- Node *root;
- Dictionary editor_states;
- List<Node *> selection;
- Vector<EditorHistory::History> history_stored;
- int history_current;
- Dictionary custom_state;
- uint64_t version;
- NodePath live_edit_root;
- };
-
Vector<EditedScene> edited_scene;
int current_edited_scene;
@@ -180,6 +181,7 @@ public:
int get_edited_scene() const;
Node *get_edited_scene_root(int p_idx = -1);
int get_edited_scene_count() const;
+ Vector<EditedScene> get_edited_scenes() const;
String get_scene_title(int p_idx) const;
String get_scene_path(int p_idx) const;
String get_scene_type(int p_idx) const;
diff --git a/editor/editor_export.cpp b/editor/editor_export.cpp
index 5cd00738a2..6bf92ddd2d 100644
--- a/editor/editor_export.cpp
+++ b/editor/editor_export.cpp
@@ -33,13 +33,13 @@
#include "editor/plugins/script_editor_plugin.h"
#include "editor_node.h"
#include "editor_settings.h"
-#include "global_config.h"
#include "io/config_file.h"
#include "io/resource_loader.h"
#include "io/resource_saver.h"
#include "io/zip_io.h"
#include "os/dir_access.h"
#include "os/file_access.h"
+#include "project_settings.h"
#include "script_language.h"
#include "version.h"
@@ -200,6 +200,17 @@ Vector<String> EditorExportPreset::get_patches() const {
return patches;
}
+void EditorExportPreset::set_custom_features(const String &p_custom_features) {
+
+ custom_features = p_custom_features;
+ EditorExport::singleton->save_presets();
+}
+
+String EditorExportPreset::get_custom_features() const {
+
+ return custom_features;
+}
+
EditorExportPreset::EditorExportPreset() {
export_filter = EXPORT_ALL_RESOURCES;
@@ -491,9 +502,23 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> &
//save config!
- String config_file = "godot.cfb";
+ Vector<String> custom_list;
+
+ if (p_preset->get_custom_features() != String()) {
+
+ Vector<String> tmp_custom_list = p_preset->get_custom_features().split(",");
+
+ for (int i = 0; i < tmp_custom_list.size(); i++) {
+ String f = tmp_custom_list[i].strip_edges();
+ if (f != String()) {
+ custom_list.push_back(f);
+ }
+ }
+ }
+
+ String config_file = "project.binary";
String engine_cfb = EditorSettings::get_singleton()->get_settings_path() + "/tmp/tmp" + config_file;
- GlobalConfig::get_singleton()->save_custom(engine_cfb);
+ ProjectSettings::get_singleton()->save_custom(engine_cfb, ProjectSettings::CustomMap(), custom_list);
Vector<uint8_t> data = FileAccess::get_file_as_array(engine_cfb);
p_func(p_udata, "res://" + config_file, data, idx, total);
@@ -691,6 +716,7 @@ void EditorExport::_save() {
config->set_value(section, "name", preset->get_name());
config->set_value(section, "platform", preset->get_platform()->get_name());
config->set_value(section, "runnable", preset->is_runnable());
+ config->set_value(section, "custom_features", preset->get_custom_features());
bool save_files = false;
switch (preset->get_export_filter()) {
case EditorExportPreset::EXPORT_ALL_RESOURCES: {
@@ -823,6 +849,10 @@ void EditorExport::load_config() {
preset->set_name(config->get_value(section, "name"));
preset->set_runnable(config->get_value(section, "runnable"));
+ if (config->has_section_key(section, "custom_features")) {
+ preset->set_custom_features(config->get_value(section, "custom_features"));
+ }
+
String export_filter = config->get_value(section, "export_filter");
bool get_files = false;
@@ -931,6 +961,11 @@ String EditorExportPlatformPC::get_name() const {
return name;
}
+
+String EditorExportPlatformPC::get_os_name() const {
+
+ return os_name;
+}
Ref<Texture> EditorExportPlatformPC::get_logo() const {
return logo;
@@ -1033,6 +1068,10 @@ void EditorExportPlatformPC::set_name(const String &p_name) {
name = p_name;
}
+void EditorExportPlatformPC::set_os_name(const String &p_name) {
+ os_name = p_name;
+}
+
void EditorExportPlatformPC::set_logo(const Ref<Texture> &p_logo) {
logo = p_logo;
}
@@ -1055,6 +1094,20 @@ void EditorExportPlatformPC::set_debug_32(const String &p_file) {
debug_file_32 = p_file;
}
+void EditorExportPlatformPC::add_platform_feature(const String &p_feature) {
+
+ extra_features.insert(p_feature);
+}
+
+void EditorExportPlatformPC::get_platform_features(List<String> *r_features) {
+ r_features->push_back("pc"); //all pcs support "pc"
+ r_features->push_back("s3tc"); //all pcs support "s3tc" compression
+ r_features->push_back(get_os_name()); //OS name is a feature
+ for (Set<String>::Element *E = extra_features.front(); E; E = E->next()) {
+ r_features->push_back(E->get());
+ }
+}
+
EditorExportPlatformPC::EditorExportPlatformPC() {
}
@@ -1065,7 +1118,6 @@ EditorExportPlatformPC::EditorExportPlatformPC() {
#include "editor/plugins/script_editor_plugin.h"
#include "editor_node.h"
#include "editor_settings.h"
-#include "global_config.h"
#include "io/config_file.h"
#include "io/md5.h"
#include "io/resource_loader.h"
@@ -1074,14 +1126,15 @@ EditorExportPlatformPC::EditorExportPlatformPC() {
#include "io_plugins/editor_texture_import_plugin.h"
#include "os/dir_access.h"
#include "os/file_access.h"
+#include "project_settings.h"
#include "script_language.h"
#include "version.h"
String EditorImportPlugin::validate_source_path(const String& p_path) {
- String gp = GlobalConfig::get_singleton()->globalize_path(p_path);
- String rp = GlobalConfig::get_singleton()->get_resource_path();
+ String gp = ProjectSettings::get_singleton()->globalize_path(p_path);
+ String rp = ProjectSettings::get_singleton()->get_resource_path();
if (!rp.ends_with("/"))
rp+="/";
@@ -1091,7 +1144,7 @@ String EditorImportPlugin::validate_source_path(const String& p_path) {
String EditorImportPlugin::expand_source_path(const String& p_path) {
if (p_path.is_rel_path()) {
- return GlobalConfig::get_singleton()->get_resource_path().plus_file(p_path).simplify_path();
+ return ProjectSettings::get_singleton()->get_resource_path().plus_file(p_path).simplify_path();
} else {
return p_path;
}
@@ -1766,7 +1819,7 @@ Error EditorExportPlatform::export_project_files(EditorExportSaveFunction p_func
{
MD5_CTX ctx;
MD5Init(&ctx);
- String path = GlobalConfig::get_singleton()->get_resource_path()+"::"+String(E->get())+"::"+get_name();
+ String path = ProjectSettings::get_singleton()->get_resource_path()+"::"+String(E->get())+"::"+get_name();
MD5Update(&ctx,(unsigned char*)path.utf8().get_data(),path.utf8().length());
MD5Final(&ctx);
md5 = String::md5(ctx.digest);
@@ -1875,11 +1928,11 @@ Error EditorExportPlatform::export_project_files(EditorExportSaveFunction p_func
int flags=0;
- if (GlobalConfig::get_singleton()->get("image_loader/filter"))
+ if (ProjectSettings::get_singleton()->get("image_loader/filter"))
flags|=EditorTextureImportPlugin::IMAGE_FLAG_FILTER;
- if (!GlobalConfig::get_singleton()->get("image_loader/gen_mipmaps"))
+ if (!ProjectSettings::get_singleton()->get("image_loader/gen_mipmaps"))
flags|=EditorTextureImportPlugin::IMAGE_FLAG_NO_MIPMAPS;
- if (!GlobalConfig::get_singleton()->get("image_loader/repeat"))
+ if (!ProjectSettings::get_singleton()->get("image_loader/repeat"))
flags|=EditorTextureImportPlugin::IMAGE_FLAG_REPEAT;
flags|=EditorTextureImportPlugin::IMAGE_FLAG_FIX_BORDER_ALPHA;
@@ -1988,7 +2041,7 @@ Error EditorExportPlatform::export_project_files(EditorExportSaveFunction p_func
StringName engine_cfg="res://project.godot";
StringName boot_splash;
{
- String splash=GlobalConfig::get_singleton()->get("application/boot_splash"); //avoid splash from being converted
+ String splash=ProjectSettings::get_singleton()->get("application/boot_splash"); //avoid splash from being converted
splash=splash.strip_edges();
if (splash!=String()) {
if (!splash.begins_with("res://"))
@@ -1999,7 +2052,7 @@ Error EditorExportPlatform::export_project_files(EditorExportSaveFunction p_func
}
StringName custom_cursor;
{
- String splash=GlobalConfig::get_singleton()->get("display/custom_mouse_cursor"); //avoid splash from being converted
+ String splash=ProjectSettings::get_singleton()->get("display/custom_mouse_cursor"); //avoid splash from being converted
splash=splash.strip_edges();
if (splash!=String()) {
if (!splash.begins_with("res://"))
@@ -2083,9 +2136,9 @@ Error EditorExportPlatform::export_project_files(EditorExportSaveFunction p_func
}
- String remap_file="godot.cfb";
+ String remap_file="project.binary";
String engine_cfb =EditorSettings::get_singleton()->get_settings_path()+"/tmp/tmp"+remap_file;
- GlobalConfig::get_singleton()->save_custom(engine_cfb,custom);
+ ProjectSettings::get_singleton()->save_custom(engine_cfb,custom);
Vector<uint8_t> data = FileAccess::get_file_as_array(engine_cfb);
Error err = p_func(p_udata,"res://"+remap_file,data,counter,files.size());
diff --git a/editor/editor_export.h b/editor/editor_export.h
index 64381fbb35..dc4b198575 100644
--- a/editor/editor_export.h
+++ b/editor/editor_export.h
@@ -70,6 +70,8 @@ private:
String name;
+ String custom_features;
+
protected:
bool _set(const StringName &p_name, const Variant &p_value);
bool _get(const StringName &p_name, Variant &r_ret) const;
@@ -107,6 +109,9 @@ public:
void remove_patch(int p_idx);
Vector<String> get_patches() const;
+ void set_custom_features(const String &p_custom_features);
+ String get_custom_features() const;
+
const List<PropertyInfo> &get_properties() const { return properties; }
EditorExportPreset();
@@ -153,12 +158,13 @@ private:
static Error _save_zip_file(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total);
protected:
- virtual void get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) = 0;
bool exists_export_template(String template_file_name, String *err) const;
String find_export_template(String template_file_name, String *err = NULL) const;
void gen_export_flags(Vector<String> &r_flags, int p_flags);
public:
+ virtual void get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) = 0;
+
struct ExportOption {
PropertyInfo option;
Variant default_value;
@@ -175,6 +181,7 @@ public:
virtual void get_export_options(List<ExportOption> *r_options) = 0;
virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const { return true; }
+ virtual String get_os_name() const = 0;
virtual String get_name() const = 0;
virtual Ref<Texture> get_logo() const = 0;
@@ -203,6 +210,7 @@ public:
virtual String get_binary_extension() const = 0;
virtual Error export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0) = 0;
+ virtual void get_platform_features(List<String> *r_features) = 0;
EditorExportPlatform();
};
@@ -253,6 +261,7 @@ class EditorExportPlatformPC : public EditorExportPlatform {
Ref<ImageTexture> logo;
String name;
+ String os_name;
String extension;
String release_file_32;
@@ -260,6 +269,8 @@ class EditorExportPlatformPC : public EditorExportPlatform {
String debug_file_32;
String debug_file_64;
+ Set<String> extra_features;
+
bool use64;
public:
@@ -268,6 +279,7 @@ public:
virtual void get_export_options(List<ExportOption> *r_options);
virtual String get_name() const;
+ virtual String get_os_name() const;
virtual Ref<Texture> get_logo() const;
virtual bool can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const;
@@ -276,6 +288,7 @@ public:
void set_extension(const String &p_extension);
void set_name(const String &p_name);
+ void set_os_name(const String &p_name);
void set_logo(const Ref<Texture> &p_loco);
@@ -284,6 +297,9 @@ public:
void set_debug_64(const String &p_file);
void set_debug_32(const String &p_file);
+ void add_platform_feature(const String &p_feature);
+ virtual void get_platform_features(List<String> *r_features);
+
EditorExportPlatformPC();
};
diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp
index f314f772d1..ed58116304 100644
--- a/editor/editor_file_system.cpp
+++ b/editor/editor_file_system.cpp
@@ -32,12 +32,12 @@
#include "editor_node.h"
#include "editor_resource_preview.h"
#include "editor_settings.h"
-#include "global_config.h"
#include "io/resource_import.h"
#include "io/resource_loader.h"
#include "io/resource_saver.h"
#include "os/file_access.h"
#include "os/os.h"
+#include "project_settings.h"
#include "variant_parser.h"
EditorFileSystem *EditorFileSystem::singleton = NULL;
@@ -137,7 +137,7 @@ EditorFileSystemDirectory *EditorFileSystemDirectory::get_parent() {
void EditorFileSystemDirectory::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_subdir_count"), &EditorFileSystemDirectory::get_subdir_count);
- ClassDB::bind_method(D_METHOD("get_subdir", "idx"), &EditorFileSystemDirectory::get_subdir);
+ ClassDB::bind_method(D_METHOD("get_subdir:EditorFileSystemDirectory", "idx"), &EditorFileSystemDirectory::get_subdir);
ClassDB::bind_method(D_METHOD("get_file_count"), &EditorFileSystemDirectory::get_file_count);
ClassDB::bind_method(D_METHOD("get_file", "idx"), &EditorFileSystemDirectory::get_file);
ClassDB::bind_method(D_METHOD("get_file_path", "idx"), &EditorFileSystemDirectory::get_file_path);
@@ -179,7 +179,7 @@ void EditorFileSystem::_scan_filesystem() {
sources_changed.clear();
file_cache.clear();
- String project = GlobalConfig::get_singleton()->get_resource_path();
+ String project = ProjectSettings::get_singleton()->get_resource_path();
String fscache = EditorSettings::get_singleton()->get_project_settings_path().plus_file("filesystem_cache2");
FileAccess *f = FileAccess::open(fscache, FileAccess::READ);
@@ -1008,7 +1008,7 @@ bool EditorFileSystem::_find_file(const String &p_file, EditorFileSystemDirector
if (!filesystem || scanning)
return false;
- String f = GlobalConfig::get_singleton()->localize_path(p_file);
+ String f = ProjectSettings::get_singleton()->localize_path(p_file);
if (!f.begins_with("res://"))
return false;
@@ -1121,7 +1121,7 @@ EditorFileSystemDirectory *EditorFileSystem::get_filesystem_path(const String &p
if (!filesystem || scanning)
return NULL;
- String f = GlobalConfig::get_singleton()->localize_path(p_path);
+ String f = ProjectSettings::get_singleton()->localize_path(p_path);
if (!f.begins_with("res://"))
return NULL;
@@ -1239,7 +1239,7 @@ void EditorFileSystem::_reimport_file(const String &p_file) {
String importer_name;
if (FileAccess::exists(p_file + ".import")) {
-
+ //use existing
Ref<ConfigFile> cf;
cf.instance();
Error err = cf->load(p_file + ".import");
@@ -1254,6 +1254,7 @@ void EditorFileSystem::_reimport_file(const String &p_file) {
}
Ref<ResourceImporter> importer;
+ bool load_default = false;
//find the importer
if (importer_name != "") {
importer = ResourceFormatImporter::get_singleton()->get_importer_by_name(importer_name);
@@ -1262,6 +1263,7 @@ void EditorFileSystem::_reimport_file(const String &p_file) {
if (importer.is_null()) {
//not found by name, find by extension
importer = ResourceFormatImporter::get_singleton()->get_importer_by_extension(p_file.get_extension());
+ load_default = true;
if (importer.is_null()) {
ERR_PRINT("BUG: File queued for import, but can't be imported!");
ERR_FAIL();
@@ -1278,6 +1280,17 @@ void EditorFileSystem::_reimport_file(const String &p_file) {
}
}
+ if (load_default && ProjectSettings::get_singleton()->get("importer_defaults/" + importer->get_importer_name())) {
+ //use defaults if exist
+ Dictionary d = ProjectSettings::get_singleton()->get("importer_defaults/" + importer->get_importer_name());
+ List<Variant> v;
+ d.get_key_list(&v);
+
+ for (List<Variant>::Element *E = v.front(); E; E = E->next()) {
+ params[E->get()] = d[E->get()];
+ }
+ }
+
//finally, perform import!!
String base_path = ResourceFormatImporter::get_singleton()->get_import_base_path(p_file);
@@ -1335,7 +1348,7 @@ void EditorFileSystem::_reimport_file(const String &p_file) {
f->store_line("[params]");
f->store_line("");
- //store options in provided order, to avoid file changing
+ //store options in provided order, to avoid file changing. Order is also important because first match is accepted first.
for (List<ResourceImporter::ImportOption>::Element *E = opts.front(); E; E = E->next()) {
diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp
index 5089468e1d..e890082ee1 100644
--- a/editor/editor_help.cpp
+++ b/editor/editor_help.cpp
@@ -36,7 +36,8 @@
#include "os/keyboard.h"
void EditorHelpSearch::popup() {
- popup_centered_ratio(0.6);
+
+ popup_centered(Size2(700, 600) * EDSCALE);
if (search_box->get_text() != "") {
search_box->select_all();
_update_search();
@@ -46,7 +47,7 @@ void EditorHelpSearch::popup() {
void EditorHelpSearch::popup(const String &p_term) {
- popup_centered_ratio(0.6);
+ popup_centered(Size2(700, 600) * EDSCALE);
if (p_term != "") {
search_box->set_text(p_term);
search_box->select_all();
@@ -262,6 +263,8 @@ void EditorHelpSearch::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE) {
+ search_box->add_icon_override("right_icon", get_icon("Search", "EditorIcons"));
+
connect("confirmed", this, "_confirmed");
_update_search();
}
@@ -293,12 +296,7 @@ EditorHelpSearch::EditorHelpSearch() {
HBoxContainer *sb_hb = memnew(HBoxContainer);
search_box = memnew(LineEdit);
- sb_hb->add_child(search_box);
- search_box->set_h_size_flags(SIZE_EXPAND_FILL);
- Button *sb = memnew(Button(TTR("Search")));
- sb->connect("pressed", this, "_update_search");
- sb_hb->add_child(sb);
- vbc->add_margin_child(TTR("Search:"), sb_hb);
+ vbc->add_child(search_box);
search_box->connect("text_changed", this, "_text_changed");
search_box->connect("gui_input", this, "_sbox_input");
search_options = memnew(Tree);
@@ -378,7 +376,7 @@ void EditorHelpIndex::select_class(const String &p_class) {
void EditorHelpIndex::popup() {
- popup_centered_ratio(0.6);
+ popup_centered(Size2(500, 600) * EDSCALE);
search_box->set_text("");
_update_class_list();
@@ -388,6 +386,7 @@ void EditorHelpIndex::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE) {
+ search_box->add_icon_override("right_icon", get_icon("Search", "EditorIcons"));
_update_class_list();
connect("confirmed", this, "_tree_item_selected");
@@ -478,7 +477,7 @@ EditorHelpIndex::EditorHelpIndex() {
add_child(vbc);
search_box = memnew(LineEdit);
- vbc->add_margin_child(TTR("Search:"), search_box);
+ vbc->add_child(search_box);
search_box->set_h_size_flags(SIZE_EXPAND_FILL);
register_text_enter(search_box);
@@ -1782,8 +1781,8 @@ void EditorHelpBit::_bind_methods() {
void EditorHelpBit::_notification(int p_what) {
- if (p_what == NOTIFICATION_ENTER_TREE) {
- add_style_override("panel", get_stylebox("ScriptPanel", "EditorStyles"));
+ if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) {
+ add_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_stylebox("ScriptPanel", "EditorStyles"));
}
}
@@ -1800,4 +1799,5 @@ EditorHelpBit::EditorHelpBit() {
rich_text->set_area_as_parent_rect(8 * EDSCALE);
rich_text->connect("meta_clicked", this, "_meta_clicked");
set_custom_minimum_size(Size2(0, 70 * EDSCALE));
+ add_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_stylebox("ScriptPanel", "EditorStyles"));
}
diff --git a/editor/editor_name_dialog.cpp b/editor/editor_name_dialog.cpp
index d4c418bfc9..7435e9a9f7 100644
--- a/editor/editor_name_dialog.cpp
+++ b/editor/editor_name_dialog.cpp
@@ -85,7 +85,6 @@ EditorNameDialog::EditorNameDialog() {
add_child(makevb);
name = memnew(LineEdit);
makevb->add_child(name);
- makevb->move_child(name, get_label()->get_index() + 1);
name->set_margin(MARGIN_TOP, 5);
name->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_BEGIN, 5);
name->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, 5);
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 3d119354e1..0cdb981306 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -30,7 +30,6 @@
#include "editor_node.h"
#include "animation_editor.h"
-#include "authors.gen.h"
#include "bind/core_bind.h"
#include "class_db.h"
#include "core/io/resource_loader.h"
@@ -39,7 +38,6 @@
#include "editor_help.h"
#include "editor_settings.h"
#include "editor_themes.h"
-#include "global_config.h"
#include "io/config_file.h"
#include "io/stream_peer_ssl.h"
#include "io/zip_io.h"
@@ -51,6 +49,7 @@
#include "os/os.h"
#include "path_remap.h"
#include "print_string.h"
+#include "project_settings.h"
#include "pvrtc_compress.h"
#include "register_exporters.h"
#include "scene/resources/packed_scene.h"
@@ -162,7 +161,7 @@ void EditorNode::_update_scene_tabs() {
void EditorNode::_update_title() {
- String appname = GlobalConfig::get_singleton()->get("application/name");
+ String appname = ProjectSettings::get_singleton()->get("application/config/name");
String title = appname.empty() ? String(VERSION_FULL_NAME) : String(_MKSTR(VERSION_NAME) + String(" - ") + appname);
String edited = editor_data.get_edited_scene_root() ? editor_data.get_edited_scene_root()->get_filename() : String();
if (!edited.empty())
@@ -271,7 +270,7 @@ void EditorNode::_notification(int p_what) {
}
editor_selection->update();
- scene_root->set_size_override(true, Size2(GlobalConfig::get_singleton()->get("display/window/width"), GlobalConfig::get_singleton()->get("display/window/height")));
+ scene_root->set_size_override(true, Size2(ProjectSettings::get_singleton()->get("display/window/size/width"), ProjectSettings::get_singleton()->get("display/window/size/height")));
ResourceImporterTexture::get_singleton()->update_imports();
}
@@ -340,7 +339,7 @@ void EditorNode::_notification(int p_what) {
gui_base->add_style_override("panel", gui_base->get_stylebox("Background", "EditorStyles"));
play_button_panel->add_style_override("panel", gui_base->get_stylebox("PlayButtonPanel", "EditorStyles"));
scene_root_parent->add_style_override("panel", gui_base->get_stylebox("Content", "EditorStyles"));
- bottom_panel->add_style_override("panel", gui_base->get_stylebox("Content", "EditorStyles"));
+ bottom_panel->add_style_override("panel", gui_base->get_stylebox("panel", "TabContainer"));
scene_tabs->add_style_override("tab_fg", gui_base->get_stylebox("SceneTabFG", "EditorStyles"));
scene_tabs->add_style_override("tab_bg", gui_base->get_stylebox("SceneTabBG", "EditorStyles"));
if (bool(EDITOR_DEF("interface/scene_tabs/resize_if_many_tabs", true))) {
@@ -416,6 +415,8 @@ void EditorNode::_fs_changed() {
}
}
}
+
+ _mark_unsaved_scenes();
}
void EditorNode::_sources_changed(bool p_exist) {
@@ -516,7 +517,7 @@ void EditorNode::save_resource_in_path(const Ref<Resource> &p_resource, const St
flg|=ResourceSaver::FLAG_RELATIVE_PATHS;
*/
- String path = GlobalConfig::get_singleton()->localize_path(p_path);
+ String path = ProjectSettings::get_singleton()->localize_path(p_path);
Error err = ResourceSaver::save(path, p_resource, flg | ResourceSaver::FLAG_REPLACE_SUBRESOURCE_PATHS);
if (err != OK) {
@@ -867,7 +868,7 @@ void EditorNode::_save_scene_with_preview(String p_file) {
//save thumbnail directly, as thumbnailer may not update due to actual scene not changing md5
String temp_path = EditorSettings::get_singleton()->get_settings_path().plus_file("tmp");
- String cache_base = GlobalConfig::get_singleton()->globalize_path(p_file).md5_text();
+ String cache_base = ProjectSettings::get_singleton()->globalize_path(p_file).md5_text();
cache_base = temp_path.plus_file("resthumb-" + cache_base);
//does not have it, try to load a cached thumbnail
@@ -947,7 +948,7 @@ void EditorNode::_save_scene(String p_file, int idx) {
_save_edited_subresources(scene, processed, flg);
editor_data.save_editor_external_data();
if (err == OK) {
- scene->set_filename(GlobalConfig::get_singleton()->localize_path(p_file));
+ scene->set_filename(ProjectSettings::get_singleton()->localize_path(p_file));
//EditorFileSystem::get_singleton()->update_file(p_file,sdata->get_type());
if (idx < 0 || idx == editor_data.get_edited_scene())
set_current_version(editor_data.get_undo_redo().get_version());
@@ -978,6 +979,29 @@ void EditorNode::_save_all_scenes() {
_save_default_environment();
}
+void EditorNode::_mark_unsaved_scenes() {
+
+ for (int i = 0; i < editor_data.get_edited_scene_count(); i++) {
+
+ Node *node = editor_data.get_edited_scene_root(i);
+ if (!node)
+ continue;
+
+ String path = node->get_filename();
+ if (!(path == String() || FileAccess::exists(path))) {
+
+ node->set_filename("");
+ if (i == editor_data.get_edited_scene())
+ set_current_version(-1);
+ else
+ editor_data.set_edited_scene_version(-1, i);
+ }
+ }
+
+ _update_title();
+ _update_scene_tabs();
+}
+
void EditorNode::_import_action(const String &p_action) {
#if 0
import_confirmation->hide();
@@ -1003,7 +1027,7 @@ void EditorNode::_import_action(const String &p_action) {
EditorImport::generate_version_hashes(src);
- Node *dst = SceneLoader::load(editor_data.get_imported_scene(GlobalConfig::get_singleton()->localize_path(_tmp_import_path)));
+ Node *dst = SceneLoader::load(editor_data.get_imported_scene(ProjectSettings::get_singleton()->localize_path(_tmp_import_path)));
if (!dst) {
@@ -1106,8 +1130,8 @@ void EditorNode::_dialog_action(String p_file) {
} break;
case SETTINGS_PICK_MAIN_SCENE: {
- GlobalConfig::get_singleton()->set("application/main_scene", p_file);
- GlobalConfig::get_singleton()->save();
+ ProjectSettings::get_singleton()->set("application/run/main_scene", p_file);
+ ProjectSettings::get_singleton()->save();
//would be nice to show the project manager opened with the highlighted field..
_run(false, ""); // automatically run the project
} break;
@@ -1549,6 +1573,11 @@ void EditorNode::_edit_current() {
editor_plugin_screen->make_visible(true);
+ int plugin_count = editor_data.get_editor_plugin_count();
+ for (int i = 0; i < plugin_count; i++) {
+ editor_data.get_editor_plugin(i)->notify_main_screen_changed(editor_plugin_screen->get_name());
+ }
+
for (int i = 0; i < editor_table.size(); i++) {
main_editor_buttons[i]->set_pressed(editor_table[i] == main_plugin);
@@ -1602,7 +1631,7 @@ void EditorNode::_edit_current() {
p->add_separator();
p->add_shortcut(ED_SHORTCUT("property_editor/make_subresources_unique", TTR("Make Sub-Resources Unique")), OBJECT_UNIQUE_RESOURCES);
p->add_separator();
- p->add_icon_shortcut(gui_base->get_icon("Help", "EditorIcons"), ED_SHORTCUT("property_editor/open_help", TTR("Open in Help")), OBJECT_REQUEST_HELP);
+ p->add_icon_shortcut(gui_base->get_icon("HelpSearch", "EditorIcons"), ED_SHORTCUT("property_editor/open_help", TTR("Open in Help")), OBJECT_REQUEST_HELP);
}
List<MethodInfo> methods;
@@ -1705,7 +1734,7 @@ void EditorNode::_run(bool p_current, const String &p_custom) {
if (run_filename == "") {
//evidently, run the scene
- main_scene = GLOBAL_DEF("application/main_scene", "");
+ main_scene = GLOBAL_DEF("application/run/main_scene", "");
if (main_scene == "") {
current_option = -1;
@@ -1771,7 +1800,7 @@ void EditorNode::_run(bool p_current, const String &p_custom) {
List<String> breakpoints;
editor_data.get_editor_breakpoints(&breakpoints);
- args = GlobalConfig::get_singleton()->get("editor/main_run_args");
+ args = ProjectSettings::get_singleton()->get("editor/main_run_args");
Error error = editor_run.run(run_filename, args, breakpoints);
@@ -1920,7 +1949,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
case FILE_CLOSE: {
if (!p_confirmed && (unsaved_cache || p_option == FILE_CLOSE_ALL_AND_QUIT || p_option == FILE_CLOSE_ALL_AND_RUN_PROJECT_MANAGER)) {
- tab_closing = p_option == FILE_CLOSE ? editor_data.get_edited_scene() : _next_unsaved_scene();
+ tab_closing = p_option == FILE_CLOSE ? editor_data.get_edited_scene() : _next_unsaved_scene(false);
String scene_filename = editor_data.get_edited_scene_root(tab_closing)->get_filename();
save_confirmation->get_ok()->set_text(TTR("Save & Close"));
save_confirmation->set_text(vformat(TTR("Save changes to '%s' before closing?"), scene_filename != "" ? scene_filename : "unsaved scene"));
@@ -2238,7 +2267,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
}
instanced_scene->generate_instance_state();
- instanced_scene->set_filename( GlobalConfig::get_singleton()->localize_path(external_file) );
+ instanced_scene->set_filename( ProjectSettings::get_singleton()->localize_path(external_file) );
editor_data.get_undo_redo().create_action("Instance Scene");
editor_data.get_undo_redo().add_do_method(parent,"add_child",instanced_scene);
@@ -2452,7 +2481,8 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
case RUN_PROJECT_MANAGER: {
if (!p_confirmed) {
- if (_next_unsaved_scene() == -1) {
+ bool save_each = EDITOR_DEF("interface/save_each_scene_on_quit", true);
+ if (_next_unsaved_scene(!save_each) == -1) {
bool confirm = EDITOR_DEF("interface/quit_confirmation", true);
if (confirm) {
@@ -2462,24 +2492,20 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
confirmation->popup_centered_minsize();
} else {
_discard_changes();
+ break;
}
} else {
- bool save_each = EDITOR_DEF("interface/save_each_scene_on_quit", true);
if (save_each) {
_menu_option_confirm(p_option == FILE_QUIT ? FILE_CLOSE_ALL_AND_QUIT : FILE_CLOSE_ALL_AND_RUN_PROJECT_MANAGER, false);
} else {
String unsaved_scenes;
- for (int i = 0; i < editor_data.get_edited_scene_count(); i++) {
- int current = editor_data.get_edited_scene();
- bool unsaved = (i == current) ? saved_version != editor_data.get_undo_redo().get_version() : editor_data.get_scene_version(i) != 0;
- if (unsaved) {
-
- String scene_filename = editor_data.get_edited_scene_root(i)->get_filename();
- unsaved_scenes += "\n " + scene_filename;
- }
+ int i = _next_unsaved_scene(true, 0);
+ while (i != -1) {
+ unsaved_scenes += "\n " + editor_data.get_edited_scene_root(i)->get_filename();
+ i = _next_unsaved_scene(true, ++i);
}
save_confirmation->get_ok()->set_text(TTR("Save & Quit"));
@@ -2488,10 +2514,11 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
}
}
+ OS::get_singleton()->request_attention();
break;
}
- if (_next_unsaved_scene() != -1) {
+ if (_next_unsaved_scene(true) != -1) {
_save_all_scenes();
}
_discard_changes();
@@ -2643,7 +2670,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
OS::get_singleton()->shell_open("https://godotengine.org/community");
} break;
case HELP_ABOUT: {
- about->popup_centered_minsize(Size2(500, 130) * EDSCALE);
+ about->popup_centered_minsize(Size2(780, 500) * EDSCALE);
} break;
case SOURCES_REIMPORT: {
@@ -2720,13 +2747,18 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
}
}
-int EditorNode::_next_unsaved_scene() {
+int EditorNode::_next_unsaved_scene(bool p_valid_filename, int p_start) {
- for (int i = 0; i < editor_data.get_edited_scene_count(); i++) {
+ for (int i = p_start; i < editor_data.get_edited_scene_count(); i++) {
+ if (!editor_data.get_edited_scene_root(i))
+ continue;
int current = editor_data.get_edited_scene();
bool unsaved = (i == current) ? saved_version != editor_data.get_undo_redo().get_version() : editor_data.get_scene_version(i) != 0;
if (unsaved) {
+ String scene_filename = editor_data.get_edited_scene_root(i)->get_filename();
+ if (p_valid_filename && scene_filename.length() == 0)
+ continue;
return i;
}
}
@@ -2746,7 +2778,7 @@ void EditorNode::_discard_changes(const String &p_str) {
_update_scene_tabs();
if (current_option == FILE_CLOSE_ALL_AND_QUIT || current_option == FILE_CLOSE_ALL_AND_RUN_PROJECT_MANAGER) {
- if (_next_unsaved_scene() == -1) {
+ if (_next_unsaved_scene(false) == -1) {
current_option = current_option == FILE_CLOSE_ALL_AND_QUIT ? FILE_QUIT : RUN_PROJECT_MANAGER;
_discard_changes();
} else {
@@ -2834,6 +2866,11 @@ void EditorNode::_editor_select(int p_which) {
editor_plugin_screen->make_visible(true);
editor_plugin_screen->selected_notify();
+ int plugin_count = editor_data.get_editor_plugin_count();
+ for (int i = 0; i < plugin_count; i++) {
+ editor_data.get_editor_plugin(i)->notify_main_screen_changed(editor_plugin_screen->get_name());
+ }
+
if (EditorSettings::get_singleton()->get("interface/separate_distraction_mode")) {
if (p_which == EDITOR_SCRIPT) {
set_distraction_free_mode(script_distraction);
@@ -2882,7 +2919,6 @@ void EditorNode::remove_editor_plugin(EditorPlugin *p_editor) {
}
}
- //singleton->main_editor_tabs->add_tab(p_editor->get_name());
singleton->editor_table.erase(p_editor);
}
p_editor->make_visible(false);
@@ -2904,9 +2940,9 @@ void EditorNode::_update_addon_config() {
}
if (enabled_addons.size() == 0) {
- GlobalConfig::get_singleton()->set("editor_plugins/enabled", Variant());
+ ProjectSettings::get_singleton()->set("editor_plugins/enabled", Variant());
} else {
- GlobalConfig::get_singleton()->set("editor_plugins/enabled", enabled_addons);
+ ProjectSettings::get_singleton()->set("editor_plugins/enabled", enabled_addons);
}
project_settings->queue_save();
@@ -3247,7 +3283,7 @@ Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, b
if (p_clear_errors)
load_errors->clear();
- String lpath = GlobalConfig::get_singleton()->localize_path(p_scene);
+ String lpath = ProjectSettings::get_singleton()->localize_path(p_scene);
if (!lpath.begins_with("res://")) {
@@ -3535,7 +3571,7 @@ void EditorNode::animation_editor_make_visible(bool p_visible) {
#endif
void EditorNode::_add_to_recent_scenes(const String &p_scene) {
- String base = "_" + GlobalConfig::get_singleton()->get_resource_path().replace("\\", "::").replace("/", "::");
+ String base = "_" + ProjectSettings::get_singleton()->get_resource_path().replace("\\", "::").replace("/", "::");
Vector<String> rc = EDITOR_DEF(base + "/_recent_scenes", Array());
String name = p_scene;
name = name.replace("res://", "");
@@ -3552,21 +3588,12 @@ void EditorNode::_add_to_recent_scenes(const String &p_scene) {
void EditorNode::_open_recent_scene(int p_idx) {
- String base = "_" + GlobalConfig::get_singleton()->get_resource_path().replace("\\", "::").replace("/", "::");
+ String base = "_" + ProjectSettings::get_singleton()->get_resource_path().replace("\\", "::").replace("/", "::");
Vector<String> rc = EDITOR_DEF(base + "/_recent_scenes", Array());
ERR_FAIL_INDEX(p_idx, rc.size());
String path = "res://" + rc[p_idx];
-
- /*if (unsaved_cache) {
- _recent_scene=rc[p_idx];
- open_recent_confirmation->set_text("Discard current scene and open:\n'"+rc[p_idx]+"'");
- open_recent_confirmation->get_label()->set_align(Label::ALIGN_CENTER);
- open_recent_confirmation->popup_centered(Size2(400,100));
- return;
- }*/
-
load_scene(path);
}
@@ -3604,13 +3631,13 @@ void EditorNode::_save_optimized() {
}
- project_settings->add_remapped_path(GlobalConfig::get_singleton()->localize_path(get_edited_scene()->get_filename()),GlobalConfig::get_singleton()->localize_path(path),platform);
+ project_settings->add_remapped_path(ProjectSettings::get_singleton()->localize_path(get_edited_scene()->get_filename()),ProjectSettings::get_singleton()->localize_path(path),platform);
#endif
}
void EditorNode::_update_recent_scenes() {
- String base = "_" + GlobalConfig::get_singleton()->get_resource_path().replace("\\", "::").replace("/", "::");
+ String base = "_" + ProjectSettings::get_singleton()->get_resource_path().replace("\\", "::").replace("/", "::");
Vector<String> rc = EDITOR_DEF(base + "/_recent_scenes", Array());
recent_scenes->clear();
for (int i = 0; i < rc.size(); i++) {
@@ -3725,6 +3752,7 @@ void EditorNode::register_editor_types() {
ClassDB::register_class<EditorResourcePreviewGenerator>();
ClassDB::register_class<EditorFileSystem>();
ClassDB::register_class<EditorFileSystemDirectory>();
+ ClassDB::register_virtual_class<ScriptEditor>();
//ClassDB::register_type<EditorImporter>();
//ClassDB::register_type<EditorPostImport>();
@@ -4354,6 +4382,10 @@ void EditorNode::_scene_tab_closed(int p_tab) {
current_option = SCENE_TAB_CLOSE;
tab_closing = p_tab;
Node *scene = editor_data.get_edited_scene_root(p_tab);
+ if (!scene) {
+ _discard_changes();
+ return;
+ }
bool unsaved = (p_tab == editor_data.get_edited_scene()) ?
saved_version != editor_data.get_undo_redo().get_version() :
@@ -4389,12 +4421,23 @@ void EditorNode::_scene_tab_input(const Ref<InputEvent> &p_input) {
Ref<InputEventMouseButton> mb = p_input;
if (mb.is_valid()) {
- if (mb->get_button_index() == BUTTON_MIDDLE && mb->is_pressed() && scene_tabs->get_hovered_tab() >= 0) {
- _scene_tab_closed(scene_tabs->get_hovered_tab());
+ if (scene_tabs->get_hovered_tab() >= 0) {
+ if (mb->get_button_index() == BUTTON_MIDDLE && mb->is_pressed()) {
+ _scene_tab_closed(scene_tabs->get_hovered_tab());
+ }
+ } else {
+ if ((mb->get_button_index() == BUTTON_LEFT && mb->is_doubleclick()) || (mb->get_button_index() == BUTTON_MIDDLE && mb->is_pressed())) {
+ _menu_option_confirm(FILE_NEW_SCENE, true);
+ }
}
}
}
+void EditorNode::_reposition_active_tab(int idx_to) {
+ editor_data.move_edited_scene_to_index(idx_to);
+ _update_scene_tabs();
+}
+
void EditorNode::_thumbnail_done(const String &p_path, const Ref<Texture> &p_preview, const Variant &p_udata) {
int p_tab = p_udata.operator signed int();
if (p_preview.is_valid()) {
@@ -4977,6 +5020,7 @@ void EditorNode::_bind_methods() {
ClassDB::bind_method("_scene_tab_hover", &EditorNode::_scene_tab_hover);
ClassDB::bind_method("_scene_tab_exit", &EditorNode::_scene_tab_exit);
ClassDB::bind_method("_scene_tab_input", &EditorNode::_scene_tab_input);
+ ClassDB::bind_method("_reposition_active_tab", &EditorNode::_reposition_active_tab);
ClassDB::bind_method("_thumbnail_done", &EditorNode::_thumbnail_done);
ClassDB::bind_method("_scene_tab_script_edited", &EditorNode::_scene_tab_script_edited);
ClassDB::bind_method("_set_main_scene_state", &EditorNode::_set_main_scene_state);
@@ -5095,10 +5139,6 @@ EditorNode::EditorNode() {
import_wav.instance();
ResourceFormatImporter::get_singleton()->add_importer(import_wav);
- Ref<ResourceImporterOBJ> import_obj;
- import_obj.instance();
- ResourceFormatImporter::get_singleton()->add_importer(import_obj);
-
Ref<ResourceImporterScene> import_scene;
import_scene.instance();
ResourceFormatImporter::get_singleton()->add_importer(import_scene);
@@ -5107,6 +5147,10 @@ EditorNode::EditorNode() {
Ref<EditorSceneImporterCollada> import_collada;
import_collada.instance();
import_scene->add_importer(import_collada);
+
+ Ref<EditorOBJImporter> import_obj;
+ import_obj.instance();
+ import_scene->add_importer(import_obj);
}
}
@@ -5166,28 +5210,9 @@ EditorNode::EditorNode() {
main_vbox->set_area_as_parent_rect(8);
main_vbox->set_margin(MARGIN_TOP, 5);
-#if 0
- PanelContainer *top_dark_panel = memnew( PanelContainer );
- Ref<StyleBoxTexture> top_dark_sb;
- top_dark_sb.instance();
- top_dark_sb->set_texture(theme->get_icon("PanelTop","EditorIcons"));
- for(int i=0;i<4;i++) {
- top_dark_sb->set_margin_size(Margin(i),3);
- top_dark_sb->set_default_margin(Margin(i),0);
- }
- top_dark_sb->set_expand_margin_size(MARGIN_LEFT,20);
- top_dark_sb->set_expand_margin_size(MARGIN_RIGHT,20);
-
- top_dark_panel->add_style_override("panel",top_dark_sb);
- VBoxContainer *top_dark_vb = memnew( VBoxContainer );
- main_vbox->add_child(top_dark_panel);
- top_dark_panel->add_child(top_dark_vb);
-#endif
-
menu_hb = memnew(HBoxContainer);
main_vbox->add_child(menu_hb);
- //top_dark_vb->add_child(scene_tabs);
//left
left_l_hsplit = memnew(HSplitContainer);
main_vbox->add_child(left_l_hsplit);
@@ -5262,10 +5287,10 @@ EditorNode::EditorNode() {
main_hsplit->connect("dragged", this, "_dock_split_dragged");
right_hsplit->connect("dragged", this, "_dock_split_dragged");
- dock_select_popoup = memnew(PopupPanel);
- gui_base->add_child(dock_select_popoup);
+ dock_select_popup = memnew(PopupPanel);
+ gui_base->add_child(dock_select_popup);
VBoxContainer *dock_vb = memnew(VBoxContainer);
- dock_select_popoup->add_child(dock_vb);
+ dock_select_popup->add_child(dock_vb);
HBoxContainer *dock_hb = memnew(HBoxContainer);
dock_tab_move_left = memnew(ToolButton);
@@ -5292,14 +5317,13 @@ EditorNode::EditorNode() {
dock_select->set_v_size_flags(Control::SIZE_EXPAND_FILL);
dock_vb->add_child(dock_select);
- dock_select_popoup->set_as_minsize();
+ dock_select_popup->set_as_minsize();
dock_select_rect_over = -1;
dock_popup_selected = -1;
- //dock_select_popoup->set_(Size2(20,20));
for (int i = 0; i < DOCK_SLOT_MAX; i++) {
dock_slot[i]->set_custom_minimum_size(Size2(230, 220) * EDSCALE);
dock_slot[i]->set_v_size_flags(Control::SIZE_EXPAND_FILL);
- dock_slot[i]->set_popup(dock_select_popoup);
+ dock_slot[i]->set_popup(dock_select_popup);
dock_slot[i]->connect("pre_popup_pressed", this, "_dock_pre_popup", varray(i));
dock_slot[i]->set_tab_align(TabContainer::ALIGN_LEFT);
}
@@ -5320,10 +5344,6 @@ EditorNode::EditorNode() {
top_split->add_child(srt);
srt->add_constant_override("separation", 0);
- /* main_editor_tabs = memnew( Tabs );
- main_editor_tabs->connect("tab_changed",this,"_editor_select");
- main_editor_tabs->set_tab_close_display_policy(Tabs::SHOW_NEVER);
-*/
tab_preview_panel = memnew(Panel);
tab_preview_panel->set_size(Size2(100, 100) * EDSCALE);
tab_preview_panel->hide();
@@ -5349,6 +5369,7 @@ EditorNode::EditorNode() {
scene_tabs->connect("tab_hover", this, "_scene_tab_hover");
scene_tabs->connect("mouse_exited", this, "_scene_tab_exit");
scene_tabs->connect("gui_input", this, "_scene_tab_input");
+ scene_tabs->connect("reposition_active_tab_request", this, "_reposition_active_tab");
HBoxContainer *tabbar_container = memnew(HBoxContainer);
scene_tabs->set_h_size_flags(Control::SIZE_EXPAND_FILL);
@@ -5358,6 +5379,7 @@ EditorNode::EditorNode() {
distraction_free = memnew(ToolButton);
tabbar_container->add_child(distraction_free);
distraction_free->set_shortcut(ED_SHORTCUT("editor/distraction_free_mode", TTR("Distraction Free Mode"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_F11));
+ distraction_free->set_tooltip(TTR("Toggle distraction-free mode."));
distraction_free->connect("pressed", this, "_toggle_distraction_free_mode");
distraction_free->set_icon(gui_base->get_icon("DistractionFree", "EditorIcons"));
distraction_free->set_toggle_mode(true);
@@ -5365,6 +5387,7 @@ EditorNode::EditorNode() {
scene_root_parent = memnew(PanelContainer);
scene_root_parent->set_custom_minimum_size(Size2(0, 80) * EDSCALE);
scene_root_parent->add_style_override("panel", gui_base->get_stylebox("Content", "EditorStyles"));
+ // sc->add_style_override("panel", gui_base->get_stylebox("Background", "EditorStyles"));
//Ref<StyleBox> sp = scene_root_parent->get_stylebox("panel","TabContainer");
//scene_root_parent->add_style_override("panel",sp);
@@ -5384,7 +5407,7 @@ EditorNode::EditorNode() {
VisualServer::get_singleton()->viewport_set_hide_scenario(scene_root->get_viewport_rid(), true);
scene_root->set_disable_input(true);
scene_root->set_as_audio_listener_2d(true);
- //scene_root->set_size_override(true,Size2(GlobalConfig::get_singleton()->get("display/width"),GlobalConfig::get_singleton()->get("display/height")));
+ //scene_root->set_size_override(true,Size2(ProjectSettings::get_singleton()->get("display/width"),ProjectSettings::get_singleton()->get("display/height")));
//scene_root->set_world_2d( Ref<World2D>( memnew( World2D )) );
@@ -5435,7 +5458,6 @@ EditorNode::EditorNode() {
p->add_separator();
p->add_shortcut(ED_SHORTCUT("editor/close_scene", TTR("Close Scene"), KEY_MASK_SHIFT + KEY_MASK_CTRL + KEY_W), FILE_CLOSE);
p->add_separator();
- //p->add_shortcut(ED_SHORTCUT("editor/save_scene",TTR("Close Goto Prev. Scene")),FILE_OPEN_PREV,KEY_MASK_SHIFT+KEY_MASK_CMD+KEY_P);
p->add_submenu_item(TTR("Open Recent"), "RecentScenes", FILE_OPEN_RECENT);
p->add_separator();
p->add_shortcut(ED_SHORTCUT("editor/quick_open_scene", TTR("Quick Open Scene.."), KEY_MASK_SHIFT + KEY_MASK_CMD + KEY_O), FILE_QUICK_OPEN_SCENE);
@@ -5503,35 +5525,6 @@ EditorNode::EditorNode() {
menu_hb->add_spacer();
menu_hb->add_child(editor_region);
-//menu_hb->add_spacer();
-#if 0
- node_menu = memnew( MenuButton );
- node_menu->set_text("Node");
- node_menu->set_position( Point2( 50,0) );
- menu_panel->add_child( node_menu );
-
- p=node_menu->get_popup();
- p->add_item("Create",NODE_CREATE);
- p->add_item("Instance",NODE_INSTANCE);
- p->add_separator();
- p->add_item("Reparent",NODE_REPARENT);
- p->add_item("Move Up",NODE_MOVE_UP);
- p->add_item("Move Down",NODE_MOVE_DOWN);
- p->add_separator();
- p->add_item("Duplicate",NODE_DUPLICATE);
- p->add_separator();
- p->add_item("Remove (Branch)",NODE_REMOVE_BRANCH);
- p->add_item("Remove (Element)",NODE_REMOVE_ELEMENT);
- p->add_separator();
- p->add_item("Edit Subscriptions..",NODE_CONNECTIONS);
- p->add_item("Edit Groups..",NODE_GROUPS);
-
- resource_menu = memnew( MenuButton );
- resource_menu->set_text("Resource");
- resource_menu->set_position( Point2( 90,0) );
- menu_panel->add_child( resource_menu );
-#endif
-
debug_menu = memnew(MenuButton);
debug_menu->set_text(TTR("Debug"));
debug_menu->add_style_override("hover", gui_base->get_stylebox("MenuHover", "EditorStyles"));
@@ -5584,7 +5577,7 @@ EditorNode::EditorNode() {
p = help_menu->get_popup();
p->connect("id_pressed", this, "_menu_option");
p->add_icon_item(gui_base->get_icon("ClassList", "EditorIcons"), TTR("Classes"), HELP_CLASSES);
- p->add_icon_item(gui_base->get_icon("Help", "EditorIcons"), TTR("Search"), HELP_SEARCH);
+ p->add_icon_item(gui_base->get_icon("HelpSearch", "EditorIcons"), TTR("Search"), HELP_SEARCH);
p->add_separator();
p->add_icon_item(gui_base->get_icon("Instance", "EditorIcons"), TTR("Online Docs"), HELP_DOCS);
p->add_icon_item(gui_base->get_icon("Instance", "EditorIcons"), TTR("Q&A"), HELP_QA);
@@ -5593,11 +5586,6 @@ EditorNode::EditorNode() {
p->add_separator();
p->add_icon_item(gui_base->get_icon("GodotDocs", "EditorIcons"), TTR("About"), HELP_ABOUT);
- //Separator *s1 = memnew( VSeparator );
- //menu_panel->add_child(s1);
- //s1->set_position(Point2(210,4));
- //s1->set_size(Point2(10,15));
-
play_cc = memnew(CenterContainer);
play_cc->set_mouse_filter(Control::MOUSE_FILTER_IGNORE);
menu_hb->add_child(play_cc);
@@ -5622,7 +5610,6 @@ EditorNode::EditorNode() {
play_button->set_shortcut(ED_SHORTCUT("editor/play", TTR("Play"), KEY_F5));
pause_button = memnew(ToolButton);
- //menu_panel->add_child(pause_button); - not needed for now?
pause_button->set_toggle_mode(true);
pause_button->set_icon(gui_base->get_icon("Pause", "EditorIcons"));
pause_button->set_focus_mode(Control::FOCUS_NONE);
@@ -5650,9 +5637,6 @@ EditorNode::EditorNode() {
native_play_button->get_popup()->connect("id_pressed", this, "_run_in_device");
run_native->connect("native_run", this, "_menu_option", varray(RUN_PLAY_NATIVE));
- //VSeparator *s1 = memnew( VSeparator );
- //play_hb->add_child(s1);
-
play_scene_button = memnew(ToolButton);
play_hb->add_child(play_scene_button);
play_scene_button->set_toggle_mode(true);
@@ -5671,24 +5655,6 @@ EditorNode::EditorNode() {
play_custom_scene_button->set_tooltip(TTR("Play custom scene"));
play_custom_scene_button->set_shortcut(ED_SHORTCUT("editor/play_custom_scene", TTR("Play Custom Scene"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_F5));
- /*
- run_settings_button = memnew( ToolButton );
- //menu_hb->add_child(run_settings_button);
- //run_settings_button->set_toggle_mode(true);
- run_settings_button->set_focus_mode(Control::FOCUS_NONE);
- run_settings_button->set_icon(gui_base->get_icon("Run","EditorIcons"));
- run_settings_button->connect("pressed", this,"_menu_option",make_binds(RUN_SCENE_SETTINGS));
-*/
-
- /*
- run_settings_button = memnew( ToolButton );
- menu_panel->add_child(run_settings_button);
- run_settings_button->set_position(Point2(305,0));
- run_settings_button->set_focus_mode(Control::FOCUS_NONE);
- run_settings_button->set_icon(gui_base->get_icon("Run","EditorIcons"));
- run_settings_button->connect("pressed", this,"_menu_option",make_binds(RUN_SETTINGS));
-*/
-
progress_hb = memnew(BackgroundProgress);
//menu_hb->add_child(progress_hb);
@@ -5727,52 +5693,15 @@ EditorNode::EditorNode() {
p->add_check_item(TTR("Disable Update Spinner"), SETTINGS_UPDATE_SPINNER_HIDE);
p->set_item_checked(1, true);
- //sources_button->connect();
-
- /*
- Separator *s2 = memnew( VSeparator );
- menu_panel->add_child(s2);
- s2->set_position(Point2(338,4));
- s2->set_size(Point2(10,15));
-*/
-
- //editor_hsplit = memnew( HSplitContainer );
- //main_split->add_child(editor_hsplit);
- //editor_hsplit->set_v_size_flags(Control::SIZE_EXPAND_FILL);
-
- //editor_vsplit = memnew( VSplitContainer );
- //editor_hsplit->add_child(editor_vsplit);
-
- //top_pallete = memnew( TabContainer );
scene_tree_dock = memnew(SceneTreeDock(this, scene_root, editor_selection, editor_data));
scene_tree_dock->set_name(TTR("Scene"));
- //top_pallete->add_child(scene_tree_dock);
dock_slot[DOCK_SLOT_RIGHT_UL]->add_child(scene_tree_dock);
#if 0
resources_dock = memnew( ResourcesDock(this) );
resources_dock->set_name("Resources");
- //top_pallete->add_child(resources_dock);
dock_slot[DOCK_SLOT_RIGHT_BL]->add_child(resources_dock);
- //top_pallete->set_v_size_flags(Control::SIZE_EXPAND_FILL);
#endif
dock_slot[DOCK_SLOT_LEFT_BR]->hide();
- /*Control *editor_spacer = memnew( Control );
- editor_spacer->set_custom_minimum_size(Size2(260,200));
- editor_spacer->set_v_size_flags(Control::SIZE_EXPAND_FILL);
- editor_vsplit->add_child( editor_spacer );
- editor_spacer->add_child( top_pallete );
- top_pallete->set_area_as_parent_rect();*/
-
- //prop_pallete = memnew( TabContainer );
-
- //prop_pallete->set_v_size_flags(Control::SIZE_EXPAND_FILL);
-
- /*editor_spacer = memnew( Control );
- editor_spacer->set_custom_minimum_size(Size2(260,200));
- editor_spacer->set_v_size_flags(Control::SIZE_EXPAND_FILL);
- editor_vsplit->add_child( editor_spacer );
- editor_spacer->add_child( prop_pallete );
- prop_pallete->set_area_as_parent_rect();*/
VBoxContainer *prop_editor_base = memnew(VBoxContainer);
prop_editor_base->set_name(TTR("Inspector")); // Properties?
@@ -5842,7 +5771,7 @@ EditorNode::EditorNode() {
search_button = memnew(ToolButton);
search_button->set_toggle_mode(true);
search_button->set_pressed(false);
- search_button->set_icon(gui_base->get_icon("Zoom", "EditorIcons"));
+ search_button->set_icon(gui_base->get_icon("Search", "EditorIcons"));
prop_editor_hb->add_child(search_button);
search_button->connect("toggled", this, "_toggle_search_bar");
@@ -5879,6 +5808,7 @@ EditorNode::EditorNode() {
property_editor->set_use_folding(true);
property_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL);
property_editor->set_use_doc_hints(true);
+ property_editor->set_hide_script(false);
property_editor->set_enable_capitalize_paths(bool(EDITOR_DEF("interface/capitalize_properties", true)));
property_editor->hide_top_label();
@@ -5913,7 +5843,6 @@ EditorNode::EditorNode() {
} else {
dock_slot[DOCK_SLOT_LEFT_UR]->add_child(filesystem_dock);
}
- //prop_pallete->add_child(filesystem_dock);
filesystem_dock->connect("open", this, "open_request");
filesystem_dock->connect("instance", this, "_instance_request");
@@ -5933,7 +5862,7 @@ EditorNode::EditorNode() {
_update_layouts_menu();
bottom_panel = memnew(PanelContainer);
- bottom_panel->add_style_override("panel", gui_base->get_stylebox("Content", "EditorStyles"));
+ bottom_panel->add_style_override("panel", gui_base->get_stylebox("panel", "TabContainer"));
center_split->add_child(bottom_panel);
center_split->set_dragger_visibility(SplitContainer::DRAGGER_HIDDEN);
@@ -5964,17 +5893,6 @@ EditorNode::EditorNode() {
//progress_hb->set_h_size_flags(Control::SIZE_EXPAND_FILL);
- /*
- animation_menu = memnew( ToolButton );
- animation_menu->set_position(Point2(500,0));
- animation_menu->set_size(Size2(20,20));
- animation_menu->set_toggle_mode(true);
- animation_menu->set_focus_mode(Control::FOCUS_NONE);
- menu_panel->add_child(animation_menu);
- animation_menu->set_icon(gui_base->get_icon("Animation","EditorIcons"));
- animation_menu->connect("pressed",this,"_animation_visibility_toggle");
-*/
-
orphan_resources = memnew(OrphanResourcesDialog);
gui_base->add_child(orphan_resources);
@@ -6018,7 +5936,7 @@ EditorNode::EditorNode() {
settings_config_dialog = memnew(EditorSettingsDialog);
gui_base->add_child(settings_config_dialog);
- project_settings = memnew(ProjectSettings(&editor_data));
+ project_settings = memnew(ProjectSettingsEditor(&editor_data));
gui_base->add_child(project_settings);
import_confirmation = memnew(ConfirmationDialog);
@@ -6029,64 +5947,15 @@ EditorNode::EditorNode() {
import_confirmation->connect("custom_action", this, "_import_action");
gui_base->add_child(import_confirmation);
- open_recent_confirmation = memnew(ConfirmationDialog);
- add_child(open_recent_confirmation);
- open_recent_confirmation->connect("confirmed", this, "_open_recent_scene_confirm");
-
run_settings_dialog = memnew(RunSettingsDialog);
gui_base->add_child(run_settings_dialog);
export_template_manager = memnew(ExportTemplateManager);
gui_base->add_child(export_template_manager);
- about = memnew(AcceptDialog);
- about->set_title(TTR("Thanks from the Godot community!"));
- about->get_ok()->set_text(TTR("Thanks!"));
- about->set_hide_on_ok(true);
+ about = memnew(EditorAbout);
+ about->get_logo()->set_texture(gui_base->get_icon("Logo", "EditorIcons"));
gui_base->add_child(about);
- VBoxContainer *vbc = memnew(VBoxContainer);
- HBoxContainer *hbc = memnew(HBoxContainer);
- hbc->set_h_size_flags(Control::SIZE_EXPAND_FILL);
- hbc->set_alignment(BoxContainer::ALIGN_CENTER);
- about->add_child(vbc);
- vbc->add_child(hbc);
- Label *about_text = memnew(Label);
- about_text->set_text(VERSION_FULL_NAME + String::utf8("\n\u00A9 2007-2017 Juan Linietsky, Ariel Manzur.\n\u00A9 2014-2017 ") + TTR("Godot Engine contributors") + "\n");
- TextureRect *logo = memnew(TextureRect);
- logo->set_texture(gui_base->get_icon("Logo", "EditorIcons"));
- hbc->add_child(logo);
- hbc->add_child(about_text);
- TabContainer *tc = memnew(TabContainer);
- tc->set_custom_minimum_size(Vector2(740, 300));
- vbc->add_child(tc);
- ScrollContainer *dev_base = memnew(ScrollContainer);
- dev_base->set_name(TTR("Developers"));
- tc->add_child(dev_base);
- HBoxContainer *dev_hbc = memnew(HBoxContainer);
- dev_hbc->set_h_size_flags(Control::SIZE_EXPAND_FILL);
- dev_base->add_child(dev_hbc);
- for (int i = 0; i < 3; i++) {
- Label *dev_label = memnew(Label);
- dev_label->set_h_size_flags(Control::SIZE_EXPAND);
- dev_label->set_v_size_flags(Control::SIZE_FILL);
- dev_hbc->add_child(dev_label);
- }
- int dev_name_index = 0;
- int dev_name_column = 0;
- const int dev_index_max = AUTHORS_COUNT / 3 + (AUTHORS_COUNT % 3 == 0 ? 0 : 1);
- String dev_name = "";
- const char **dev_names_ptr = dev_names;
- while (*dev_names_ptr) {
- dev_name += String::utf8(*dev_names_ptr++);
- if (++dev_name_index == dev_index_max || !*dev_names_ptr) {
- dev_hbc->get_child(dev_name_column)->cast_to<Label>()->set_text(dev_name);
- dev_name_column++;
- dev_name = "";
- dev_name_index = 0;
- } else {
- dev_name += "\n";
- }
- }
warning = memnew(AcceptDialog);
gui_base->add_child(warning);
@@ -6180,21 +6049,17 @@ EditorNode::EditorNode() {
add_editor_plugin( memnew( ShaderEditorPlugin(this,false) ) );*/
add_editor_plugin(memnew(CameraEditorPlugin(this)));
- // add_editor_plugin( memnew( SampleEditorPlugin(this) ) );
- // add_editor_plugin( memnew( SampleLibraryEditorPlugin(this) ) );
add_editor_plugin(memnew(ThemeEditorPlugin(this)));
add_editor_plugin(memnew(MultiMeshEditorPlugin(this)));
add_editor_plugin(memnew(MeshInstanceEditorPlugin(this)));
add_editor_plugin(memnew(AnimationTreeEditorPlugin(this)));
- //add_editor_plugin( memnew( SamplePlayerEditorPlugin(this) ) ); - this is kind of useless at this point
//add_editor_plugin( memnew( MeshLibraryEditorPlugin(this) ) );
- //add_editor_plugin( memnew( StreamEditorPlugin(this) ) );
add_editor_plugin(memnew(StyleBoxEditorPlugin(this)));
add_editor_plugin(memnew(ParticlesEditorPlugin(this)));
add_editor_plugin(memnew(ResourcePreloaderEditorPlugin(this)));
add_editor_plugin(memnew(ItemListEditorPlugin(this)));
//add_editor_plugin( memnew( RichTextEditorPlugin(this) ) );
- //add_editor_plugin( memnew( CollisionPolygonEditorPlugin(this) ) );
+ add_editor_plugin(memnew(CollisionPolygonEditorPlugin(this)));
add_editor_plugin(memnew(CollisionPolygon2DEditorPlugin(this)));
add_editor_plugin(memnew(TileSetEditorPlugin(this)));
add_editor_plugin(memnew(TileMapEditorPlugin(this)));
@@ -6204,7 +6069,6 @@ EditorNode::EditorNode() {
add_editor_plugin(memnew(GIProbeEditorPlugin(this)));
add_editor_plugin(memnew(Path2DEditorPlugin(this)));
add_editor_plugin(memnew(PathEditorPlugin(this)));
- //add_editor_plugin( memnew( BakedLightEditorPlugin(this) ) );
add_editor_plugin(memnew(Line2DEditorPlugin(this)));
add_editor_plugin(memnew(Polygon2DEditorPlugin(this)));
add_editor_plugin(memnew(LightOccluder2DEditorPlugin(this)));
@@ -6215,7 +6079,7 @@ EditorNode::EditorNode() {
add_editor_plugin(memnew(TextureEditorPlugin(this)));
add_editor_plugin(memnew(AudioBusesEditorPlugin(audio_bus_editor)));
//add_editor_plugin( memnew( MaterialEditorPlugin(this) ) );
- //add_editor_plugin( memnew( MeshEditorPlugin(this) ) );
+ add_editor_plugin(memnew(MeshEditorPlugin(this)));
for (int i = 0; i < EditorPlugins::get_plugin_count(); i++)
add_editor_plugin(EditorPlugins::create(i, this));
@@ -6248,7 +6112,7 @@ EditorNode::EditorNode() {
Physics2DServer::get_singleton()->set_active(false); // no physics by default if editor
ScriptServer::set_scripting_enabled(false); // no scripting by default if editor
- //GlobalConfig::get_singleton()->set("render/room_cull_enabled",false);
+ //ProjectSettings::get_singleton()->set("render/room_cull_enabled",false);
reference_resource_mem = true;
save_external_resources_mem = true;
@@ -6261,7 +6125,7 @@ EditorNode::EditorNode() {
//store project name in ssettings
String project_name;
//figure it out from path
- project_name = GlobalConfig::get_singleton()->get_resource_path().replace("\\", "/");
+ project_name = ProjectSettings::get_singleton()->get_resource_path().replace("\\", "/");
print_line("path: " + project_name);
if (project_name.length() && project_name[project_name.length() - 1] == '/')
project_name = project_name.substr(0, project_name.length() - 1);
@@ -6269,7 +6133,7 @@ EditorNode::EditorNode() {
project_name = project_name.replace("/", "::");
if (project_name != "") {
- EditorSettings::get_singleton()->set("projects/" + project_name, GlobalConfig::get_singleton()->get_resource_path());
+ EditorSettings::get_singleton()->set("projects/" + project_name, ProjectSettings::get_singleton()->get_resource_path());
EditorSettings::get_singleton()->raise_order("projects/" + project_name);
EditorSettings::get_singleton()->save();
}
@@ -6346,12 +6210,14 @@ EditorNode::EditorNode() {
editor_data.set_edited_scene(0);
_update_scene_tabs();
+ import_dock->initialize_import_options();
+
{
_initializing_addons = true;
Vector<String> addons;
- if (GlobalConfig::get_singleton()->has("editor_plugins/enabled")) {
- addons = GlobalConfig::get_singleton()->get("editor_plugins/enabled");
+ if (ProjectSettings::get_singleton()->has("editor_plugins/enabled")) {
+ addons = ProjectSettings::get_singleton()->get("editor_plugins/enabled");
}
for (int i = 0; i < addons.size(); i++) {
@@ -6373,10 +6239,10 @@ EditorNode::EditorNode() {
_dim_timer->connect("timeout", this, "_dim_timeout");
add_child(_dim_timer);
- ED_SHORTCUT("editor/editor_2d", TTR("Open 2D Editor"), KEY_F2);
- ED_SHORTCUT("editor/editor_3d", TTR("Open 3D Editor"), KEY_F3);
- ED_SHORTCUT("editor/editor_script", TTR("Open Script Editor"), KEY_F4);
- ED_SHORTCUT("editor/editor_help", TTR("Search Help"), KEY_F1);
+ ED_SHORTCUT("editor/editor_2d", TTR("Open 2D Editor"), KEY_F1);
+ ED_SHORTCUT("editor/editor_3d", TTR("Open 3D Editor"), KEY_F2);
+ ED_SHORTCUT("editor/editor_script", TTR("Open Script Editor"), KEY_F3); //hack neded for script editor F3 search to work :) Assign like this or don't use F3
+ ED_SHORTCUT("editor/editor_help", TTR("Search Help"), KEY_F4);
ED_SHORTCUT("editor/editor_assetlib", TTR("Open Asset Library"));
ED_SHORTCUT("editor/editor_next", TTR("Open the next Editor"));
ED_SHORTCUT("editor/editor_prev", TTR("Open the previous Editor"));
diff --git a/editor/editor_node.h b/editor/editor_node.h
index 5e83cec4a3..a440aaa1e6 100644
--- a/editor/editor_node.h
+++ b/editor/editor_node.h
@@ -33,6 +33,7 @@
#include "editor/call_dialog.h"
#include "editor/connections_dialog.h"
#include "editor/create_dialog.h"
+#include "editor/editor_about.h"
#include "editor/editor_data.h"
#include "editor/editor_path.h"
#include "editor/editor_run.h"
@@ -64,7 +65,7 @@
#include "editor/editor_log.h"
#include "editor/editor_run_script.h"
#include "editor/project_export.h"
-#include "editor/project_settings.h"
+#include "editor/project_settings_editor.h"
#include "editor/resources_dock.h"
#include "editor/run_settings_dialog.h"
#include "editor/scene_tree_dock.h"
@@ -247,10 +248,7 @@ private:
Control *vp_base;
PaneDrag *pd;
//PaneDrag *pd_anim;
- Panel *menu_panel;
- //HSplitContainer *editor_hsplit;
- //VSplitContainer *editor_vsplit;
CenterContainer *play_cc;
HBoxContainer *menu_hb;
Control *viewport;
@@ -300,10 +298,9 @@ private:
ConfirmationDialog *confirmation;
ConfirmationDialog *save_confirmation;
ConfirmationDialog *import_confirmation;
- ConfirmationDialog *open_recent_confirmation;
ConfirmationDialog *pick_main_scene;
AcceptDialog *accept;
- AcceptDialog *about;
+ EditorAbout *about;
AcceptDialog *warning;
int overridden_default_layout;
@@ -314,7 +311,7 @@ private:
//OptimizedPresetsDialog *optimized_presets;
EditorSettingsDialog *settings_config_dialog;
RunSettingsDialog *run_settings_dialog;
- ProjectSettings *project_settings;
+ ProjectSettingsEditor *project_settings;
EditorFileDialog *file;
ExportTemplateManager *export_template_manager;
FileDialog *file_templates;
@@ -326,8 +323,6 @@ private:
String current_path;
MenuButton *update_menu;
- //TabContainer *prop_pallete;
- //TabContainer *top_pallete;
String defer_load_scene;
String defer_export;
String defer_export_platform;
@@ -363,7 +358,7 @@ private:
TabContainer *dock_slot[DOCK_SLOT_MAX];
Rect2 dock_select_rect[DOCK_SLOT_MAX];
int dock_select_rect_over;
- PopupPanel *dock_select_popoup;
+ PopupPanel *dock_select_popup;
Control *dock_select;
ToolButton *dock_tab_move_left;
ToolButton *dock_tab_move_right;
@@ -469,7 +464,7 @@ private:
void _save_scene(String p_file, int idx = -1);
void _save_all_scenes();
- int _next_unsaved_scene();
+ int _next_unsaved_scene(bool p_valid_filename, int p_start = 0);
void _discard_changes(const String &p_str = String());
void _instance_request(const Vector<String> &p_files);
@@ -529,6 +524,7 @@ private:
bool _find_and_save_resource(RES p_res, Map<RES, bool> &processed, int32_t flags);
bool _find_and_save_edited_subresources(Object *obj, Map<RES, bool> &processed, int32_t flags);
void _save_edited_subresources(Node *scene, Map<RES, bool> &processed, int32_t flags);
+ void _mark_unsaved_scenes();
void _find_node_types(Node *p_node, int &count_2d, int &count_3d);
void _save_scene_with_preview(String p_file);
@@ -568,6 +564,7 @@ private:
void _scene_tab_hover(int p_tab);
void _scene_tab_exit();
void _scene_tab_input(const Ref<InputEvent> &p_input);
+ void _reposition_active_tab(int idx_to);
void _thumbnail_done(const String &p_path, const Ref<Texture> &p_preview, const Variant &p_udata);
void _scene_tab_script_edited(int p_tab);
@@ -635,6 +632,8 @@ private:
void _dim_timeout();
void _check_gui_base_size();
+ void _license_tree_selected();
+
protected:
void _notification(int p_what);
static void _bind_methods();
diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp
index e4b055a9e2..c65065db43 100644
--- a/editor/editor_plugin.cpp
+++ b/editor/editor_plugin.cpp
@@ -80,6 +80,24 @@ void EditorPlugin::edit_resource(const Ref<Resource> &p_resource) {
EditorNode::get_singleton()->edit_resource(p_resource);
}
+void EditorPlugin::open_scene_from_path(const String &scene_path) {
+
+ if (EditorNode::get_singleton()->is_changing_scene()) {
+ return;
+ }
+
+ EditorNode::get_singleton()->open_request(scene_path);
+}
+
+void EditorPlugin::reload_scene_from_path(const String &scene_path) {
+
+ if (EditorNode::get_singleton()->is_changing_scene()) {
+ return;
+ }
+
+ EditorNode::get_singleton()->reload_scene(scene_path);
+}
+
void EditorPlugin::add_control_to_container(CustomControlContainer p_location, Control *p_control) {
switch (p_location) {
@@ -153,6 +171,46 @@ void EditorPlugin::set_input_event_forwarding_always_enabled() {
always_input_forwarding_list->add_plugin(this);
}
+Node *EditorPlugin::get_edited_scene_root() {
+ return EditorNode::get_singleton()->get_edited_scene();
+}
+
+Array EditorPlugin::get_open_scenes() const {
+
+ Array ret;
+ Vector<EditorData::EditedScene> scenes = EditorNode::get_singleton()->get_editor_data().get_edited_scenes();
+
+ int scns_amount = scenes.size();
+ for (int idx_scn = 0; idx_scn < scns_amount; idx_scn++) {
+ if (scenes[idx_scn].root == NULL)
+ continue;
+ ret.push_back(scenes[idx_scn].root->get_filename());
+ }
+ return ret;
+}
+
+ScriptEditor *EditorPlugin::get_script_editor() {
+ return ScriptEditor::get_singleton();
+}
+
+void EditorPlugin::notify_scene_changed(const Node *scn_root) {
+ if (scn_root == NULL) return;
+ emit_signal("scene_changed", scn_root);
+}
+
+void EditorPlugin::notify_main_screen_changed(const String &screen_name) {
+
+ if (screen_name == last_main_screen_name)
+ return;
+
+ emit_signal("main_screen_changed", screen_name);
+ last_main_screen_name = screen_name;
+}
+
+void EditorPlugin::notify_scene_closed(const String &scene_filepath) {
+ emit_signal("scene_closed", scene_filepath);
+}
+
Ref<SpatialEditorGizmo> EditorPlugin::create_spatial_gizmo(Spatial *p_spatial) {
//??
if (get_script_instance() && get_script_instance()->has_method("create_spatial_gizmo")) {
@@ -374,11 +432,17 @@ void EditorPlugin::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_undo_redo:UndoRedo"), &EditorPlugin::_get_undo_redo);
ClassDB::bind_method(D_METHOD("get_selection:EditorSelection"), &EditorPlugin::get_selection);
ClassDB::bind_method(D_METHOD("get_editor_settings:EditorSettings"), &EditorPlugin::get_editor_settings);
+ ClassDB::bind_method(D_METHOD("get_script_editor:ScriptEditor"), &EditorPlugin::get_script_editor);
ClassDB::bind_method(D_METHOD("queue_save_layout"), &EditorPlugin::queue_save_layout);
- ClassDB::bind_method(D_METHOD("edit_resource"), &EditorPlugin::edit_resource);
- ClassDB::bind_method(D_METHOD("add_import_plugin"), &EditorPlugin::add_import_plugin);
- ClassDB::bind_method(D_METHOD("remove_import_plugin"), &EditorPlugin::remove_import_plugin);
+ ClassDB::bind_method(D_METHOD("edit_resource", "resource:Resource"), &EditorPlugin::edit_resource);
+ ClassDB::bind_method(D_METHOD("open_scene_from_path", "scene_filepath"), &EditorPlugin::open_scene_from_path);
+ ClassDB::bind_method(D_METHOD("reload_scene_from_path", "scene_filepath"), &EditorPlugin::reload_scene_from_path);
+ ClassDB::bind_method(D_METHOD("add_import_plugin", "importer:EditorImportPlugin"), &EditorPlugin::add_import_plugin);
+ ClassDB::bind_method(D_METHOD("remove_import_plugin", "importer:EditorImportPlugin"), &EditorPlugin::remove_import_plugin);
ClassDB::bind_method(D_METHOD("set_input_event_forwarding_always_enabled"), &EditorPlugin::set_input_event_forwarding_always_enabled);
+ ClassDB::bind_method(D_METHOD("get_open_scenes"), &EditorPlugin::get_open_scenes);
+ ClassDB::bind_method(D_METHOD("get_edited_scene_root:Node"), &EditorPlugin::get_edited_scene_root);
+
ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "forward_canvas_gui_input", PropertyInfo(Variant::TRANSFORM2D, "canvas_xform"), PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent")));
ClassDB::add_virtual_method(get_class_static(), MethodInfo("forward_draw_over_canvas", PropertyInfo(Variant::TRANSFORM2D, "canvas_xform"), PropertyInfo(Variant::OBJECT, "canvas:Control")));
ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "forward_spatial_gui_input", PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Camera"), PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent")));
@@ -400,6 +464,10 @@ void EditorPlugin::_bind_methods() {
ClassDB::add_virtual_method(get_class_static(), MethodInfo("set_window_layout", PropertyInfo(Variant::OBJECT, "layout", PROPERTY_HINT_RESOURCE_TYPE, "ConfigFile")));
ClassDB::add_virtual_method(get_class_static(), MethodInfo("get_window_layout", PropertyInfo(Variant::OBJECT, "layout", PROPERTY_HINT_RESOURCE_TYPE, "ConfigFile")));
+ ADD_SIGNAL(MethodInfo("scene_changed", PropertyInfo(Variant::OBJECT, "scene_root:Node")));
+ ADD_SIGNAL(MethodInfo("scene_closed", PropertyInfo(Variant::STRING, "filepath:String")));
+ ADD_SIGNAL(MethodInfo("main_screen_changed", PropertyInfo(Variant::STRING, "screen_name:String")));
+
BIND_CONSTANT(CONTAINER_TOOLBAR);
BIND_CONSTANT(CONTAINER_SPATIAL_EDITOR_MENU);
BIND_CONSTANT(CONTAINER_SPATIAL_EDITOR_SIDE);
@@ -422,6 +490,7 @@ void EditorPlugin::_bind_methods() {
EditorPlugin::EditorPlugin() {
undo_redo = NULL;
input_event_forwarding_always_enabled = false;
+ last_main_screen_name = "";
}
EditorPlugin::~EditorPlugin() {
diff --git a/editor/editor_plugin.h b/editor/editor_plugin.h
index 57a22a8b2f..a0f64fb1ea 100644
--- a/editor/editor_plugin.h
+++ b/editor/editor_plugin.h
@@ -52,6 +52,8 @@ class EditorImportPlugin;
class EditorExportPlugin;
class EditorResourcePreview;
class EditorFileSystem;
+class EditorToolAddons;
+class ScriptEditor;
class EditorPlugin : public Node {
@@ -63,6 +65,8 @@ class EditorPlugin : public Node {
bool input_event_forwarding_always_enabled;
+ String last_main_screen_name;
+
protected:
static void _bind_methods();
UndoRedo &get_undo_redo() { return *undo_redo; }
@@ -103,6 +107,8 @@ public:
void remove_control_from_bottom_panel(Control *p_control);
Control *get_editor_viewport();
void edit_resource(const Ref<Resource> &p_resource);
+ void open_scene_from_path(const String &scene_path);
+ void reload_scene_from_path(const String &scene_path);
void add_tool_menu_item(const String &p_name, Object *p_handler, const String &p_callback, const Variant &p_ud = Variant());
void add_tool_submenu_item(const String &p_name, Object *p_submenu);
@@ -111,6 +117,14 @@ public:
void set_input_event_forwarding_always_enabled();
bool is_input_event_forwarding_always_enabled() { return input_event_forwarding_always_enabled; }
+ Node *get_edited_scene_root();
+ Array get_open_scenes() const;
+ ScriptEditor *get_script_editor();
+
+ void notify_main_screen_changed(const String &screen_name);
+ void notify_scene_changed(const Node *scn_root);
+ void notify_scene_closed(const String &scene_filepath);
+
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);
diff --git a/editor/editor_plugin_settings.cpp b/editor/editor_plugin_settings.cpp
index c6b9d4bb41..63bee33092 100644
--- a/editor/editor_plugin_settings.cpp
+++ b/editor/editor_plugin_settings.cpp
@@ -30,10 +30,10 @@
#include "editor_plugin_settings.h"
#include "editor_node.h"
-#include "global_config.h"
#include "io/config_file.h"
#include "os/file_access.h"
#include "os/main_loop.h"
+#include "project_settings.h"
#include "scene/gui/margin_container.h"
void EditorPluginSettings::_notification(int p_what) {
@@ -82,7 +82,7 @@ void EditorPluginSettings::update_plugins() {
plugins.sort();
- Vector<String> active_plugins = GlobalConfig::get_singleton()->get("editor_plugins/enabled");
+ Vector<String> active_plugins = ProjectSettings::get_singleton()->get("editor_plugins/enabled");
for (int i = 0; i < plugins.size(); i++) {
diff --git a/editor/editor_resource_preview.cpp b/editor/editor_resource_preview.cpp
index 5d68de3bb6..89fa004eb1 100644
--- a/editor/editor_resource_preview.cpp
+++ b/editor/editor_resource_preview.cpp
@@ -31,11 +31,11 @@
#include "editor_scale.h"
#include "editor_settings.h"
-#include "global_config.h"
#include "io/resource_loader.h"
#include "io/resource_saver.h"
#include "message_queue.h"
#include "os/file_access.h"
+#include "project_settings.h"
bool EditorResourcePreviewGenerator::handles(const String &p_type) const {
@@ -206,7 +206,7 @@ void EditorResourcePreview::_thread() {
} else {
String temp_path = EditorSettings::get_singleton()->get_settings_path().plus_file("tmp");
- String cache_base = GlobalConfig::get_singleton()->globalize_path(item.path).md5_text();
+ String cache_base = ProjectSettings::get_singleton()->globalize_path(item.path).md5_text();
cache_base = temp_path.plus_file("resthumb-" + cache_base);
//does not have it, try to load a cached thumbnail
diff --git a/editor/editor_run.cpp b/editor/editor_run.cpp
index a8106b4eec..aa97dd237b 100644
--- a/editor/editor_run.cpp
+++ b/editor/editor_run.cpp
@@ -30,7 +30,7 @@
#include "editor_run.h"
#include "editor_settings.h"
-#include "global_config.h"
+#include "project_settings.h"
EditorRun::Status EditorRun::get_status() const {
@@ -40,7 +40,7 @@ Error EditorRun::run(const String &p_scene, const String p_custom_args, const Li
List<String> args;
- String resource_path = GlobalConfig::get_singleton()->get_resource_path();
+ String resource_path = ProjectSettings::get_singleton()->get_resource_path();
String remote_host = EditorSettings::get_singleton()->get("network/debug/remote_host");
int remote_port = (int)EditorSettings::get_singleton()->get("network/debug/remote_port");
@@ -79,12 +79,12 @@ Error EditorRun::run(const String &p_scene, const String p_custom_args, const Li
Size2 desired_size;
- desired_size.x = GlobalConfig::get_singleton()->get("display/window/width");
- desired_size.y = GlobalConfig::get_singleton()->get("display/window/height");
+ desired_size.x = ProjectSettings::get_singleton()->get("display/window/size/width");
+ desired_size.y = ProjectSettings::get_singleton()->get("display/window/size/height");
Size2 test_size;
- test_size.x = GlobalConfig::get_singleton()->get("display/window/test_width");
- test_size.y = GlobalConfig::get_singleton()->get("display/window/test_height");
+ test_size.x = ProjectSettings::get_singleton()->get("display/window/size/test_width");
+ test_size.y = ProjectSettings::get_singleton()->get("display/window/size/test_height");
if (test_size.x > 0 && test_size.y > 0) {
desired_size = test_size;
diff --git a/editor/editor_run_script.cpp b/editor/editor_run_script.cpp
index 8bd1b8f4fd..0e980b040e 100644
--- a/editor/editor_run_script.cpp
+++ b/editor/editor_run_script.cpp
@@ -81,8 +81,8 @@ void EditorScript::set_editor(EditorNode *p_editor) {
void EditorScript::_bind_methods() {
- ClassDB::bind_method(D_METHOD("add_root_node", "node"), &EditorScript::add_root_node);
- ClassDB::bind_method(D_METHOD("get_scene"), &EditorScript::get_scene);
+ ClassDB::bind_method(D_METHOD("add_root_node", "node:Node"), &EditorScript::add_root_node);
+ ClassDB::bind_method(D_METHOD("get_scene:Node"), &EditorScript::get_scene);
BIND_VMETHOD(MethodInfo("_run"));
}
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index 5c6ba892cb..755ac75180 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -30,7 +30,6 @@
#include "editor_settings.h"
#include "editor_node.h"
-#include "global_config.h"
#include "io/compression.h"
#include "io/config_file.h"
#include "io/file_access_memory.h"
@@ -41,6 +40,7 @@
#include "os/file_access.h"
#include "os/keyboard.h"
#include "os/os.h"
+#include "project_settings.h"
#include "scene/main/node.h"
#include "scene/main/scene_tree.h"
#include "scene/main/viewport.h"
@@ -216,6 +216,20 @@ Variant _EDITOR_DEF(const String &p_var, const Variant &p_default) {
return p_default;
}
+static void _create_script_templates(const String &p_path) {
+
+ FileAccess *file = FileAccess::open(p_path.plus_file("no_comments.gd"), FileAccess::WRITE);
+ ERR_FAIL_COND(!file);
+ String script = String("extends %BASE%\n\nfunc _ready():\n%TS%pass\n");
+ file->store_string(script);
+ file->close();
+ file->reopen(p_path.plus_file("empty.gd"), FileAccess::WRITE);
+ script = "extends %BASE%\n\n";
+ file->store_string(script);
+ file->close();
+ memdelete(file);
+}
+
void EditorSettings::create() {
if (singleton.ptr())
@@ -294,6 +308,7 @@ void EditorSettings::create() {
if (dir->change_dir("script_templates") != OK) {
dir->make_dir("script_templates");
+ _create_script_templates(dir->get_current_dir() + "/script_templates");
} else {
dir->change_dir("..");
}
@@ -314,7 +329,7 @@ void EditorSettings::create() {
dir->change_dir("config");
- String pcp = GlobalConfig::get_singleton()->get_resource_path();
+ String pcp = ProjectSettings::get_singleton()->get_resource_path();
if (pcp.ends_with("/"))
pcp = config_path.substr(0, pcp.size() - 1);
pcp = pcp.get_file() + "-" + pcp.md5_text();
@@ -522,12 +537,15 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
set("interface/theme/preset", 0);
hints["interface/theme/preset"] = PropertyInfo(Variant::INT, "interface/theme/preset", PROPERTY_HINT_ENUM, "Default,Grey,Godot 2,Arc,Custom", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
- set("interface/theme/base_color", Color::html("#273241"));
+ set("interface/theme/base_color", Color::html("#323b4f"));
hints["interface/theme/highlight_color"] = PropertyInfo(Variant::COLOR, "interface/theme/highlight_color", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
- set("interface/theme/highlight_color", Color::html("#b79047"));
+ set("interface/theme/highlight_color", Color::html("#699ce8"));
hints["interface/theme/base_color"] = PropertyInfo(Variant::COLOR, "interface/theme/base_color", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
set("interface/theme/contrast", 0.2);
hints["interface/theme/contrast"] = PropertyInfo(Variant::REAL, "interface/theme/contrast", PROPERTY_HINT_RANGE, "0.01, 1, 0.01");
+ set("interface/theme/highlight_tabs", false);
+ set("interface/theme/border_size", 1);
+ hints["interface/theme/border_size"] = PropertyInfo(Variant::INT, "interface/theme/border_size", PROPERTY_HINT_RANGE, "0,2,1", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
set("interface/theme/custom_theme", "");
hints["interface/theme/custom_theme"] = PropertyInfo(Variant::STRING, "interface/theme/custom_theme", PROPERTY_HINT_GLOBAL_FILE, "*.res,*.tres,*.theme", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
@@ -598,7 +616,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
set("editors/grid_map/pick_distance", 5000.0);
- set("editors/3d/grid_color", Color(0, 1, 0, 0.2));
+ set("editors/3d/grid_color", Color(1, 1, 1, 0.2));
hints["editors/3d/grid_color"] = PropertyInfo(Variant::COLOR, "editors/3d/grid_color", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
set("editors/3d/default_fov", 55.0);
@@ -620,6 +638,10 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
set("editors/3d/warped_mouse_panning", true);
set("editors/3d/freelook_base_speed", 1);
+
+ set("editors/3d/freelook_activation_modifier", 0);
+ hints["editors/3d/freelook_activation_modifier"] = PropertyInfo(Variant::INT, "editors/3d/freelook_activation_modifier", PROPERTY_HINT_ENUM, "None,Shift,Alt,Meta,Ctrl");
+
set("editors/3d/freelook_modifier_speed_factor", 5.0);
set("editors/2d/bone_width", 5);
diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp
index 7e453a01c6..6b985c7b4b 100644
--- a/editor/editor_themes.cpp
+++ b/editor/editor_themes.cpp
@@ -69,6 +69,15 @@ static Ref<StyleBoxFlat> make_flat_stylebox(Color color, float p_margin_left = -
return style;
}
+static Ref<StyleBoxLine> make_line_stylebox(Color color, int thickness = 1, float grow = 1, bool vertical = false) {
+ Ref<StyleBoxLine> style(memnew(StyleBoxLine));
+ style->set_color(color);
+ style->set_grow(grow);
+ style->set_thickness(thickness);
+ style->set_vertical(vertical);
+ return style;
+}
+
static Ref<StyleBoxFlat> change_border_color(Ref<StyleBoxFlat> p_style, Color p_color) {
Ref<StyleBoxFlat> style = p_style->duplicate();
style->set_light_color(p_color);
@@ -94,17 +103,21 @@ Ref<Theme> create_editor_theme() {
editor_register_fonts(theme);
editor_register_icons(theme);
+ const float default_contrast = 0.25;
+
// Define colors
- Color highlight_color = EDITOR_DEF("interface/theme/highlight_color", Color::html("#b79047"));
- Color base_color = EDITOR_DEF("interface/theme/base_color", Color::html("#273241"));
- float contrast = EDITOR_DEF("interface/theme/contrast", 0.25);
+ Color highlight_color = EDITOR_DEF("interface/theme/highlight_color", Color::html("#000000"));
+ Color base_color = EDITOR_DEF("interface/theme/base_color", Color::html("#000000"));
+ float contrast = EDITOR_DEF("interface/theme/contrast", default_contrast);
int preset = EDITOR_DEF("interface/theme/preset", 0);
+ bool highlight_tabs = EDITOR_DEF("interface/theme/highlight_tabs", false);
+ int border_size = EDITOR_DEF("interface/theme/border_size", 1);
switch (preset) {
case 0: { // Default
- highlight_color = Color::html("#b79047");
- base_color = Color::html("#273241");
- contrast = 0.25;
+ highlight_color = Color::html("#699ce8");
+ base_color = Color::html("#323b4f");
+ contrast = default_contrast;
} break;
case 1: { // Grey
highlight_color = Color::html("#3e3e3e");
@@ -117,9 +130,9 @@ Ref<Theme> create_editor_theme() {
contrast = 0.25;
} break;
case 3: { // Arc
- highlight_color = Color::html("#68a7f2");
- base_color = Color::html("#434a59");
- contrast = 0.2;
+ highlight_color = Color::html("#5294e2");
+ base_color = Color::html("#383c4a");
+ contrast = 0.25;
} break;
}
@@ -130,6 +143,18 @@ Ref<Theme> create_editor_theme() {
Color light_color_1 = base_color.linear_interpolate(Color(1, 1, 1, 1), contrast);
Color light_color_2 = base_color.linear_interpolate(Color(1, 1, 1, 1), contrast * 1.5);
+ const int border_width = (border_size % 3) * EDSCALE;
+
+ Color title_color_hl = base_color;
+ if (highlight_tabs)
+ title_color_hl = base_color.linear_interpolate(Color(1, 1, 1, 1), contrast / default_contrast / 10);
+ bool dark_bg = ((title_color_hl.r + title_color_hl.g + title_color_hl.b) / 3.0) < 0.5;
+ Color title_color_hl_text_color = dark_bg ? Color(1, 1, 1, 0.9) : Color(0, 0, 0, 0.9);
+ Ref<Texture> title_hl_close_icon = theme->get_icon((dark_bg ? "GuiCloseLight" : "GuiCloseDark"), "EditorIcons");
+
+ bool dark_base = ((base_color.r + base_color.g + base_color.b) / 3.0) < 0.5;
+ Color separator_color = dark_base ? Color(1, 1, 1, 0.1) : Color(0, 0, 0, 0.1);
+
theme->set_color("highlight_color", "Editor", highlight_color);
theme->set_color("base_color", "Editor", base_color);
theme->set_color("dark_color_1", "Editor", dark_color_1);
@@ -139,10 +164,10 @@ Ref<Theme> create_editor_theme() {
theme->set_color("light_color_2", "Editor", light_color_2);
// Checkbox icon
- theme->set_icon("checked", "CheckBox", theme->get_icon("Checked", "EditorIcons"));
- theme->set_icon("unchecked", "CheckBox", theme->get_icon("Unchecked", "EditorIcons"));
- theme->set_icon("checked", "PopupMenu", theme->get_icon("Checked", "EditorIcons"));
- theme->set_icon("unchecked", "PopupMenu", theme->get_icon("Unchecked", "EditorIcons"));
+ theme->set_icon("checked", "CheckBox", theme->get_icon("GuiChecked", "EditorIcons"));
+ theme->set_icon("unchecked", "CheckBox", theme->get_icon("GuiUnchecked", "EditorIcons"));
+ theme->set_icon("checked", "PopupMenu", theme->get_icon("GuiChecked", "EditorIcons"));
+ theme->set_icon("unchecked", "PopupMenu", theme->get_icon("GuiUnchecked", "EditorIcons"));
// Editor background
Ref<StyleBoxFlat> style_panel = make_flat_stylebox(dark_color_2, 4, 4, 4, 4);
@@ -151,7 +176,7 @@ Ref<Theme> create_editor_theme() {
// Focus
Ref<StyleBoxFlat> focus_sbt = make_flat_stylebox(light_color_1, 4, 4, 4, 4);
focus_sbt->set_draw_center(false);
- focus_sbt->set_border_size(1 * EDSCALE);
+ focus_sbt->set_border_size(border_width);
focus_sbt = change_border_color(focus_sbt, light_color_2);
theme->set_stylebox("Focus", "EditorStyles", focus_sbt);
@@ -161,13 +186,13 @@ Ref<Theme> create_editor_theme() {
theme->set_stylebox("MenuPanel", "EditorStyles", style_menu);
// Play button group
- theme->set_stylebox("PlayButtonPanel", "EditorStyles", make_stylebox(theme->get_icon("PlayButtonGroup", "EditorIcons"), 16, 16, 16, 16, 8, 4, 8, 4));
+ theme->set_stylebox("PlayButtonPanel", "EditorStyles", make_stylebox(theme->get_icon("GuiPlayButtonGroup", "EditorIcons"), 16, 16, 16, 16, 8, 4, 8, 4));
Ref<StyleBoxFlat> style_menu_hover_border = make_flat_stylebox(highlight_color, 4, 4, 4, 4);
Ref<StyleBoxFlat> style_menu_hover_bg = make_flat_stylebox(dark_color_2, 4, 4, 4, 4);
style_menu_hover_border->set_draw_center(false);
- style_menu_hover_border->_set_additional_border_size(MARGIN_BOTTOM, 1 * EDSCALE);
+ style_menu_hover_border->_set_additional_border_size(MARGIN_BOTTOM, border_width);
theme->set_stylebox("normal", "MenuButton", style_menu);
theme->set_stylebox("hover", "MenuButton", style_menu);
theme->set_stylebox("pressed", "MenuButton", style_menu);
@@ -193,22 +218,37 @@ Ref<Theme> create_editor_theme() {
theme->set_stylebox("MenuHover", "EditorStyles", style_menu_hover_border);
// Content of each tab
- Ref<StyleBoxFlat> style_content_panel = make_flat_stylebox(base_color, 1, 4, 1, 1);
+ Ref<StyleBoxFlat> style_content_panel = make_flat_stylebox(base_color, 4, 5, 4, 4);
+ style_content_panel->set_dark_color(title_color_hl);
+ style_content_panel->set_light_color(title_color_hl);
+ style_content_panel->set_border_size(border_width);
+ style_content_panel->set_border_blend(false);
+ Ref<StyleBoxFlat> style_content_panel_vp = make_flat_stylebox(base_color, border_width, 5, border_width, border_width);
+ style_content_panel_vp->set_dark_color(title_color_hl);
+ style_content_panel_vp->set_light_color(title_color_hl);
+ style_content_panel_vp->set_border_size(border_width);
+ style_content_panel_vp->set_border_blend(false);
theme->set_stylebox("panel", "TabContainer", style_content_panel);
- theme->set_stylebox("Content", "EditorStyles", style_content_panel);
+ theme->set_stylebox("Content", "EditorStyles", style_content_panel_vp);
+
+ Ref<StyleBoxFlat> style_button_type = make_flat_stylebox(dark_color_1, 4, 4, 6, 4);
+ style_button_type->set_draw_center(true);
+ style_button_type->set_border_size(border_width);
+ style_button_type->set_light_color(light_color_1);
+ style_button_type->set_dark_color(light_color_1);
+ style_button_type->set_border_blend(false);
+
+ Ref<StyleBoxFlat> style_button_type_disabled = change_border_color(style_button_type, dark_color_2);
+
+ Color button_font_color = light_color_1.linear_interpolate(Color(1, 1, 1, 1), .6);
// Button
- Ref<StyleBoxFlat> style_button = make_flat_stylebox(dark_color_1, 4, 4, 4, 4);
- style_button->set_draw_center(true);
- style_button->set_border_size(2 * EDSCALE);
- style_button->set_light_color(light_color_1);
- style_button->set_dark_color(light_color_1);
- style_button->set_border_blend(false);
- theme->set_stylebox("normal", "Button", style_button);
- theme->set_stylebox("hover", "Button", style_button);
- theme->set_stylebox("pressed", "Button", style_button);
- theme->set_stylebox("focus", "Button", style_button);
- theme->set_stylebox("disabled", "Button", style_button);
+ theme->set_stylebox("normal", "Button", style_button_type);
+ theme->set_stylebox("hover", "Button", change_border_color(style_button_type, HIGHLIGHT_COLOR_LIGHT));
+ theme->set_stylebox("pressed", "Button", change_border_color(style_button_type, highlight_color));
+ theme->set_stylebox("focus", "Button", change_border_color(style_button_type, highlight_color));
+ theme->set_stylebox("disabled", "Button", style_button_type_disabled);
+ theme->set_color("font_color", "Button", button_font_color);
theme->set_color("font_color_hover", "Button", HIGHLIGHT_COLOR_LIGHT);
theme->set_color("font_color_pressed", "Button", highlight_color);
theme->set_color("icon_color_hover", "Button", HIGHLIGHT_COLOR_LIGHT);
@@ -216,42 +256,60 @@ Ref<Theme> create_editor_theme() {
theme->set_color("icon_color_pressed", "Button", Color(highlight_color.r * 1.15, highlight_color.g * 1.15, highlight_color.b * 1.15, highlight_color.a));
// OptionButton
- Ref<StyleBoxFlat> style_option_button = make_flat_stylebox(dark_color_1, 4, 4, 4, 4);
- style_option_button->set_border_size(1 * EDSCALE);
+ Ref<StyleBoxFlat> style_option_button = make_flat_stylebox(dark_color_1, 4, 4, 8, 4);
+ style_option_button->set_border_size(border_width);
style_option_button->set_light_color(light_color_1);
style_option_button->set_dark_color(light_color_1);
- style_option_button->_set_additional_border_size(MARGIN_RIGHT, -16 * EDSCALE);
- theme->set_stylebox("hover", "OptionButton", change_border_color(style_option_button, HIGHLIGHT_COLOR_LIGHT));
- theme->set_stylebox("pressed", "OptionButton", change_border_color(style_option_button, highlight_color));
- theme->set_stylebox("focus", "OptionButton", change_border_color(style_option_button, highlight_color));
- theme->set_stylebox("disabled", "OptionButton", style_option_button);
- theme->set_stylebox("normal", "OptionButton", style_option_button);
- theme->set_icon("arrow", "OptionButton", theme->get_icon("OptionArrow", "EditorIcons"));
+ style_option_button->set_border_blend(false);
+ theme->set_stylebox("hover", "OptionButton", change_border_color(style_button_type, HIGHLIGHT_COLOR_LIGHT));
+ theme->set_stylebox("pressed", "OptionButton", change_border_color(style_button_type, highlight_color));
+ theme->set_stylebox("focus", "OptionButton", change_border_color(style_button_type, highlight_color));
+ theme->set_stylebox("disabled", "OptionButton", style_button_type_disabled);
+ theme->set_stylebox("normal", "OptionButton", style_button_type);
+ theme->set_color("font_color", "OptionButton", button_font_color);
+ theme->set_color("font_color_hover", "OptionButton", HIGHLIGHT_COLOR_LIGHT);
+ theme->set_color("font_color_pressed", "OptionButton", highlight_color);
+ theme->set_color("icon_color_hover", "OptionButton", HIGHLIGHT_COLOR_LIGHT);
+ theme->set_icon("arrow", "OptionButton", theme->get_icon("GuiOptionArrow", "EditorIcons"));
+ theme->set_constant("arrow_margin", "OptionButton", 4);
+ theme->set_constant("modulate_arrow", "OptionButton", true);
+
+ // CheckButton
+ theme->set_icon("on", "CheckButton", theme->get_icon("GuiToggleOn", "EditorIcons"));
+ theme->set_icon("off", "CheckButton", theme->get_icon("GuiToggleOff", "EditorIcons"));
// PopupMenu
Ref<StyleBoxFlat> style_popup_menu = make_flat_stylebox(dark_color_1, 8, 8, 8, 8);
- style_popup_menu->set_border_size(2 * EDSCALE);
+ style_popup_menu->set_border_size(border_width);
style_popup_menu->set_light_color(light_color_1);
style_popup_menu->set_dark_color(light_color_1);
+ style_popup_menu->set_border_blend(false);
theme->set_stylebox("panel", "PopupMenu", style_popup_menu);
+ theme->set_stylebox("separator", "PopupMenu", make_line_stylebox(separator_color, border_width, 8 - border_width));
// Tree & ItemList background
Ref<StyleBoxFlat> style_tree_bg = make_flat_stylebox(dark_color_1, 2, 4, 2, 4);
+ style_tree_bg->set_border_size(border_width);
+ style_tree_bg->set_light_color(dark_color_3);
+ style_tree_bg->set_dark_color(dark_color_3);
theme->set_stylebox("bg", "Tree", style_tree_bg);
// Script background
Ref<StyleBoxFlat> style_script_bg = make_flat_stylebox(dark_color_1, 0, 0, 0, 0);
+ style_script_bg->set_border_size(border_width);
+ style_script_bg->set_light_color(dark_color_3);
+ style_script_bg->set_dark_color(dark_color_3);
theme->set_stylebox("ScriptPanel", "EditorStyles", style_script_bg);
// Tree
- theme->set_icon("checked", "Tree", theme->get_icon("Checked", "EditorIcons"));
- theme->set_icon("unchecked", "Tree", theme->get_icon("Unchecked", "EditorIcons"));
- theme->set_icon("arrow", "Tree", theme->get_icon("TreeArrowDown", "EditorIcons"));
- theme->set_icon("arrow_collapsed", "Tree", theme->get_icon("TreeArrowRight", "EditorIcons"));
- theme->set_icon("select_arrow", "Tree", theme->get_icon("Dropdown", "EditorIcons"));
+ theme->set_icon("checked", "Tree", theme->get_icon("GuiChecked", "EditorIcons"));
+ theme->set_icon("unchecked", "Tree", theme->get_icon("GuiUnchecked", "EditorIcons"));
+ theme->set_icon("arrow", "Tree", theme->get_icon("GuiTreeArrowDown", "EditorIcons"));
+ theme->set_icon("arrow_collapsed", "Tree", theme->get_icon("GuiTreeArrowRight", "EditorIcons"));
+ theme->set_icon("select_arrow", "Tree", theme->get_icon("GuiDropdown", "EditorIcons"));
theme->set_stylebox("bg_focus", "Tree", focus_sbt);
- theme->set_stylebox("custom_button", "Tree", style_button);
- theme->set_stylebox("custom_button_pressed", "Tree", style_button);
- theme->set_stylebox("custom_button_hover", "Tree", style_button);
+ theme->set_stylebox("custom_button", "Tree", style_button_type);
+ theme->set_stylebox("custom_button_pressed", "Tree", style_button_type);
+ theme->set_stylebox("custom_button_hover", "Tree", style_button_type);
theme->set_color("custom_button_font_highlight", "Tree", HIGHLIGHT_COLOR_LIGHT);
Ref<StyleBox> style_tree_btn = make_flat_stylebox(light_color_1, 2, 4, 2, 4);
@@ -260,12 +318,12 @@ Ref<Theme> create_editor_theme() {
Ref<StyleBoxFlat> style_tree_focus = make_flat_stylebox(HIGHLIGHT_COLOR_DARK, 2, 2, 2, 2);
theme->set_stylebox("selected_focus", "Tree", style_tree_focus);
- Ref<StyleBoxFlat> style_tree_selected = make_flat_stylebox(light_color_1, 2, 2, 2, 2);
+ Ref<StyleBoxFlat> style_tree_selected = make_flat_stylebox(HIGHLIGHT_COLOR_DARK, 2, 2, 2, 2);
theme->set_stylebox("selected", "Tree", style_tree_selected);
Ref<StyleBoxFlat> style_tree_cursor = make_flat_stylebox(HIGHLIGHT_COLOR_DARK, 4, 4, 4, 4);
style_tree_cursor->set_draw_center(false);
- style_tree_cursor->set_border_size(1 * EDSCALE);
+ style_tree_cursor->set_border_size(border_width);
style_tree_cursor->set_light_color(light_color_1);
style_tree_cursor->set_dark_color(light_color_1);
Ref<StyleBoxFlat> style_tree_title = make_flat_stylebox(dark_color_3, 4, 4, 4, 4);
@@ -275,18 +333,21 @@ Ref<Theme> create_editor_theme() {
theme->set_stylebox("title_button_hover", "Tree", style_tree_title);
theme->set_stylebox("title_button_pressed", "Tree", style_tree_title);
- theme->set_color("prop_category", "Editor", dark_color_3);
- theme->set_color("prop_section", "Editor", dark_color_1);
- theme->set_color("prop_subsection", "Editor", dark_color_2);
- theme->set_color("fg_selected", "Editor", Color::html("ffbd8e8e"));
+ theme->set_color("prop_category", "Editor", dark_color_1.linear_interpolate(Color(1, 1, 1, 1), 0.12));
+ theme->set_color("prop_section", "Editor", dark_color_1.linear_interpolate(Color(1, 1, 1, 1), 0.09));
+ theme->set_color("prop_subsection", "Editor", dark_color_1.linear_interpolate(Color(1, 1, 1, 1), 0.06));
+ theme->set_color("fg_selected", "Editor", HIGHLIGHT_COLOR_DARK);
theme->set_color("fg_error", "Editor", Color::html("ffbd8e8e"));
theme->set_color("drop_position_color", "Tree", highlight_color);
// ItemList
Ref<StyleBoxFlat> style_itemlist_bg = make_flat_stylebox(dark_color_1, 4, 4, 4, 4);
+ style_itemlist_bg->set_border_size(border_width);
+ style_itemlist_bg->set_light_color(dark_color_3);
+ style_itemlist_bg->set_dark_color(dark_color_3);
Ref<StyleBoxFlat> style_itemlist_cursor = make_flat_stylebox(highlight_color, 0, 0, 0, 0);
style_itemlist_cursor->set_draw_center(false);
- style_itemlist_cursor->set_border_size(1 * EDSCALE);
+ style_itemlist_cursor->set_border_size(border_width);
style_itemlist_cursor->set_light_color(HIGHLIGHT_COLOR_DARK);
style_itemlist_cursor->set_dark_color(HIGHLIGHT_COLOR_DARK);
theme->set_stylebox("cursor", "ItemList", style_itemlist_cursor);
@@ -297,7 +358,7 @@ Ref<Theme> create_editor_theme() {
theme->set_stylebox("bg", "ItemList", style_itemlist_bg);
theme->set_constant("vseparation", "ItemList", 5 * EDSCALE);
- Ref<StyleBoxFlat> style_tab_fg = make_flat_stylebox(base_color, 15, 5, 15, 5);
+ Ref<StyleBoxFlat> style_tab_fg = make_flat_stylebox(title_color_hl, 15, 5, 15, 5);
Ref<StyleBoxFlat> style_tab_bg = make_flat_stylebox(base_color, 15, 5, 15, 5);
style_tab_bg->set_draw_center(false);
@@ -306,12 +367,17 @@ Ref<Theme> create_editor_theme() {
theme->set_stylebox("tab_bg", "TabContainer", style_tab_bg);
theme->set_stylebox("tab_fg", "Tabs", style_tab_fg);
theme->set_stylebox("tab_bg", "Tabs", style_tab_bg);
- theme->set_color("font_color_fg", "TabContainer", Color(1, 1, 1, 1));
+ theme->set_color("font_color_fg", "TabContainer", title_color_hl_text_color);
theme->set_color("font_color_bg", "TabContainer", light_color_2);
- theme->set_icon("menu", "TabContainer", theme->get_icon("TabMenu", "EditorIcons"));
- theme->set_icon("menu_hl", "TabContainer", theme->get_icon("TabMenu", "EditorIcons"));
- theme->set_stylebox("SceneTabFG", "EditorStyles", make_flat_stylebox(base_color, 10, 5, 10, 5));
+ theme->set_icon("menu", "TabContainer", theme->get_icon("GuiTabMenu", "EditorIcons"));
+ theme->set_icon("menu_hl", "TabContainer", theme->get_icon("GuiTabMenu", "EditorIcons"));
+ theme->set_stylebox("SceneTabFG", "EditorStyles", make_flat_stylebox(title_color_hl, 10, 5, 10, 5));
theme->set_stylebox("SceneTabBG", "EditorStyles", make_empty_stylebox(6, 5, 6, 5));
+ theme->set_icon("close", "Tabs", title_hl_close_icon);
+
+ // Separatos (no separatos)
+ theme->set_stylebox("separator", "HSeparator", make_line_stylebox(separator_color, border_width));
+ theme->set_stylebox("separator", "VSeparator", make_line_stylebox(separator_color, border_width, 0, true));
// Debugger
Ref<StyleBoxFlat> style_panel_debugger = make_flat_stylebox(dark_color_2, 0, 4, 0, 0);
@@ -325,16 +391,15 @@ Ref<Theme> create_editor_theme() {
theme->set_stylebox("DebuggerTabBG", "EditorStyles", style_tab_bg_debugger);
// LineEdit
- Ref<StyleBoxFlat> style_lineedit = make_flat_stylebox(dark_color_1, 4, 4, 4, 4);
- style_lineedit->set_border_size(1 * EDSCALE);
+ Ref<StyleBoxFlat> style_lineedit = style_button_type;
style_lineedit = change_border_color(style_lineedit, light_color_1);
- Ref<StyleBoxFlat> style_lineedit_disabled = style_lineedit->duplicate();
- style_lineedit_disabled->set_bg_color(light_color_1);
+ Ref<StyleBoxFlat> style_lineedit_disabled = change_border_color(style_lineedit, dark_color_1);
+ style_lineedit_disabled->set_bg_color(Color(0, 0, 0, .1));
Ref<StyleBoxFlat> style_lineedit_focus = change_border_color(style_lineedit, highlight_color);
- style_lineedit_focus->set_draw_center(false);
theme->set_stylebox("normal", "LineEdit", style_lineedit);
theme->set_stylebox("focus", "LineEdit", style_lineedit_focus);
theme->set_stylebox("read_only", "LineEdit", style_lineedit_disabled);
+ theme->set_color("read_only", "LineEdit", dark_color_1);
// TextEdit
Ref<StyleBoxFlat> style_textedit_normal(memnew(StyleBoxFlat));
@@ -348,31 +413,37 @@ Ref<Theme> create_editor_theme() {
theme->set_constant("side_margin", "TabContainer", 0);
// H/VSplitContainer
- theme->set_stylebox("bg", "VSplitContainer", make_stylebox(theme->get_icon("VsplitBg", "EditorIcons"), 1, 1, 1, 1));
- theme->set_stylebox("bg", "HSplitContainer", make_stylebox(theme->get_icon("HsplitBg", "EditorIcons"), 1, 1, 1, 1));
+ theme->set_stylebox("bg", "VSplitContainer", make_stylebox(theme->get_icon("GuiVsplitBg", "EditorIcons"), 1, 1, 1, 1));
+ theme->set_stylebox("bg", "HSplitContainer", make_stylebox(theme->get_icon("GuiHsplitBg", "EditorIcons"), 1, 1, 1, 1));
- theme->set_icon("grabber", "VSplitContainer", theme->get_icon("Vsplitter", "EditorIcons"));
- theme->set_icon("grabber", "HSplitContainer", theme->get_icon("Hsplitter", "EditorIcons"));
+ theme->set_icon("grabber", "VSplitContainer", theme->get_icon("GuiVsplitter", "EditorIcons"));
+ theme->set_icon("grabber", "HSplitContainer", theme->get_icon("GuiHsplitter", "EditorIcons"));
theme->set_constant("separation", "HSplitContainer", 8 * EDSCALE);
theme->set_constant("separation", "VSplitContainer", 8 * EDSCALE);
// WindowDialog
Ref<StyleBoxFlat> style_window = make_flat_stylebox(dark_color_2, 4, 4, 4, 4);
- style_window->set_border_size(2 * EDSCALE);
+ style_window->set_border_size(border_width);
style_window->set_border_blend(false);
- style_window->set_light_color(light_color_2);
- style_window->set_dark_color(light_color_2);
+ style_window->set_light_color(title_color_hl);
+ style_window->set_dark_color(title_color_hl);
style_window->_set_additional_border_size(MARGIN_TOP, 24 * EDSCALE);
theme->set_stylebox("panel", "WindowDialog", style_window);
+ theme->set_color("title_color", "WindowDialog", title_color_hl_text_color);
+ theme->set_icon("close", "WindowDialog", title_hl_close_icon);
+ theme->set_icon("close_highlight", "WindowDialog", title_hl_close_icon);
+ theme->set_constant("close_h_ofs", "WindowDialog", 22 * EDSCALE);
+ theme->set_constant("close_v_ofs", "WindowDialog", 20 * EDSCALE);
+ theme->set_constant("title_height", "WindowDialog", 24 * EDSCALE);
// HScrollBar
Ref<Texture> empty_icon = memnew(ImageTexture);
- theme->set_stylebox("scroll", "HScrollBar", make_stylebox(theme->get_icon("ScrollBg", "EditorIcons"), 5, 5, 5, 5, 0, 0, 0, 0));
- theme->set_stylebox("scroll_focus", "HScrollBar", make_stylebox(theme->get_icon("ScrollBg", "EditorIcons"), 5, 5, 5, 5, 0, 0, 0, 0));
- theme->set_stylebox("grabber", "HScrollBar", make_stylebox(theme->get_icon("ScrollGrabber", "EditorIcons"), 6, 6, 6, 6, 2, 2, 2, 2));
- theme->set_stylebox("grabber_highlight", "HScrollBar", make_stylebox(theme->get_icon("ScrollGrabberHl", "EditorIcons"), 5, 5, 5, 5, 2, 2, 2, 2));
+ theme->set_stylebox("scroll", "HScrollBar", make_stylebox(theme->get_icon("GuiScrollBg", "EditorIcons"), 5, 5, 5, 5, 0, 0, 0, 0));
+ theme->set_stylebox("scroll_focus", "HScrollBar", make_stylebox(theme->get_icon("GuiScrollBg", "EditorIcons"), 5, 5, 5, 5, 0, 0, 0, 0));
+ theme->set_stylebox("grabber", "HScrollBar", make_stylebox(theme->get_icon("GuiScrollGrabber", "EditorIcons"), 6, 6, 6, 6, 2, 2, 2, 2));
+ theme->set_stylebox("grabber_highlight", "HScrollBar", make_stylebox(theme->get_icon("GuiScrollGrabberHl", "EditorIcons"), 5, 5, 5, 5, 2, 2, 2, 2));
theme->set_icon("increment", "HScrollBar", empty_icon);
theme->set_icon("increment_highlight", "HScrollBar", empty_icon);
@@ -380,10 +451,10 @@ Ref<Theme> create_editor_theme() {
theme->set_icon("decrement_highlight", "HScrollBar", empty_icon);
// VScrollBar
- theme->set_stylebox("scroll", "VScrollBar", make_stylebox(theme->get_icon("ScrollBg", "EditorIcons"), 5, 5, 5, 5, 0, 0, 0, 0));
- theme->set_stylebox("scroll_focus", "VScrollBar", make_stylebox(theme->get_icon("ScrollBg", "EditorIcons"), 5, 5, 5, 5, 0, 0, 0, 0));
- theme->set_stylebox("grabber", "VScrollBar", make_stylebox(theme->get_icon("ScrollGrabber", "EditorIcons"), 6, 6, 6, 6, 2, 2, 2, 2));
- theme->set_stylebox("grabber_highlight", "VScrollBar", make_stylebox(theme->get_icon("ScrollGrabberHl", "EditorIcons"), 5, 5, 5, 5, 2, 2, 2, 2));
+ theme->set_stylebox("scroll", "VScrollBar", make_stylebox(theme->get_icon("GuiScrollBg", "EditorIcons"), 5, 5, 5, 5, 0, 0, 0, 0));
+ theme->set_stylebox("scroll_focus", "VScrollBar", make_stylebox(theme->get_icon("GuiScrollBg", "EditorIcons"), 5, 5, 5, 5, 0, 0, 0, 0));
+ theme->set_stylebox("grabber", "VScrollBar", make_stylebox(theme->get_icon("GuiScrollGrabber", "EditorIcons"), 6, 6, 6, 6, 2, 2, 2, 2));
+ theme->set_stylebox("grabber_highlight", "VScrollBar", make_stylebox(theme->get_icon("GuiScrollGrabberHl", "EditorIcons"), 5, 5, 5, 5, 2, 2, 2, 2));
theme->set_icon("increment", "VScrollBar", empty_icon);
theme->set_icon("increment_highlight", "VScrollBar", empty_icon);
@@ -391,21 +462,21 @@ Ref<Theme> create_editor_theme() {
theme->set_icon("decrement_highlight", "VScrollBar", empty_icon);
// HSlider
- theme->set_stylebox("slider", "HSlider", make_stylebox(theme->get_icon("HsliderBg", "EditorIcons"), 4, 4, 4, 4));
- theme->set_icon("grabber", "HSlider", theme->get_icon("SliderGrabber", "EditorIcons"));
- theme->set_icon("grabber_highlight", "HSlider", theme->get_icon("SliderGrabberHl", "EditorIcons"));
+ theme->set_stylebox("slider", "HSlider", make_stylebox(theme->get_icon("GuiHsliderBg", "EditorIcons"), 4, 4, 4, 4));
+ theme->set_icon("grabber", "HSlider", theme->get_icon("GuiSliderGrabber", "EditorIcons"));
+ theme->set_icon("grabber_highlight", "HSlider", theme->get_icon("GuiSliderGrabberHl", "EditorIcons"));
// VSlider
- theme->set_stylebox("slider", "VSlider", make_stylebox(theme->get_icon("VsliderBg", "EditorIcons"), 4, 4, 4, 4));
- theme->set_icon("grabber", "VSlider", theme->get_icon("SliderGrabber", "EditorIcons"));
- theme->set_icon("grabber_highlight", "VSlider", theme->get_icon("SliderGrabberHl", "EditorIcons"));
+ theme->set_stylebox("slider", "VSlider", make_stylebox(theme->get_icon("GuiVsliderBg", "EditorIcons"), 4, 4, 4, 4));
+ theme->set_icon("grabber", "VSlider", theme->get_icon("GuiSliderGrabber", "EditorIcons"));
+ theme->set_icon("grabber_highlight", "VSlider", theme->get_icon("GuiSliderGrabberHl", "EditorIcons"));
// Panel
theme->set_stylebox("panel", "Panel", style_panel);
// TooltipPanel
Ref<StyleBoxFlat> style_tooltip = make_flat_stylebox(Color(1, 1, 1, 0.8), 8, 8, 8, 8);
- style_tooltip->set_border_size(2 * EDSCALE);
+ style_tooltip->set_border_size(border_width);
style_tooltip->set_border_blend(false);
style_tooltip->set_light_color(Color(1, 1, 1, 0.9));
style_tooltip->set_dark_color(Color(1, 1, 1, 0.9));
@@ -419,30 +490,42 @@ Ref<Theme> create_editor_theme() {
theme->set_stylebox("panel", "PopupPanel", style_dock_select);
// SpinBox
- theme->set_icon("updown", "SpinBox", theme->get_icon("SpinboxUpdown", "EditorIcons"));
+ theme->set_icon("updown", "SpinBox", theme->get_icon("GuiSpinboxUpdown", "EditorIcons"));
+
+ // ProgressBar
+ theme->set_stylebox("bg", "ProgressBar", make_stylebox(theme->get_icon("GuiProgressBar", "EditorIcons"), 4, 4, 4, 4, 0, 0, 0, 0));
+ theme->set_stylebox("fg", "ProgressBar", make_stylebox(theme->get_icon("GuiProgressFill", "EditorIcons"), 6, 6, 6, 6, 2, 1, 2, 1));
+
+ // theme->set_font("font", "ProgressBar", default_font);
+
+ // theme->set_color("font_color", "ProgressBar", control_font_color_hover);
+ theme->set_color("font_color_shadow", "ProgressBar", Color(0, 0, 0));
+
+ // GraphEdit
+ theme->set_stylebox("bg", "GraphEdit", make_flat_stylebox(dark_color_2, 4, 4, 4, 4));
// GraphNode
Ref<StyleBoxFlat> graphsb = make_flat_stylebox(Color(0, 0, 0, 0.3), 16, 24, 16, 5);
graphsb->set_border_blend(false);
- graphsb->set_border_size(2);
+ graphsb->set_border_size(border_width);
graphsb->set_light_color(Color(1, 1, 1, 0.6));
graphsb->set_dark_color(Color(1, 1, 1, 0.6));
graphsb = add_additional_border(graphsb, 0, -22, 0, 0);
Ref<StyleBoxFlat> graphsbselected = make_flat_stylebox(Color(0, 0, 0, 0.4), 16, 24, 16, 5);
graphsbselected->set_border_blend(false);
- graphsbselected->set_border_size(2);
+ graphsbselected->set_border_size(border_width);
graphsbselected->set_light_color(Color(1, 1, 1, 0.9));
graphsbselected->set_dark_color(Color(1, 1, 1, 0.9));
graphsbselected = add_additional_border(graphsbselected, 0, -22, 0, 0);
Ref<StyleBoxFlat> graphsbcomment = make_flat_stylebox(Color(0, 0, 0, 0.3), 16, 24, 16, 5);
graphsbcomment->set_border_blend(false);
- graphsbcomment->set_border_size(1);
+ graphsbcomment->set_border_size(border_width);
graphsbcomment->set_light_color(Color(1, 1, 1, 0.6));
graphsbcomment->set_dark_color(Color(1, 1, 1, 0.6));
graphsbcomment = add_additional_border(graphsbcomment, 0, -22, 0, 0);
Ref<StyleBoxFlat> graphsbcommentselected = make_flat_stylebox(Color(0, 0, 0, 0.4), 16, 24, 16, 5);
graphsbcommentselected->set_border_blend(false);
- graphsbcommentselected->set_border_size(1);
+ graphsbcommentselected->set_border_size(border_width);
graphsbcommentselected->set_light_color(Color(1, 1, 1, 0.9));
graphsbcommentselected->set_dark_color(Color(1, 1, 1, 0.9));
graphsbcommentselected = add_additional_border(graphsbcommentselected, 0, -22, 0, 0);
diff --git a/editor/file_type_cache.cpp b/editor/file_type_cache.cpp
index de6ee171ae..728e80bba7 100644
--- a/editor/file_type_cache.cpp
+++ b/editor/file_type_cache.cpp
@@ -29,8 +29,8 @@
/*************************************************************************/
#include "file_type_cache.h"
-#include "global_config.h"
#include "os/file_access.h"
+#include "project_settings.h"
FileTypeCache *FileTypeCache::singleton = NULL;
@@ -55,7 +55,7 @@ void FileTypeCache::set_file_type(const String &p_path, const String &p_type) {
void FileTypeCache::load() {
GLOBAL_LOCK_FUNCTION
- String project = GlobalConfig::get_singleton()->get_resource_path();
+ String project = ProjectSettings::get_singleton()->get_resource_path();
FileAccess *f = FileAccess::open(project + "/file_type_cache.cch", FileAccess::READ);
if (!f) {
@@ -80,7 +80,7 @@ void FileTypeCache::load() {
void FileTypeCache::save() {
GLOBAL_LOCK_FUNCTION
- String project = GlobalConfig::get_singleton()->get_resource_path();
+ String project = ProjectSettings::get_singleton()->get_resource_path();
FileAccess *f = FileAccess::open(project + "/file_type_cache.cch", FileAccess::WRITE);
if (!f) {
diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp
index 62fb241ade..77ca1a5145 100644
--- a/editor/filesystem_dock.cpp
+++ b/editor/filesystem_dock.cpp
@@ -31,11 +31,11 @@
#include "editor_node.h"
#include "editor_settings.h"
-#include "global_config.h"
#include "io/resource_loader.h"
#include "os/dir_access.h"
#include "os/file_access.h"
#include "os/os.h"
+#include "project_settings.h"
#include "scene/main/viewport.h"
bool FileSystemDock::_create_tree(TreeItem *p_parent, EditorFileSystemDirectory *p_dir) {
@@ -153,7 +153,7 @@ void FileSystemDock::_notification(int p_what) {
files->connect("item_activated", this, "_select_file");
button_hist_next->connect("pressed", this, "_fw_history");
button_hist_prev->connect("pressed", this, "_bw_history");
- search_icon->set_texture(get_icon("Zoom", "EditorIcons"));
+ search_box->add_icon_override("right_icon", get_icon("Search", "EditorIcons"));
button_hist_next->set_icon(get_icon("Forward", "EditorIcons"));
button_hist_prev->set_icon(get_icon("Back", "EditorIcons"));
@@ -879,7 +879,7 @@ void FileSystemDock::_file_option(int p_option) {
String path = files->get_item_metadata(idx);
if (p_option == FILE_SHOW_IN_EXPLORER) {
- String dir = GlobalConfig::get_singleton()->globalize_path(path);
+ String dir = ProjectSettings::get_singleton()->globalize_path(path);
dir = dir.substr(0, dir.find_last("/"));
OS::get_singleton()->shell_open(String("file://") + dir);
return;
@@ -1067,7 +1067,7 @@ void FileSystemDock::_folder_option(int p_option) {
break;
case FOLDER_SHOW_IN_EXPLORER:
String path = item->get_metadata(tree->get_selected_column());
- String dir = GlobalConfig::get_singleton()->globalize_path(path);
+ String dir = ProjectSettings::get_singleton()->globalize_path(path);
OS::get_singleton()->shell_open(String("file://") + dir);
return;
}
@@ -1749,10 +1749,6 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) {
path_hb->add_child(search_box);
search_box->connect("text_changed", this, "_search_changed");
- search_icon = memnew(TextureRect);
- search_icon->set_stretch_mode(TextureRect::STRETCH_KEEP_CENTERED);
- path_hb->add_child(search_icon);
-
button_display_mode = memnew(ToolButton);
path_hb->add_child(button_display_mode);
button_display_mode->set_toggle_mode(true);
diff --git a/editor/icons/2x/icon_GUI_checked.png b/editor/icons/2x/icon_GUI_checked.png
new file mode 100644
index 0000000000..d51f20b867
--- /dev/null
+++ b/editor/icons/2x/icon_GUI_checked.png
Binary files differ
diff --git a/editor/icons/2x/icon_GUI_dropdown.png b/editor/icons/2x/icon_GUI_dropdown.png
new file mode 100644
index 0000000000..c959378430
--- /dev/null
+++ b/editor/icons/2x/icon_GUI_dropdown.png
Binary files differ
diff --git a/editor/icons/2x/icon_GUI_hslider_bg.png b/editor/icons/2x/icon_GUI_hslider_bg.png
new file mode 100644
index 0000000000..38af962095
--- /dev/null
+++ b/editor/icons/2x/icon_GUI_hslider_bg.png
Binary files differ
diff --git a/editor/icons/2x/icon_GUI_hsplitter.png b/editor/icons/2x/icon_GUI_hsplitter.png
new file mode 100644
index 0000000000..063f0c90fc
--- /dev/null
+++ b/editor/icons/2x/icon_GUI_hsplitter.png
Binary files differ
diff --git a/editor/icons/2x/icon_GUI_option_arrow.png b/editor/icons/2x/icon_GUI_option_arrow.png
new file mode 100644
index 0000000000..87fdc8aa51
--- /dev/null
+++ b/editor/icons/2x/icon_GUI_option_arrow.png
Binary files differ
diff --git a/editor/icons/2x/icon_GUI_play_button_group.png b/editor/icons/2x/icon_GUI_play_button_group.png
new file mode 100644
index 0000000000..6a569d5e80
--- /dev/null
+++ b/editor/icons/2x/icon_GUI_play_button_group.png
Binary files differ
diff --git a/editor/icons/2x/icon_GUI_progress_bar.png b/editor/icons/2x/icon_GUI_progress_bar.png
new file mode 100644
index 0000000000..ca53eba8d0
--- /dev/null
+++ b/editor/icons/2x/icon_GUI_progress_bar.png
Binary files differ
diff --git a/editor/icons/2x/icon_GUI_progress_fill.png b/editor/icons/2x/icon_GUI_progress_fill.png
new file mode 100644
index 0000000000..ac6c562650
--- /dev/null
+++ b/editor/icons/2x/icon_GUI_progress_fill.png
Binary files differ
diff --git a/editor/icons/2x/icon_GUI_scroll_bg.png b/editor/icons/2x/icon_GUI_scroll_bg.png
new file mode 100644
index 0000000000..58369d6f96
--- /dev/null
+++ b/editor/icons/2x/icon_GUI_scroll_bg.png
Binary files differ
diff --git a/editor/icons/2x/icon_GUI_scroll_grabber.png b/editor/icons/2x/icon_GUI_scroll_grabber.png
new file mode 100644
index 0000000000..6f74a9365f
--- /dev/null
+++ b/editor/icons/2x/icon_GUI_scroll_grabber.png
Binary files differ
diff --git a/editor/icons/2x/icon_GUI_scroll_grabber_hl.png b/editor/icons/2x/icon_GUI_scroll_grabber_hl.png
new file mode 100644
index 0000000000..c03ca1adf9
--- /dev/null
+++ b/editor/icons/2x/icon_GUI_scroll_grabber_hl.png
Binary files differ
diff --git a/editor/icons/2x/icon_GUI_slider_grabber.png b/editor/icons/2x/icon_GUI_slider_grabber.png
new file mode 100644
index 0000000000..97e97cb536
--- /dev/null
+++ b/editor/icons/2x/icon_GUI_slider_grabber.png
Binary files differ
diff --git a/editor/icons/2x/icon_GUI_slider_grabber_hl.png b/editor/icons/2x/icon_GUI_slider_grabber_hl.png
new file mode 100644
index 0000000000..2229e25a60
--- /dev/null
+++ b/editor/icons/2x/icon_GUI_slider_grabber_hl.png
Binary files differ
diff --git a/editor/icons/2x/icon_GUI_spinbox_updown.png b/editor/icons/2x/icon_GUI_spinbox_updown.png
new file mode 100644
index 0000000000..a20b43f9c3
--- /dev/null
+++ b/editor/icons/2x/icon_GUI_spinbox_updown.png
Binary files differ
diff --git a/editor/icons/2x/icon_GUI_tab_menu.png b/editor/icons/2x/icon_GUI_tab_menu.png
new file mode 100644
index 0000000000..3887615fee
--- /dev/null
+++ b/editor/icons/2x/icon_GUI_tab_menu.png
Binary files differ
diff --git a/editor/icons/2x/icon_GUI_toggle_off.png b/editor/icons/2x/icon_GUI_toggle_off.png
new file mode 100644
index 0000000000..9da02707d1
--- /dev/null
+++ b/editor/icons/2x/icon_GUI_toggle_off.png
Binary files differ
diff --git a/editor/icons/2x/icon_GUI_toggle_on.png b/editor/icons/2x/icon_GUI_toggle_on.png
new file mode 100644
index 0000000000..41a25e9345
--- /dev/null
+++ b/editor/icons/2x/icon_GUI_toggle_on.png
Binary files differ
diff --git a/editor/icons/2x/icon_GUI_tree_arrow_down.png b/editor/icons/2x/icon_GUI_tree_arrow_down.png
new file mode 100644
index 0000000000..c71c6f4159
--- /dev/null
+++ b/editor/icons/2x/icon_GUI_tree_arrow_down.png
Binary files differ
diff --git a/editor/icons/2x/icon_GUI_tree_arrow_right.png b/editor/icons/2x/icon_GUI_tree_arrow_right.png
new file mode 100644
index 0000000000..66331c730a
--- /dev/null
+++ b/editor/icons/2x/icon_GUI_tree_arrow_right.png
Binary files differ
diff --git a/editor/icons/2x/icon_GUI_unchecked.png b/editor/icons/2x/icon_GUI_unchecked.png
new file mode 100644
index 0000000000..f76b6351d8
--- /dev/null
+++ b/editor/icons/2x/icon_GUI_unchecked.png
Binary files differ
diff --git a/editor/icons/2x/icon_GUI_vslider_bg.png b/editor/icons/2x/icon_GUI_vslider_bg.png
new file mode 100644
index 0000000000..eeb68e2d7a
--- /dev/null
+++ b/editor/icons/2x/icon_GUI_vslider_bg.png
Binary files differ
diff --git a/editor/icons/2x/icon_GUI_vsplit_bg.png b/editor/icons/2x/icon_GUI_vsplit_bg.png
new file mode 100644
index 0000000000..09524bd25a
--- /dev/null
+++ b/editor/icons/2x/icon_GUI_vsplit_bg.png
Binary files differ
diff --git a/editor/icons/2x/icon_GUI_vsplitter.png b/editor/icons/2x/icon_GUI_vsplitter.png
new file mode 100644
index 0000000000..84920525b7
--- /dev/null
+++ b/editor/icons/2x/icon_GUI_vsplitter.png
Binary files differ
diff --git a/editor/icons/2x/icon_animation_tree.png b/editor/icons/2x/icon_animation_tree.png
index a1dd4f137f..ba7930b88f 100644
--- a/editor/icons/2x/icon_animation_tree.png
+++ b/editor/icons/2x/icon_animation_tree.png
Binary files differ
diff --git a/editor/icons/2x/icon_animation_tree_player.png b/editor/icons/2x/icon_animation_tree_player.png
index a1dd4f137f..ba7930b88f 100644
--- a/editor/icons/2x/icon_animation_tree_player.png
+++ b/editor/icons/2x/icon_animation_tree_player.png
Binary files differ
diff --git a/editor/icons/2x/icon_audio_player.png b/editor/icons/2x/icon_audio_stream_player.png
index 799b93cc5d..799b93cc5d 100644
--- a/editor/icons/2x/icon_audio_player.png
+++ b/editor/icons/2x/icon_audio_stream_player.png
Binary files differ
diff --git a/editor/icons/2x/icon_audio_stream_player_2_d.png b/editor/icons/2x/icon_audio_stream_player_2_d.png
new file mode 100644
index 0000000000..f2eaa41769
--- /dev/null
+++ b/editor/icons/2x/icon_audio_stream_player_2_d.png
Binary files differ
diff --git a/editor/icons/2x/icon_audio_stream_sample.png b/editor/icons/2x/icon_audio_stream_sample.png
new file mode 100644
index 0000000000..baaa7bf86f
--- /dev/null
+++ b/editor/icons/2x/icon_audio_stream_sample.png
Binary files differ
diff --git a/editor/icons/2x/icon_bit_map.png b/editor/icons/2x/icon_bit_map.png
index 7372b85944..864d09991e 100644
--- a/editor/icons/2x/icon_bit_map.png
+++ b/editor/icons/2x/icon_bit_map.png
Binary files differ
diff --git a/editor/icons/2x/icon_button.png b/editor/icons/2x/icon_button.png
index 210b0da486..dc07e92b73 100644
--- a/editor/icons/2x/icon_button.png
+++ b/editor/icons/2x/icon_button.png
Binary files differ
diff --git a/editor/icons/2x/icon_button_group.png b/editor/icons/2x/icon_button_group.png
index 47f62005b9..15bcae7690 100644
--- a/editor/icons/2x/icon_button_group.png
+++ b/editor/icons/2x/icon_button_group.png
Binary files differ
diff --git a/editor/icons/2x/icon_capsule_mesh.png b/editor/icons/2x/icon_capsule_mesh.png
new file mode 100644
index 0000000000..ebc48ee736
--- /dev/null
+++ b/editor/icons/2x/icon_capsule_mesh.png
Binary files differ
diff --git a/editor/icons/2x/icon_color_rect.png b/editor/icons/2x/icon_color_rect.png
index 153029ac20..7f258d5d92 100644
--- a/editor/icons/2x/icon_color_rect.png
+++ b/editor/icons/2x/icon_color_rect.png
Binary files differ
diff --git a/editor/icons/2x/icon_confirmation_dialog.png b/editor/icons/2x/icon_confirmation_dialog.png
index a0df7fcd1e..ebf5886445 100644
--- a/editor/icons/2x/icon_confirmation_dialog.png
+++ b/editor/icons/2x/icon_confirmation_dialog.png
Binary files differ
diff --git a/editor/icons/2x/icon_cube_mesh.png b/editor/icons/2x/icon_cube_mesh.png
new file mode 100644
index 0000000000..b2acdd156d
--- /dev/null
+++ b/editor/icons/2x/icon_cube_mesh.png
Binary files differ
diff --git a/editor/icons/2x/icon_curve.png b/editor/icons/2x/icon_curve.png
new file mode 100644
index 0000000000..fb8c209d1e
--- /dev/null
+++ b/editor/icons/2x/icon_curve.png
Binary files differ
diff --git a/editor/icons/2x/icon_cylinder_mesh.png b/editor/icons/2x/icon_cylinder_mesh.png
new file mode 100644
index 0000000000..b36f599522
--- /dev/null
+++ b/editor/icons/2x/icon_cylinder_mesh.png
Binary files differ
diff --git a/editor/icons/2x/icon_debug.png b/editor/icons/2x/icon_debug.png
index 9c581f340f..c007d54b6e 100644
--- a/editor/icons/2x/icon_debug.png
+++ b/editor/icons/2x/icon_debug.png
Binary files differ
diff --git a/editor/icons/2x/icon_environment.png b/editor/icons/2x/icon_environment.png
index 4c4c30b0e5..b8438202c1 100644
--- a/editor/icons/2x/icon_environment.png
+++ b/editor/icons/2x/icon_environment.png
Binary files differ
diff --git a/editor/icons/2x/icon_file_big.png b/editor/icons/2x/icon_file_big.png
index 8c86c6b958..092132ff36 100644
--- a/editor/icons/2x/icon_file_big.png
+++ b/editor/icons/2x/icon_file_big.png
Binary files differ
diff --git a/editor/icons/2x/icon_file_dialog.png b/editor/icons/2x/icon_file_dialog.png
index f19b4d7507..ca34090296 100644
--- a/editor/icons/2x/icon_file_dialog.png
+++ b/editor/icons/2x/icon_file_dialog.png
Binary files differ
diff --git a/editor/icons/2x/icon_g_d_native_library.png b/editor/icons/2x/icon_g_d_native_library.png
new file mode 100644
index 0000000000..1deb0664ed
--- /dev/null
+++ b/editor/icons/2x/icon_g_d_native_library.png
Binary files differ
diff --git a/editor/icons/2x/icon_godot.png b/editor/icons/2x/icon_godot.png
new file mode 100644
index 0000000000..d40c25cae7
--- /dev/null
+++ b/editor/icons/2x/icon_godot.png
Binary files differ
diff --git a/editor/icons/2x/icon_gradient.png b/editor/icons/2x/icon_gradient.png
new file mode 100644
index 0000000000..caf6da5836
--- /dev/null
+++ b/editor/icons/2x/icon_gradient.png
Binary files differ
diff --git a/editor/icons/2x/icon_grid_map.png b/editor/icons/2x/icon_grid_map.png
index 5bbd16d3df..83baf36c1b 100644
--- a/editor/icons/2x/icon_grid_map.png
+++ b/editor/icons/2x/icon_grid_map.png
Binary files differ
diff --git a/editor/icons/2x/icon_gui_close_dark.png b/editor/icons/2x/icon_gui_close_dark.png
new file mode 100644
index 0000000000..fe47e003f9
--- /dev/null
+++ b/editor/icons/2x/icon_gui_close_dark.png
Binary files differ
diff --git a/editor/icons/2x/icon_gui_close_light.png b/editor/icons/2x/icon_gui_close_light.png
new file mode 100644
index 0000000000..2d93123f20
--- /dev/null
+++ b/editor/icons/2x/icon_gui_close_light.png
Binary files differ
diff --git a/editor/icons/2x/icon_h_button_array.png b/editor/icons/2x/icon_h_button_array.png
index 750eef8267..3e4464f33e 100644
--- a/editor/icons/2x/icon_h_button_array.png
+++ b/editor/icons/2x/icon_h_button_array.png
Binary files differ
diff --git a/editor/icons/2x/icon_h_scroll_bar.png b/editor/icons/2x/icon_h_scroll_bar.png
index d15a36bb16..6186d23742 100644
--- a/editor/icons/2x/icon_h_scroll_bar.png
+++ b/editor/icons/2x/icon_h_scroll_bar.png
Binary files differ
diff --git a/editor/icons/2x/icon_h_slider.png b/editor/icons/2x/icon_h_slider.png
index 50bad1cc18..dee580d909 100644
--- a/editor/icons/2x/icon_h_slider.png
+++ b/editor/icons/2x/icon_h_slider.png
Binary files differ
diff --git a/editor/icons/2x/icon_help.png b/editor/icons/2x/icon_help.png
index f16a34c918..771b815020 100644
--- a/editor/icons/2x/icon_help.png
+++ b/editor/icons/2x/icon_help.png
Binary files differ
diff --git a/editor/icons/2x/icon_help_search.png b/editor/icons/2x/icon_help_search.png
new file mode 100644
index 0000000000..a35c4b6070
--- /dev/null
+++ b/editor/icons/2x/icon_help_search.png
Binary files differ
diff --git a/editor/icons/2x/icon_line_edit.png b/editor/icons/2x/icon_line_edit.png
index d0c987388f..e6a0bc4777 100644
--- a/editor/icons/2x/icon_line_edit.png
+++ b/editor/icons/2x/icon_line_edit.png
Binary files differ
diff --git a/editor/icons/2x/icon_load.png b/editor/icons/2x/icon_load.png
index 2e797c448b..759381d636 100644
--- a/editor/icons/2x/icon_load.png
+++ b/editor/icons/2x/icon_load.png
Binary files differ
diff --git a/editor/icons/2x/icon_multi_script.png b/editor/icons/2x/icon_multi_script.png
new file mode 100644
index 0000000000..8a7dd4ee11
--- /dev/null
+++ b/editor/icons/2x/icon_multi_script.png
Binary files differ
diff --git a/editor/icons/2x/icon_nine_patch_rect.png b/editor/icons/2x/icon_nine_patch_rect.png
index 5762a0392e..95edb79936 100644
--- a/editor/icons/2x/icon_nine_patch_rect.png
+++ b/editor/icons/2x/icon_nine_patch_rect.png
Binary files differ
diff --git a/editor/icons/2x/icon_open.png b/editor/icons/2x/icon_open.png
index 2e797c448b..759381d636 100644
--- a/editor/icons/2x/icon_open.png
+++ b/editor/icons/2x/icon_open.png
Binary files differ
diff --git a/editor/icons/2x/icon_option_button.png b/editor/icons/2x/icon_option_button.png
index f4438f9efd..0e9998f856 100644
--- a/editor/icons/2x/icon_option_button.png
+++ b/editor/icons/2x/icon_option_button.png
Binary files differ
diff --git a/editor/icons/2x/icon_panorama_sky.png b/editor/icons/2x/icon_panorama_sky.png
new file mode 100644
index 0000000000..984b92c682
--- /dev/null
+++ b/editor/icons/2x/icon_panorama_sky.png
Binary files differ
diff --git a/editor/icons/2x/icon_plane_mesh.png b/editor/icons/2x/icon_plane_mesh.png
new file mode 100644
index 0000000000..d7692eae72
--- /dev/null
+++ b/editor/icons/2x/icon_plane_mesh.png
Binary files differ
diff --git a/editor/icons/2x/icon_prism_mesh.png b/editor/icons/2x/icon_prism_mesh.png
new file mode 100644
index 0000000000..fcf34ba7a6
--- /dev/null
+++ b/editor/icons/2x/icon_prism_mesh.png
Binary files differ
diff --git a/editor/icons/2x/icon_procedural_sky.png b/editor/icons/2x/icon_procedural_sky.png
new file mode 100644
index 0000000000..b615c16ecb
--- /dev/null
+++ b/editor/icons/2x/icon_procedural_sky.png
Binary files differ
diff --git a/editor/icons/2x/icon_quad_mesh.png b/editor/icons/2x/icon_quad_mesh.png
new file mode 100644
index 0000000000..a8a3513b6d
--- /dev/null
+++ b/editor/icons/2x/icon_quad_mesh.png
Binary files differ
diff --git a/editor/icons/2x/icon_reference_rect.png b/editor/icons/2x/icon_reference_rect.png
index 63fe559fa7..41130f7fdd 100644
--- a/editor/icons/2x/icon_reference_rect.png
+++ b/editor/icons/2x/icon_reference_rect.png
Binary files differ
diff --git a/editor/icons/2x/icon_remote_transform.png b/editor/icons/2x/icon_remote_transform.png
index dad528615a..38bfaad644 100644
--- a/editor/icons/2x/icon_remote_transform.png
+++ b/editor/icons/2x/icon_remote_transform.png
Binary files differ
diff --git a/editor/icons/2x/icon_remote_transform_2d.png b/editor/icons/2x/icon_remote_transform_2d.png
index 7ef3e06f81..022da8a9ef 100644
--- a/editor/icons/2x/icon_remote_transform_2d.png
+++ b/editor/icons/2x/icon_remote_transform_2d.png
Binary files differ
diff --git a/editor/icons/2x/icon_slider_joint.png b/editor/icons/2x/icon_slider_joint.png
index 626479152f..d3bb501bac 100644
--- a/editor/icons/2x/icon_slider_joint.png
+++ b/editor/icons/2x/icon_slider_joint.png
Binary files differ
diff --git a/editor/icons/2x/icon_sphere_mesh.png b/editor/icons/2x/icon_sphere_mesh.png
new file mode 100644
index 0000000000..29b01ebd1b
--- /dev/null
+++ b/editor/icons/2x/icon_sphere_mesh.png
Binary files differ
diff --git a/editor/icons/2x/icon_texture_rect.png b/editor/icons/2x/icon_texture_rect.png
index 50d715dd09..4eba75c4e7 100644
--- a/editor/icons/2x/icon_texture_rect.png
+++ b/editor/icons/2x/icon_texture_rect.png
Binary files differ
diff --git a/editor/icons/2x/icon_timer.png b/editor/icons/2x/icon_timer.png
index b0df31d803..bc07f41828 100644
--- a/editor/icons/2x/icon_timer.png
+++ b/editor/icons/2x/icon_timer.png
Binary files differ
diff --git a/editor/icons/2x/icon_tool_button.png b/editor/icons/2x/icon_tool_button.png
index 091fa8334f..b9dd65518f 100644
--- a/editor/icons/2x/icon_tool_button.png
+++ b/editor/icons/2x/icon_tool_button.png
Binary files differ
diff --git a/editor/icons/2x/icon_tools.png b/editor/icons/2x/icon_tools.png
index 6143191fc7..be76e8fc3a 100644
--- a/editor/icons/2x/icon_tools.png
+++ b/editor/icons/2x/icon_tools.png
Binary files differ
diff --git a/editor/icons/2x/icon_tree.png b/editor/icons/2x/icon_tree.png
index 3f470cc0f3..7fb4f97f83 100644
--- a/editor/icons/2x/icon_tree.png
+++ b/editor/icons/2x/icon_tree.png
Binary files differ
diff --git a/editor/icons/2x/icon_v_button_array.png b/editor/icons/2x/icon_v_button_array.png
index 93fd1fed04..c91d7ec1cb 100644
--- a/editor/icons/2x/icon_v_button_array.png
+++ b/editor/icons/2x/icon_v_button_array.png
Binary files differ
diff --git a/editor/icons/2x/icon_v_scroll_bar.png b/editor/icons/2x/icon_v_scroll_bar.png
index 5e4f83197f..2601f681b7 100644
--- a/editor/icons/2x/icon_v_scroll_bar.png
+++ b/editor/icons/2x/icon_v_scroll_bar.png
Binary files differ
diff --git a/editor/icons/2x/icon_v_slider.png b/editor/icons/2x/icon_v_slider.png
index afc88cf510..fb7d8c2e56 100644
--- a/editor/icons/2x/icon_v_slider.png
+++ b/editor/icons/2x/icon_v_slider.png
Binary files differ
diff --git a/editor/icons/2x/icon_variant.png b/editor/icons/2x/icon_variant.png
new file mode 100644
index 0000000000..bb8075a069
--- /dev/null
+++ b/editor/icons/2x/icon_variant.png
Binary files differ
diff --git a/editor/icons/2x/icon_video_player.png b/editor/icons/2x/icon_video_player.png
index 588e17aa4e..4c1961f2ae 100644
--- a/editor/icons/2x/icon_video_player.png
+++ b/editor/icons/2x/icon_video_player.png
Binary files differ
diff --git a/editor/icons/2x/icon_visual_script.png b/editor/icons/2x/icon_visual_script.png
index 78a3a0c318..eefd214811 100644
--- a/editor/icons/2x/icon_visual_script.png
+++ b/editor/icons/2x/icon_visual_script.png
Binary files differ
diff --git a/editor/icons/2x/icon_world_environment.png b/editor/icons/2x/icon_world_environment.png
index 9ca558fcba..c680dd99bd 100644
--- a/editor/icons/2x/icon_world_environment.png
+++ b/editor/icons/2x/icon_world_environment.png
Binary files differ
diff --git a/editor/icons/icon_GUI_checked.png b/editor/icons/icon_GUI_checked.png
new file mode 100644
index 0000000000..aa5e7f6bdb
--- /dev/null
+++ b/editor/icons/icon_GUI_checked.png
Binary files differ
diff --git a/editor/icons/icon_GUI_dropdown.png b/editor/icons/icon_GUI_dropdown.png
new file mode 100644
index 0000000000..4bd6544830
--- /dev/null
+++ b/editor/icons/icon_GUI_dropdown.png
Binary files differ
diff --git a/editor/icons/icon_GUI_hslider_bg.png b/editor/icons/icon_GUI_hslider_bg.png
new file mode 100644
index 0000000000..1286b887f6
--- /dev/null
+++ b/editor/icons/icon_GUI_hslider_bg.png
Binary files differ
diff --git a/editor/icons/icon_GUI_hsplitter.png b/editor/icons/icon_GUI_hsplitter.png
new file mode 100644
index 0000000000..3ac1dddf90
--- /dev/null
+++ b/editor/icons/icon_GUI_hsplitter.png
Binary files differ
diff --git a/editor/icons/icon_GUI_option_arrow.png b/editor/icons/icon_GUI_option_arrow.png
new file mode 100644
index 0000000000..b7bc38e03f
--- /dev/null
+++ b/editor/icons/icon_GUI_option_arrow.png
Binary files differ
diff --git a/editor/icons/icon_GUI_play_button_group.png b/editor/icons/icon_GUI_play_button_group.png
new file mode 100644
index 0000000000..83820c8e0c
--- /dev/null
+++ b/editor/icons/icon_GUI_play_button_group.png
Binary files differ
diff --git a/editor/icons/icon_GUI_progress_bar.png b/editor/icons/icon_GUI_progress_bar.png
new file mode 100644
index 0000000000..7d70e6beb5
--- /dev/null
+++ b/editor/icons/icon_GUI_progress_bar.png
Binary files differ
diff --git a/editor/icons/icon_GUI_progress_fill.png b/editor/icons/icon_GUI_progress_fill.png
new file mode 100644
index 0000000000..4b7b4c554c
--- /dev/null
+++ b/editor/icons/icon_GUI_progress_fill.png
Binary files differ
diff --git a/editor/icons/icon_GUI_scroll_bg.png b/editor/icons/icon_GUI_scroll_bg.png
new file mode 100644
index 0000000000..1908fd8aee
--- /dev/null
+++ b/editor/icons/icon_GUI_scroll_bg.png
Binary files differ
diff --git a/editor/icons/icon_GUI_scroll_grabber.png b/editor/icons/icon_GUI_scroll_grabber.png
new file mode 100644
index 0000000000..4be7f4e6cc
--- /dev/null
+++ b/editor/icons/icon_GUI_scroll_grabber.png
Binary files differ
diff --git a/editor/icons/icon_GUI_scroll_grabber_hl.png b/editor/icons/icon_GUI_scroll_grabber_hl.png
new file mode 100644
index 0000000000..98e357f82a
--- /dev/null
+++ b/editor/icons/icon_GUI_scroll_grabber_hl.png
Binary files differ
diff --git a/editor/icons/icon_GUI_slider_grabber.png b/editor/icons/icon_GUI_slider_grabber.png
new file mode 100644
index 0000000000..76edc3b81f
--- /dev/null
+++ b/editor/icons/icon_GUI_slider_grabber.png
Binary files differ
diff --git a/editor/icons/icon_GUI_slider_grabber_hl.png b/editor/icons/icon_GUI_slider_grabber_hl.png
new file mode 100644
index 0000000000..97a2f4b67a
--- /dev/null
+++ b/editor/icons/icon_GUI_slider_grabber_hl.png
Binary files differ
diff --git a/editor/icons/icon_GUI_spinbox_updown.png b/editor/icons/icon_GUI_spinbox_updown.png
new file mode 100644
index 0000000000..ff65df801b
--- /dev/null
+++ b/editor/icons/icon_GUI_spinbox_updown.png
Binary files differ
diff --git a/editor/icons/icon_GUI_tab_menu.png b/editor/icons/icon_GUI_tab_menu.png
new file mode 100644
index 0000000000..ffc63f2d41
--- /dev/null
+++ b/editor/icons/icon_GUI_tab_menu.png
Binary files differ
diff --git a/editor/icons/icon_GUI_toggle_off.png b/editor/icons/icon_GUI_toggle_off.png
new file mode 100644
index 0000000000..c4c599172d
--- /dev/null
+++ b/editor/icons/icon_GUI_toggle_off.png
Binary files differ
diff --git a/editor/icons/icon_GUI_toggle_on.png b/editor/icons/icon_GUI_toggle_on.png
new file mode 100644
index 0000000000..9dd6ce7bee
--- /dev/null
+++ b/editor/icons/icon_GUI_toggle_on.png
Binary files differ
diff --git a/editor/icons/icon_GUI_tree_arrow_down.png b/editor/icons/icon_GUI_tree_arrow_down.png
new file mode 100644
index 0000000000..4ef7b41de6
--- /dev/null
+++ b/editor/icons/icon_GUI_tree_arrow_down.png
Binary files differ
diff --git a/editor/icons/icon_GUI_tree_arrow_right.png b/editor/icons/icon_GUI_tree_arrow_right.png
new file mode 100644
index 0000000000..13a42f730d
--- /dev/null
+++ b/editor/icons/icon_GUI_tree_arrow_right.png
Binary files differ
diff --git a/editor/icons/icon_GUI_unchecked.png b/editor/icons/icon_GUI_unchecked.png
new file mode 100644
index 0000000000..8341cdc643
--- /dev/null
+++ b/editor/icons/icon_GUI_unchecked.png
Binary files differ
diff --git a/editor/icons/icon_GUI_vslider_bg.png b/editor/icons/icon_GUI_vslider_bg.png
new file mode 100644
index 0000000000..fa8c6cac1f
--- /dev/null
+++ b/editor/icons/icon_GUI_vslider_bg.png
Binary files differ
diff --git a/editor/icons/icon_GUI_vsplit_bg.png b/editor/icons/icon_GUI_vsplit_bg.png
new file mode 100644
index 0000000000..0c29b1e35c
--- /dev/null
+++ b/editor/icons/icon_GUI_vsplit_bg.png
Binary files differ
diff --git a/editor/icons/icon_GUI_vsplitter.png b/editor/icons/icon_GUI_vsplitter.png
new file mode 100644
index 0000000000..56fb20bc3f
--- /dev/null
+++ b/editor/icons/icon_GUI_vsplitter.png
Binary files differ
diff --git a/editor/icons/icon_animation_tree.png b/editor/icons/icon_animation_tree.png
index 7a29f4d841..0bc8e7245a 100644
--- a/editor/icons/icon_animation_tree.png
+++ b/editor/icons/icon_animation_tree.png
Binary files differ
diff --git a/editor/icons/icon_animation_tree_player.png b/editor/icons/icon_animation_tree_player.png
index 7a29f4d841..0bc8e7245a 100644
--- a/editor/icons/icon_animation_tree_player.png
+++ b/editor/icons/icon_animation_tree_player.png
Binary files differ
diff --git a/editor/icons/icon_audio_stream_player.png b/editor/icons/icon_audio_stream_player.png
new file mode 100644
index 0000000000..c3e6d6cafa
--- /dev/null
+++ b/editor/icons/icon_audio_stream_player.png
Binary files differ
diff --git a/editor/icons/icon_audio_stream_player_2_d.png b/editor/icons/icon_audio_stream_player_2_d.png
new file mode 100644
index 0000000000..a332b876ea
--- /dev/null
+++ b/editor/icons/icon_audio_stream_player_2_d.png
Binary files differ
diff --git a/editor/icons/icon_audio_stream_sample.png b/editor/icons/icon_audio_stream_sample.png
new file mode 100644
index 0000000000..2b97f6198b
--- /dev/null
+++ b/editor/icons/icon_audio_stream_sample.png
Binary files differ
diff --git a/editor/icons/icon_bit_map.png b/editor/icons/icon_bit_map.png
index 50dd8157d1..58468c98bd 100644
--- a/editor/icons/icon_bit_map.png
+++ b/editor/icons/icon_bit_map.png
Binary files differ
diff --git a/editor/icons/icon_button.png b/editor/icons/icon_button.png
index da02831da2..0c39e003e4 100644
--- a/editor/icons/icon_button.png
+++ b/editor/icons/icon_button.png
Binary files differ
diff --git a/editor/icons/icon_button_group.png b/editor/icons/icon_button_group.png
index c105234598..ac2e484abc 100644
--- a/editor/icons/icon_button_group.png
+++ b/editor/icons/icon_button_group.png
Binary files differ
diff --git a/editor/icons/icon_capsule_mesh.png b/editor/icons/icon_capsule_mesh.png
new file mode 100644
index 0000000000..e656b4b047
--- /dev/null
+++ b/editor/icons/icon_capsule_mesh.png
Binary files differ
diff --git a/editor/icons/icon_color_rect.png b/editor/icons/icon_color_rect.png
index 40b9dab605..4199a89049 100644
--- a/editor/icons/icon_color_rect.png
+++ b/editor/icons/icon_color_rect.png
Binary files differ
diff --git a/editor/icons/icon_confirmation_dialog.png b/editor/icons/icon_confirmation_dialog.png
index 2dd4cd00fb..ffadb9d907 100644
--- a/editor/icons/icon_confirmation_dialog.png
+++ b/editor/icons/icon_confirmation_dialog.png
Binary files differ
diff --git a/editor/icons/icon_cube_mesh.png b/editor/icons/icon_cube_mesh.png
new file mode 100644
index 0000000000..a52d7a1823
--- /dev/null
+++ b/editor/icons/icon_cube_mesh.png
Binary files differ
diff --git a/editor/icons/icon_curve.png b/editor/icons/icon_curve.png
index 27d423edcd..a261e00f66 100644
--- a/editor/icons/icon_curve.png
+++ b/editor/icons/icon_curve.png
Binary files differ
diff --git a/editor/icons/icon_cylinder_mesh.png b/editor/icons/icon_cylinder_mesh.png
new file mode 100644
index 0000000000..da147ce7b4
--- /dev/null
+++ b/editor/icons/icon_cylinder_mesh.png
Binary files differ
diff --git a/editor/icons/icon_debug.png b/editor/icons/icon_debug.png
index a4a4591e12..b67e306697 100644
--- a/editor/icons/icon_debug.png
+++ b/editor/icons/icon_debug.png
Binary files differ
diff --git a/editor/icons/icon_environment.png b/editor/icons/icon_environment.png
index c8c4da3e8f..265af5e4ad 100644
--- a/editor/icons/icon_environment.png
+++ b/editor/icons/icon_environment.png
Binary files differ
diff --git a/editor/icons/icon_file_big.png b/editor/icons/icon_file_big.png
index d429736b57..e0aff764f1 100644
--- a/editor/icons/icon_file_big.png
+++ b/editor/icons/icon_file_big.png
Binary files differ
diff --git a/editor/icons/icon_file_dialog.png b/editor/icons/icon_file_dialog.png
index 162827b2b0..c918e2b3b2 100644
--- a/editor/icons/icon_file_dialog.png
+++ b/editor/icons/icon_file_dialog.png
Binary files differ
diff --git a/editor/icons/icon_g_d_native_library.png b/editor/icons/icon_g_d_native_library.png
new file mode 100644
index 0000000000..530e06a982
--- /dev/null
+++ b/editor/icons/icon_g_d_native_library.png
Binary files differ
diff --git a/editor/icons/icon_godot.png b/editor/icons/icon_godot.png
new file mode 100644
index 0000000000..a5e371865c
--- /dev/null
+++ b/editor/icons/icon_godot.png
Binary files differ
diff --git a/editor/icons/icon_gradient.png b/editor/icons/icon_gradient.png
new file mode 100644
index 0000000000..c5e89c3908
--- /dev/null
+++ b/editor/icons/icon_gradient.png
Binary files differ
diff --git a/editor/icons/icon_grid_map.png b/editor/icons/icon_grid_map.png
index 570b11d085..69a431ccba 100644
--- a/editor/icons/icon_grid_map.png
+++ b/editor/icons/icon_grid_map.png
Binary files differ
diff --git a/editor/icons/icon_gui_close_dark.png b/editor/icons/icon_gui_close_dark.png
new file mode 100644
index 0000000000..8f1d7d8b2c
--- /dev/null
+++ b/editor/icons/icon_gui_close_dark.png
Binary files differ
diff --git a/editor/icons/icon_gui_close_light.png b/editor/icons/icon_gui_close_light.png
new file mode 100644
index 0000000000..b8e3a80e3b
--- /dev/null
+++ b/editor/icons/icon_gui_close_light.png
Binary files differ
diff --git a/editor/icons/icon_h_button_array.png b/editor/icons/icon_h_button_array.png
new file mode 100644
index 0000000000..81b2bf79e3
--- /dev/null
+++ b/editor/icons/icon_h_button_array.png
Binary files differ
diff --git a/editor/icons/icon_h_scroll_bar.png b/editor/icons/icon_h_scroll_bar.png
index e4576c4ae3..c6c6daf7a4 100644
--- a/editor/icons/icon_h_scroll_bar.png
+++ b/editor/icons/icon_h_scroll_bar.png
Binary files differ
diff --git a/editor/icons/icon_h_slider.png b/editor/icons/icon_h_slider.png
index 87cf585e14..156364e920 100644
--- a/editor/icons/icon_h_slider.png
+++ b/editor/icons/icon_h_slider.png
Binary files differ
diff --git a/editor/icons/icon_help.png b/editor/icons/icon_help.png
index f05b512f4c..d70807000e 100644
--- a/editor/icons/icon_help.png
+++ b/editor/icons/icon_help.png
Binary files differ
diff --git a/editor/icons/icon_help_search.png b/editor/icons/icon_help_search.png
new file mode 100644
index 0000000000..7a1506853e
--- /dev/null
+++ b/editor/icons/icon_help_search.png
Binary files differ
diff --git a/editor/icons/icon_line_edit.png b/editor/icons/icon_line_edit.png
index 81b5efcf6c..813642f25e 100644
--- a/editor/icons/icon_line_edit.png
+++ b/editor/icons/icon_line_edit.png
Binary files differ
diff --git a/editor/icons/icon_load.png b/editor/icons/icon_load.png
index cc05e98ebb..81835efa25 100644
--- a/editor/icons/icon_load.png
+++ b/editor/icons/icon_load.png
Binary files differ
diff --git a/editor/icons/icon_multi_script.png b/editor/icons/icon_multi_script.png
new file mode 100644
index 0000000000..7626937296
--- /dev/null
+++ b/editor/icons/icon_multi_script.png
Binary files differ
diff --git a/editor/icons/icon_nine_patch_rect.png b/editor/icons/icon_nine_patch_rect.png
index bdd1467144..721bd36d08 100644
--- a/editor/icons/icon_nine_patch_rect.png
+++ b/editor/icons/icon_nine_patch_rect.png
Binary files differ
diff --git a/editor/icons/icon_open.png b/editor/icons/icon_open.png
index cc05e98ebb..81835efa25 100644
--- a/editor/icons/icon_open.png
+++ b/editor/icons/icon_open.png
Binary files differ
diff --git a/editor/icons/icon_option_button.png b/editor/icons/icon_option_button.png
index c1155309aa..b67e951fef 100644
--- a/editor/icons/icon_option_button.png
+++ b/editor/icons/icon_option_button.png
Binary files differ
diff --git a/editor/icons/icon_panorama_sky.png b/editor/icons/icon_panorama_sky.png
new file mode 100644
index 0000000000..38a53afe52
--- /dev/null
+++ b/editor/icons/icon_panorama_sky.png
Binary files differ
diff --git a/editor/icons/icon_plane_mesh.png b/editor/icons/icon_plane_mesh.png
new file mode 100644
index 0000000000..8b86099d67
--- /dev/null
+++ b/editor/icons/icon_plane_mesh.png
Binary files differ
diff --git a/editor/icons/icon_prism_mesh.png b/editor/icons/icon_prism_mesh.png
new file mode 100644
index 0000000000..49f773765f
--- /dev/null
+++ b/editor/icons/icon_prism_mesh.png
Binary files differ
diff --git a/editor/icons/icon_procedural_sky.png b/editor/icons/icon_procedural_sky.png
new file mode 100644
index 0000000000..484bcde038
--- /dev/null
+++ b/editor/icons/icon_procedural_sky.png
Binary files differ
diff --git a/editor/icons/icon_quad_mesh.png b/editor/icons/icon_quad_mesh.png
new file mode 100644
index 0000000000..52f19899a3
--- /dev/null
+++ b/editor/icons/icon_quad_mesh.png
Binary files differ
diff --git a/editor/icons/icon_reference_rect.png b/editor/icons/icon_reference_rect.png
index b253af477f..3d08ee4f76 100644
--- a/editor/icons/icon_reference_rect.png
+++ b/editor/icons/icon_reference_rect.png
Binary files differ
diff --git a/editor/icons/icon_remote_transform.png b/editor/icons/icon_remote_transform.png
index 2a8b5f4d0e..9a6c30bcc8 100644
--- a/editor/icons/icon_remote_transform.png
+++ b/editor/icons/icon_remote_transform.png
Binary files differ
diff --git a/editor/icons/icon_remote_transform_2d.png b/editor/icons/icon_remote_transform_2d.png
index 16d2691832..7266f2a71d 100644
--- a/editor/icons/icon_remote_transform_2d.png
+++ b/editor/icons/icon_remote_transform_2d.png
Binary files differ
diff --git a/editor/icons/icon_slider_joint.png b/editor/icons/icon_slider_joint.png
index d65fb3650d..5b8c2df6ff 100644
--- a/editor/icons/icon_slider_joint.png
+++ b/editor/icons/icon_slider_joint.png
Binary files differ
diff --git a/editor/icons/icon_sphere_mesh.png b/editor/icons/icon_sphere_mesh.png
new file mode 100644
index 0000000000..19ed49c3cd
--- /dev/null
+++ b/editor/icons/icon_sphere_mesh.png
Binary files differ
diff --git a/editor/icons/icon_texture_rect.png b/editor/icons/icon_texture_rect.png
index 84e4a90bfb..20adc22715 100644
--- a/editor/icons/icon_texture_rect.png
+++ b/editor/icons/icon_texture_rect.png
Binary files differ
diff --git a/editor/icons/icon_timer.png b/editor/icons/icon_timer.png
index d3eb6a4b49..81e619cdaa 100644
--- a/editor/icons/icon_timer.png
+++ b/editor/icons/icon_timer.png
Binary files differ
diff --git a/editor/icons/icon_tool_button.png b/editor/icons/icon_tool_button.png
index b2f3f6103f..43c08592c6 100644
--- a/editor/icons/icon_tool_button.png
+++ b/editor/icons/icon_tool_button.png
Binary files differ
diff --git a/editor/icons/icon_tools.png b/editor/icons/icon_tools.png
index 4db4c53796..d81c93f212 100644
--- a/editor/icons/icon_tools.png
+++ b/editor/icons/icon_tools.png
Binary files differ
diff --git a/editor/icons/icon_tree.png b/editor/icons/icon_tree.png
index 50ec1df98b..de856a79fb 100644
--- a/editor/icons/icon_tree.png
+++ b/editor/icons/icon_tree.png
Binary files differ
diff --git a/editor/icons/icon_v_button_array.png b/editor/icons/icon_v_button_array.png
new file mode 100644
index 0000000000..996475ffa4
--- /dev/null
+++ b/editor/icons/icon_v_button_array.png
Binary files differ
diff --git a/editor/icons/icon_v_scroll_bar.png b/editor/icons/icon_v_scroll_bar.png
index 91e00f4619..edd6d4cd67 100644
--- a/editor/icons/icon_v_scroll_bar.png
+++ b/editor/icons/icon_v_scroll_bar.png
Binary files differ
diff --git a/editor/icons/icon_v_slider.png b/editor/icons/icon_v_slider.png
index 545c126d23..d9c0bb00d9 100644
--- a/editor/icons/icon_v_slider.png
+++ b/editor/icons/icon_v_slider.png
Binary files differ
diff --git a/editor/icons/icon_variant.png b/editor/icons/icon_variant.png
index 1ae2812ff7..af7590345e 100644
--- a/editor/icons/icon_variant.png
+++ b/editor/icons/icon_variant.png
Binary files differ
diff --git a/editor/icons/icon_video_player.png b/editor/icons/icon_video_player.png
index 5fd3723b22..0d5dc0ed73 100644
--- a/editor/icons/icon_video_player.png
+++ b/editor/icons/icon_video_player.png
Binary files differ
diff --git a/editor/icons/icon_visual_script.png b/editor/icons/icon_visual_script.png
index 1678998d17..355d3c03c3 100644
--- a/editor/icons/icon_visual_script.png
+++ b/editor/icons/icon_visual_script.png
Binary files differ
diff --git a/editor/icons/icon_world_environment.png b/editor/icons/icon_world_environment.png
index d9f1323386..230d660107 100644
--- a/editor/icons/icon_world_environment.png
+++ b/editor/icons/icon_world_environment.png
Binary files differ
diff --git a/editor/icons/source/icon_dropdown.svg b/editor/icons/source/icon_2_d.svg
index 5963e74007..54c93a45aa 100644
--- a/editor/icons/source/icon_dropdown.svg
+++ b/editor/icons/source/icon_2_d.svg
@@ -9,16 +9,16 @@
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
- width="8"
- height="8"
- viewBox="0 0 8 8"
+ width="16"
+ height="16"
+ viewBox="0 0 16 16"
id="svg2"
version="1.1"
inkscape:version="0.92.1 r"
- inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_collapse.png"
+ inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_add_track.png"
inkscape:export-xdpi="45"
inkscape:export-ydpi="45"
- sodipodi:docname="dropdown.svg">
+ sodipodi:docname="icon_2_d.svg">
<defs
id="defs4" />
<sodipodi:namedview
@@ -28,9 +28,9 @@
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
- inkscape:zoom="64"
- inkscape:cx="3.5701039"
- inkscape:cy="3.3945836"
+ inkscape:zoom="22.627418"
+ inkscape:cx="1.7654173"
+ inkscape:cy="7.2653991"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
@@ -47,6 +47,7 @@
inkscape:window-x="0"
inkscape:window-y="27"
inkscape:window-maximized="1"
+ inkscape:snap-midpoints="true"
inkscape:snap-smooth-nodes="true"
inkscape:object-nodes="true">
<inkscape:grid
@@ -61,7 +62,7 @@
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:title></dc:title>
+ <dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
@@ -69,11 +70,24 @@
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
- transform="translate(0,-1044.3622)">
+ transform="translate(0,-1036.3622)">
<path
- style="fill:none;stroke:#e0e0e0;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.78431374"
- d="m 1,1047.3622 3,3 3,-3"
- id="path4503"
- inkscape:connector-curvature="0" />
+ style="fill:none;stroke:#e0e0e0;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="m 2,1040.3622 2,-2 2,2"
+ id="path4485"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="ccc" />
+ <path
+ style="fill:none;stroke:#e0e0e0;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="m 4,1039.3622 v 9 h 9"
+ id="path4487"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="ccc" />
+ <path
+ sodipodi:nodetypes="ccc"
+ inkscape:connector-curvature="0"
+ id="path4489"
+ d="m 12,1046.3622 2,2 -2,2"
+ style="fill:none;stroke:#e0e0e0;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
</g>
</svg>
diff --git a/editor/icons/source/icon_3_d.svg b/editor/icons/source/icon_3_d.svg
new file mode 100644
index 0000000000..3147d14dc1
--- /dev/null
+++ b/editor/icons/source/icon_3_d.svg
@@ -0,0 +1,105 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="16"
+ height="16"
+ viewBox="0 0 16 16"
+ id="svg2"
+ version="1.1"
+ inkscape:version="0.92.1 r"
+ inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_add_track.png"
+ inkscape:export-xdpi="45"
+ inkscape:export-ydpi="45"
+ sodipodi:docname="icon_3_d.svg">
+ <defs
+ id="defs4" />
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="32.000001"
+ inkscape:cx="7.1007207"
+ inkscape:cy="6.155123"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="true"
+ units="px"
+ inkscape:snap-bbox="true"
+ inkscape:bbox-paths="true"
+ inkscape:bbox-nodes="true"
+ inkscape:snap-bbox-edge-midpoints="true"
+ inkscape:snap-bbox-midpoints="false"
+ inkscape:snap-object-midpoints="true"
+ inkscape:snap-center="true"
+ inkscape:window-width="1600"
+ inkscape:window-height="836"
+ inkscape:window-x="0"
+ inkscape:window-y="27"
+ inkscape:window-maximized="1"
+ inkscape:snap-midpoints="true"
+ inkscape:snap-smooth-nodes="true"
+ inkscape:object-nodes="true">
+ <inkscape:grid
+ type="xygrid"
+ id="grid3336" />
+ </sodipodi:namedview>
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(0,-1036.3622)">
+ <path
+ style="fill:none;stroke:#e0e0e0;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="m 2.0050708,1040.3622 2,-2 2,2"
+ id="path4485"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="ccc" />
+ <path
+ style="fill:none;stroke:#e0e0e0;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="m 4.0050708,1039.3622 v 9 h 9.0000002"
+ id="path4487"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="ccc" />
+ <path
+ sodipodi:nodetypes="ccc"
+ inkscape:connector-curvature="0"
+ id="path4489"
+ d="m 12.005071,1046.3622 2,2 -2,2"
+ style="fill:none;stroke:#e0e0e0;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+ <path
+ style="fill:none;stroke:#e0e0e0;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="m 4.0050708,1048.3622 8.0000002,-8"
+ id="path4496"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cc" />
+ <path
+ sodipodi:nodetypes="ccc"
+ inkscape:connector-curvature="0"
+ id="path4498"
+ d="m 10.176644,1039.3622 h 2.828427 v 2.8284"
+ style="fill:none;stroke:#e0e0e0;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+ </g>
+</svg>
diff --git a/editor/icons/source/icon_checked.svg b/editor/icons/source/icon_GUI_checked.svg
index 6d2c03f4c5..6d2c03f4c5 100644
--- a/editor/icons/source/icon_checked.svg
+++ b/editor/icons/source/icon_GUI_checked.svg
diff --git a/editor/icons/source/icon_GUI_dropdown.svg b/editor/icons/source/icon_GUI_dropdown.svg
new file mode 100644
index 0000000000..f313b09983
--- /dev/null
+++ b/editor/icons/source/icon_GUI_dropdown.svg
@@ -0,0 +1,93 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="8"
+ height="14"
+ viewBox="0 0 8 14"
+ id="svg2"
+ version="1.1"
+ inkscape:version="0.92+devel unknown"
+ inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_collapse.png"
+ inkscape:export-xdpi="45"
+ inkscape:export-ydpi="45"
+ sodipodi:docname="icon_GUI_dropdown.svg">
+ <defs
+ id="defs4" />
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="45.254834"
+ inkscape:cx="1.2944669"
+ inkscape:cy="5.9830116"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="true"
+ units="px"
+ inkscape:snap-bbox="true"
+ inkscape:bbox-paths="true"
+ inkscape:bbox-nodes="true"
+ inkscape:snap-bbox-edge-midpoints="true"
+ inkscape:snap-bbox-midpoints="false"
+ inkscape:snap-object-midpoints="true"
+ inkscape:snap-center="true"
+ inkscape:window-width="1920"
+ inkscape:window-height="1016"
+ inkscape:window-x="0"
+ inkscape:window-y="27"
+ inkscape:window-maximized="1"
+ inkscape:snap-smooth-nodes="true"
+ inkscape:object-nodes="true"
+ inkscape:document-rotation="0">
+ <inkscape:grid
+ type="xygrid"
+ id="grid3336" />
+ </sodipodi:namedview>
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(0,-1038.3622)">
+ <circle
+ style="fill:#ffffff;fill-opacity:0.58823532;stroke-width:2;stroke-linejoin:round;stroke-opacity:0.39215686"
+ id="path4268"
+ cx="4.5"
+ cy="1040.8622"
+ r="1.5" />
+ <circle
+ r="1.5"
+ cy="1045.8622"
+ cx="4.5"
+ id="circle4271"
+ style="fill:#ffffff;fill-opacity:0.58823532;stroke-width:2;stroke-linejoin:round;stroke-opacity:0.39215686" />
+ <circle
+ style="fill:#ffffff;fill-opacity:0.58823532;stroke-width:2;stroke-linejoin:round;stroke-opacity:0.39215686"
+ id="circle4273"
+ cx="4.5"
+ cy="1050.8622"
+ r="1.5" />
+ </g>
+</svg>
diff --git a/editor/icons/source/icon_hslider_bg.svg b/editor/icons/source/icon_GUI_hslider_bg.svg
index 10bea12ab8..a920bf34ab 100644
--- a/editor/icons/source/icon_hslider_bg.svg
+++ b/editor/icons/source/icon_GUI_hslider_bg.svg
@@ -14,8 +14,8 @@
viewBox="0 0 16 15.999999"
id="svg2"
version="1.1"
- inkscape:version="0.92.1 unknown"
- sodipodi:docname="icon_hslider_bg.svg"
+ inkscape:version="0.92+devel unknown"
+ sodipodi:docname="icon_GUI_hslider_bg.svg"
inkscape:export-filename="/mnt/2TB/Development/godot_dev/editor/icons/2x/icon_hslider_bg.png"
inkscape:export-xdpi="96"
inkscape:export-ydpi="96">
@@ -29,8 +29,8 @@
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="32"
- inkscape:cx="4.166346"
- inkscape:cy="6.5721301"
+ inkscape:cx="5.4823689"
+ inkscape:cy="7.6591052"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
@@ -41,13 +41,14 @@
inkscape:bbox-paths="true"
inkscape:bbox-nodes="true"
inkscape:snap-bbox-edge-midpoints="true"
- inkscape:window-width="929"
- inkscape:window-height="897"
- inkscape:window-x="436"
- inkscape:window-y="155"
- inkscape:window-maximized="0"
+ inkscape:window-width="1920"
+ inkscape:window-height="1016"
+ inkscape:window-x="0"
+ inkscape:window-y="27"
+ inkscape:window-maximized="1"
inkscape:snap-smooth-nodes="true"
- inkscape:object-nodes="true">
+ inkscape:object-nodes="true"
+ inkscape:document-rotation="0">
<inkscape:grid
type="xygrid"
id="grid4136"
@@ -70,10 +71,13 @@
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-1036.3623)">
- <path
- style="fill:#000000;fill-opacity:0.19607843;stroke:none;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
- d="M 4 5 A 3 3 0 0 0 1 8 A 3 3 0 0 0 4 11 L 12 11 A 3 3 0 0 0 15 8 A 3 3 0 0 0 12 5 L 4 5 z "
- transform="translate(0,1036.3623)"
- id="path814" />
+ <rect
+ style="fill:#000000;fill-opacity:0.39215687;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:0.3254902"
+ id="rect4266"
+ width="14"
+ height="6"
+ x="1"
+ y="1041.3623"
+ ry="0" />
</g>
</svg>
diff --git a/editor/icons/source/icon_hsplitter.svg b/editor/icons/source/icon_GUI_hsplitter.svg
index 01c893fc56..01c893fc56 100644
--- a/editor/icons/source/icon_hsplitter.svg
+++ b/editor/icons/source/icon_GUI_hsplitter.svg
diff --git a/editor/icons/source/icon_option_arrow.svg b/editor/icons/source/icon_GUI_option_arrow.svg
index 5cd943e9e3..5cd943e9e3 100644
--- a/editor/icons/source/icon_option_arrow.svg
+++ b/editor/icons/source/icon_GUI_option_arrow.svg
diff --git a/editor/icons/source/icon_play_button_group.svg b/editor/icons/source/icon_GUI_play_button_group.svg
index 84bdb00505..84bdb00505 100644
--- a/editor/icons/source/icon_play_button_group.svg
+++ b/editor/icons/source/icon_GUI_play_button_group.svg
diff --git a/editor/icons/source/icon_GUI_progress_bar.svg b/editor/icons/source/icon_GUI_progress_bar.svg
new file mode 100644
index 0000000000..1edd33dd85
--- /dev/null
+++ b/editor/icons/source/icon_GUI_progress_bar.svg
@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="16"
+ height="16"
+ viewBox="0 0 16 15.999999"
+ id="svg2"
+ version="1.1"
+ inkscape:version="0.92+devel unknown"
+ sodipodi:docname="icon_GUI_progress_bar.svg"
+ inkscape:export-filename="/home/djrm/Projects/godot/scene/resources/default_theme/checked.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90">
+ <defs
+ id="defs4" />
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="32"
+ inkscape:cx="11.875071"
+ inkscape:cy="9.2973804"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="true"
+ units="px"
+ inkscape:object-paths="false"
+ inkscape:snap-intersection-paths="false"
+ inkscape:snap-bbox="true"
+ inkscape:bbox-paths="true"
+ inkscape:bbox-nodes="true"
+ inkscape:snap-bbox-edge-midpoints="true"
+ inkscape:window-width="1920"
+ inkscape:window-height="1016"
+ inkscape:window-x="0"
+ inkscape:window-y="27"
+ inkscape:window-maximized="1"
+ inkscape:snap-smooth-nodes="true"
+ inkscape:object-nodes="true"
+ inkscape:document-rotation="0">
+ <inkscape:grid
+ type="xygrid"
+ id="grid4136"
+ empspacing="4" />
+ </sodipodi:namedview>
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(0,-1036.3623)">
+ <path
+ style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-variant-east-asian:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#e0e0e0;fill-opacity:0.39215687;fill-rule:nonzero;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
+ d="m 2,1036.3623 c -1.09070018,-2e-4 -2,0.9073 -2,1.998 v 12.002 c 0,1.0907 0.9092998,2 2,2 h 12 c 1.0907,0 2,-0.9093 2,-2 v -12 c 0,-1.0907 -0.9093,-1.9978 -2,-1.998 z m 0,2 12,0 v 11.998 H 2 Z"
+ id="path4310"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="sssssssssccccc" />
+ </g>
+</svg>
diff --git a/editor/icons/source/icon_vslider_bg.svg b/editor/icons/source/icon_GUI_progress_fill.svg
index b34dddc2d0..cf55c55ab1 100644
--- a/editor/icons/source/icon_vslider_bg.svg
+++ b/editor/icons/source/icon_GUI_progress_fill.svg
@@ -14,8 +14,8 @@
viewBox="0 0 16 15.999999"
id="svg2"
version="1.1"
- inkscape:version="0.92.1 r"
- sodipodi:docname="vslider_bg.svg"
+ inkscape:version="0.92+devel unknown"
+ sodipodi:docname="icon_GUI_progress_fill.svg"
inkscape:export-filename="/home/djrm/Projects/godot/scene/resources/default_theme/checked.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90">
@@ -28,9 +28,9 @@
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
- inkscape:zoom="22.627417"
- inkscape:cx="10.537518"
- inkscape:cy="7.6498812"
+ inkscape:zoom="45.254834"
+ inkscape:cx="10.136535"
+ inkscape:cy="8.7983986"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
@@ -41,13 +41,14 @@
inkscape:bbox-paths="true"
inkscape:bbox-nodes="true"
inkscape:snap-bbox-edge-midpoints="true"
- inkscape:window-width="1600"
- inkscape:window-height="836"
+ inkscape:window-width="1920"
+ inkscape:window-height="1016"
inkscape:window-x="0"
inkscape:window-y="27"
inkscape:window-maximized="1"
inkscape:snap-smooth-nodes="true"
- inkscape:object-nodes="true">
+ inkscape:object-nodes="true"
+ inkscape:document-rotation="0">
<inkscape:grid
type="xygrid"
id="grid4136"
@@ -70,16 +71,13 @@
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-1036.3623)">
- <g
- id="layer1-5"
- inkscape:label="Layer 1"
- transform="rotate(90,8,1044.3623)">
- <path
- id="path814"
- transform="translate(0,1036.3623)"
- d="m 4,5 a 3,3 0 0 0 -3,3 3,3 0 0 0 3,3 h 8 A 3,3 0 0 0 15,8 3,3 0 0 0 12,5 Z"
- style="fill:#000000;fill-opacity:0.19607843;stroke:none;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
- inkscape:connector-curvature="0" />
- </g>
+ <rect
+ style="fill:#e0e0e0;fill-opacity:0.39215687;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round"
+ id="rect4338"
+ width="8"
+ height="7.9999952"
+ x="4"
+ y="1040.3623"
+ ry="0.99999499" />
</g>
</svg>
diff --git a/editor/icons/source/icon_scroll_bg.svg b/editor/icons/source/icon_GUI_scroll_bg.svg
index 29604b9e14..29604b9e14 100644
--- a/editor/icons/source/icon_scroll_bg.svg
+++ b/editor/icons/source/icon_GUI_scroll_bg.svg
diff --git a/editor/icons/source/icon_scroll_grabber.svg b/editor/icons/source/icon_GUI_scroll_grabber.svg
index b9d2bbbec0..b9d2bbbec0 100644
--- a/editor/icons/source/icon_scroll_grabber.svg
+++ b/editor/icons/source/icon_GUI_scroll_grabber.svg
diff --git a/editor/icons/source/icon_scroll_grabber_hl.svg b/editor/icons/source/icon_GUI_scroll_grabber_hl.svg
index ce9a66c5bc..ce9a66c5bc 100644
--- a/editor/icons/source/icon_scroll_grabber_hl.svg
+++ b/editor/icons/source/icon_GUI_scroll_grabber_hl.svg
diff --git a/editor/icons/source/icon_slider_grabber.svg b/editor/icons/source/icon_GUI_slider_grabber.svg
index b13ca5d1a9..fb6c9d1c5c 100644
--- a/editor/icons/source/icon_slider_grabber.svg
+++ b/editor/icons/source/icon_GUI_slider_grabber.svg
@@ -14,8 +14,8 @@
viewBox="0 0 16 15.999999"
id="svg2"
version="1.1"
- inkscape:version="0.92.1 unknown"
- sodipodi:docname="icon_slider_grabber.svg"
+ inkscape:version="0.92+devel unknown"
+ sodipodi:docname="icon_GUI_slider_grabber.svg"
inkscape:export-filename="/home/djrm/Projects/godot/scene/resources/default_theme/checked.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90">
@@ -29,8 +29,8 @@
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="32"
- inkscape:cx="3.7828436"
- inkscape:cy="7.4986644"
+ inkscape:cx="4.462853"
+ inkscape:cy="8.2694974"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
@@ -41,13 +41,14 @@
inkscape:bbox-paths="true"
inkscape:bbox-nodes="true"
inkscape:snap-bbox-edge-midpoints="true"
- inkscape:window-width="1195"
- inkscape:window-height="722"
- inkscape:window-x="91"
- inkscape:window-y="633"
- inkscape:window-maximized="0"
+ inkscape:window-width="1920"
+ inkscape:window-height="1016"
+ inkscape:window-x="0"
+ inkscape:window-y="27"
+ inkscape:window-maximized="1"
inkscape:snap-smooth-nodes="true"
- inkscape:object-nodes="true">
+ inkscape:object-nodes="true"
+ inkscape:document-rotation="0">
<inkscape:grid
type="xygrid"
id="grid4136"
@@ -61,7 +62,7 @@
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:title></dc:title>
+ <dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
@@ -71,10 +72,10 @@
id="layer1"
transform="translate(0,-1036.3623)">
<circle
- r="6.9999943"
+ style="fill:#ffffff;fill-opacity:0.78431374;stroke-width:2.99999523;stroke-linejoin:round;stroke-opacity:0.39215686"
+ id="path4266"
+ cx="8"
cy="1044.3623"
- cx="8.0000057"
- id="circle4262"
- style="fill:#d3d3d3;fill-opacity:1;stroke:none;stroke-width:20;stroke-linecap:square;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+ r="2.9999952" />
</g>
</svg>
diff --git a/editor/icons/source/icon_GUI_slider_grabber_hl.svg b/editor/icons/source/icon_GUI_slider_grabber_hl.svg
new file mode 100644
index 0000000000..c7e9018ac3
--- /dev/null
+++ b/editor/icons/source/icon_GUI_slider_grabber_hl.svg
@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="16"
+ height="16"
+ viewBox="0 0 16 15.999999"
+ id="svg2"
+ version="1.1"
+ inkscape:version="0.92+devel unknown"
+ sodipodi:docname="icon_GUI_slider_grabber_hl.svg"
+ inkscape:export-filename="/home/djrm/Projects/godot/scene/resources/default_theme/checked.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90">
+ <defs
+ id="defs4" />
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="32"
+ inkscape:cx="9.784247"
+ inkscape:cy="7.9005685"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="true"
+ units="px"
+ inkscape:object-paths="false"
+ inkscape:snap-intersection-paths="false"
+ inkscape:snap-bbox="true"
+ inkscape:bbox-paths="true"
+ inkscape:bbox-nodes="true"
+ inkscape:snap-bbox-edge-midpoints="true"
+ inkscape:window-width="1920"
+ inkscape:window-height="1016"
+ inkscape:window-x="0"
+ inkscape:window-y="27"
+ inkscape:window-maximized="1"
+ inkscape:snap-smooth-nodes="true"
+ inkscape:object-nodes="true"
+ inkscape:document-rotation="0">
+ <inkscape:grid
+ type="xygrid"
+ id="grid4136"
+ empspacing="4" />
+ </sodipodi:namedview>
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(0,-1036.3623)">
+ <path
+ style="fill:#d3d3d3;fill-opacity:1;stroke:none;stroke-width:20;stroke-linecap:square;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="M 8 1 A 6.9999943 6.9999943 0 0 0 1 8 A 6.9999943 6.9999943 0 0 0 8 15 A 6.9999943 6.9999943 0 0 0 15 8 A 6.9999943 6.9999943 0 0 0 8 1 z M 8 3 A 4.9999943 4.9999943 0 0 1 8.5 3.0253906 A 4.9999943 4.9999943 0 0 1 8.9941406 3.0996094 A 4.9999943 4.9999943 0 0 1 9.4785156 3.2226562 A 4.9999943 4.9999943 0 0 1 9.9472656 3.3945312 A 4.9999943 4.9999943 0 0 1 10.396484 3.6113281 A 4.9999943 4.9999943 0 0 1 10.822266 3.8730469 A 4.9999943 4.9999943 0 0 1 11.220703 4.1757812 A 4.9999943 4.9999943 0 0 1 11.585938 4.515625 A 4.9999943 4.9999943 0 0 1 11.916016 4.8925781 A 4.9999943 4.9999943 0 0 1 12.207031 5.2988281 A 4.9999943 4.9999943 0 0 1 12.455078 5.7324219 A 4.9999943 4.9999943 0 0 1 12.660156 6.1875 A 4.9999943 4.9999943 0 0 1 12.818359 6.6621094 A 4.9999943 4.9999943 0 0 1 12.927734 7.1503906 A 4.9999943 4.9999943 0 0 1 12.988281 7.6464844 A 4.9999943 4.9999943 0 0 1 13 8 A 4.9999943 4.9999943 0 0 1 12.974609 8.5 A 4.9999943 4.9999943 0 0 1 12.900391 8.9941406 A 4.9999943 4.9999943 0 0 1 12.777344 9.4785156 A 4.9999943 4.9999943 0 0 1 12.605469 9.9472656 A 4.9999943 4.9999943 0 0 1 12.388672 10.396484 A 4.9999943 4.9999943 0 0 1 12.126953 10.822266 A 4.9999943 4.9999943 0 0 1 11.824219 11.220703 A 4.9999943 4.9999943 0 0 1 11.484375 11.585938 A 4.9999943 4.9999943 0 0 1 11.107422 11.916016 A 4.9999943 4.9999943 0 0 1 10.701172 12.207031 A 4.9999943 4.9999943 0 0 1 10.267578 12.455078 A 4.9999943 4.9999943 0 0 1 9.8125 12.660156 A 4.9999943 4.9999943 0 0 1 9.3378906 12.818359 A 4.9999943 4.9999943 0 0 1 8.8496094 12.927734 A 4.9999943 4.9999943 0 0 1 8.3535156 12.988281 A 4.9999943 4.9999943 0 0 1 8 13 A 4.9999943 4.9999943 0 0 1 7.5 12.974609 A 4.9999943 4.9999943 0 0 1 7.0058594 12.900391 A 4.9999943 4.9999943 0 0 1 6.5214844 12.777344 A 4.9999943 4.9999943 0 0 1 6.0527344 12.605469 A 4.9999943 4.9999943 0 0 1 5.6035156 12.388672 A 4.9999943 4.9999943 0 0 1 5.1777344 12.126953 A 4.9999943 4.9999943 0 0 1 4.7792969 11.824219 A 4.9999943 4.9999943 0 0 1 4.4140625 11.484375 A 4.9999943 4.9999943 0 0 1 4.0839844 11.107422 A 4.9999943 4.9999943 0 0 1 3.7929688 10.701172 A 4.9999943 4.9999943 0 0 1 3.5449219 10.267578 A 4.9999943 4.9999943 0 0 1 3.3398438 9.8125 A 4.9999943 4.9999943 0 0 1 3.1816406 9.3378906 A 4.9999943 4.9999943 0 0 1 3.0722656 8.8496094 A 4.9999943 4.9999943 0 0 1 3.0117188 8.3535156 A 4.9999943 4.9999943 0 0 1 3 8 A 4.9999943 4.9999943 0 0 1 3.0253906 7.5 A 4.9999943 4.9999943 0 0 1 3.0996094 7.0058594 A 4.9999943 4.9999943 0 0 1 3.2226562 6.5214844 A 4.9999943 4.9999943 0 0 1 3.3945312 6.0527344 A 4.9999943 4.9999943 0 0 1 3.6113281 5.6035156 A 4.9999943 4.9999943 0 0 1 3.8730469 5.1777344 A 4.9999943 4.9999943 0 0 1 4.1757812 4.7792969 A 4.9999943 4.9999943 0 0 1 4.515625 4.4140625 A 4.9999943 4.9999943 0 0 1 4.8925781 4.0839844 A 4.9999943 4.9999943 0 0 1 5.2988281 3.7929688 A 4.9999943 4.9999943 0 0 1 5.7324219 3.5449219 A 4.9999943 4.9999943 0 0 1 6.1875 3.3398438 A 4.9999943 4.9999943 0 0 1 6.6621094 3.1816406 A 4.9999943 4.9999943 0 0 1 7.1503906 3.0722656 A 4.9999943 4.9999943 0 0 1 7.6464844 3.0117188 A 4.9999943 4.9999943 0 0 1 8 3 z "
+ id="circle4262"
+ transform="translate(0,1036.3623)" />
+ <circle
+ style="fill:#ffffff;fill-opacity:0.58823529;stroke-width:2.99999523;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:0.3254902"
+ id="path4271"
+ cx="8"
+ cy="1044.3623"
+ r="2.9999952" />
+ </g>
+</svg>
diff --git a/editor/icons/source/icon_spinbox_updown.svg b/editor/icons/source/icon_GUI_spinbox_updown.svg
index e29d7fe0d2..e29d7fe0d2 100644
--- a/editor/icons/source/icon_spinbox_updown.svg
+++ b/editor/icons/source/icon_GUI_spinbox_updown.svg
diff --git a/editor/icons/source/icon_tab_menu.svg b/editor/icons/source/icon_GUI_tab_menu.svg
index 39e0d1f261..39e0d1f261 100644
--- a/editor/icons/source/icon_tab_menu.svg
+++ b/editor/icons/source/icon_GUI_tab_menu.svg
diff --git a/editor/icons/source/icon_GUI_toggle_off.svg b/editor/icons/source/icon_GUI_toggle_off.svg
new file mode 100644
index 0000000000..f0cf10a653
--- /dev/null
+++ b/editor/icons/source/icon_GUI_toggle_off.svg
@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="64"
+ height="32"
+ viewBox="0 0 64 31.999998"
+ id="svg2"
+ version="1.1"
+ inkscape:version="0.92+devel unknown"
+ sodipodi:docname="icon_GUI_toggle_off.svg"
+ inkscape:export-filename="/mnt/2TB/Development/godot_dev/editor/icons/2x/icon_hslider_bg.png"
+ inkscape:export-xdpi="96"
+ inkscape:export-ydpi="96">
+ <defs
+ id="defs4" />
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="16"
+ inkscape:cx="35.349571"
+ inkscape:cy="18.723365"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="true"
+ units="px"
+ inkscape:object-paths="false"
+ inkscape:snap-intersection-paths="false"
+ inkscape:snap-bbox="true"
+ inkscape:bbox-paths="true"
+ inkscape:bbox-nodes="true"
+ inkscape:snap-bbox-edge-midpoints="true"
+ inkscape:window-width="1920"
+ inkscape:window-height="1016"
+ inkscape:window-x="0"
+ inkscape:window-y="27"
+ inkscape:window-maximized="1"
+ inkscape:snap-smooth-nodes="true"
+ inkscape:object-nodes="true"
+ inkscape:document-rotation="0">
+ <inkscape:grid
+ type="xygrid"
+ id="grid4136"
+ empspacing="4" />
+ </sodipodi:namedview>
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(0,-1020.3623)">
+ <path
+ style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-variant-east-asian:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#e0e0e0;fill-opacity:0.78431374;fill-rule:nonzero;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;filter-blend-mode:normal;filter-gaussianBlur-deviation:0;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate;opacity:1"
+ d="M 24 4.0019531 C 17.3693 4.0019531 12 9.3673469 12 15.998047 L 12 16.001953 C 12 22.632653 17.3693 28.001953 24 28.001953 L 40 28.001953 C 46.6307 28.001953 52 22.632653 52 16.001953 L 52 15.998047 C 52 9.3673469 46.6307 4.0019531 40 4.0019531 L 24 4.0019531 z M 24 6.0019531 L 40 6.0019531 C 45.557295 6.0019531 50 10.440747 50 15.998047 L 50 16.001953 C 50 21.559253 45.557295 26.001953 40 26.001953 L 24 26.001953 C 18.442705 26.001953 14 21.559253 14 16.001953 L 14 15.998047 C 14 10.440747 18.442705 6.0019531 24 6.0019531 z M 31 10.998047 A 1.0001 1.0001 0 0 0 30 11.998047 L 30 19.998047 A 1 1 0 0 0 31 20.998047 A 1 1 0 0 0 32 19.998047 L 32 16.998047 L 34 16.998047 A 1 1 0 0 0 35 15.998047 A 1 1 0 0 0 34 14.998047 L 32 14.998047 L 32 12.998047 L 36 12.998047 A 1 1 0 0 0 37 11.998047 A 1 1 0 0 0 36 10.998047 L 31 10.998047 z M 40 10.998047 A 1.0001 1.0001 0 0 0 39 11.998047 L 39 15.998047 L 39 19.998047 A 1 1 0 0 0 40 20.998047 A 1 1 0 0 0 41 19.998047 L 41 16.998047 L 43 16.998047 A 1 1 0 0 0 44 15.998047 A 1 1 0 0 0 43 14.998047 L 41 14.998047 L 41 12.998047 L 45 12.998047 A 1 1 0 0 0 46 11.998047 A 1 1 0 0 0 45 10.998047 L 40 10.998047 z M 23 11.001953 C 20.250421 11.001953 18 13.252353 18 16.001953 C 18 18.751553 20.250421 21.001953 23 21.001953 C 25.749579 21.001953 28 18.751553 28 16.001953 C 28 13.252353 25.749579 11.001953 23 11.001953 z M 23 13.001953 C 24.668699 13.001953 26 14.333253 26 16.001953 C 26 17.670653 24.668699 19.001953 23 19.001953 C 21.331301 19.001953 20 17.670653 20 16.001953 C 20 14.333253 21.331301 13.001953 23 13.001953 z "
+ transform="translate(0,1020.3623)"
+ id="path4442" />
+ </g>
+</svg>
diff --git a/editor/icons/source/icon_GUI_toggle_on.svg b/editor/icons/source/icon_GUI_toggle_on.svg
new file mode 100644
index 0000000000..79715dd767
--- /dev/null
+++ b/editor/icons/source/icon_GUI_toggle_on.svg
@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="64"
+ height="32"
+ viewBox="0 0 64 31.999998"
+ id="svg2"
+ version="1.1"
+ inkscape:version="0.92+devel unknown"
+ sodipodi:docname="icon_GUI_toggle_on.svg"
+ inkscape:export-filename="/mnt/2TB/Development/godot_dev/editor/icons/2x/icon_hslider_bg.png"
+ inkscape:export-xdpi="96"
+ inkscape:export-ydpi="96">
+ <defs
+ id="defs4" />
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="8"
+ inkscape:cx="32.275235"
+ inkscape:cy="18.558884"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="true"
+ units="px"
+ inkscape:object-paths="false"
+ inkscape:snap-intersection-paths="false"
+ inkscape:snap-bbox="true"
+ inkscape:bbox-paths="true"
+ inkscape:bbox-nodes="true"
+ inkscape:snap-bbox-edge-midpoints="true"
+ inkscape:window-width="1920"
+ inkscape:window-height="1016"
+ inkscape:window-x="0"
+ inkscape:window-y="27"
+ inkscape:window-maximized="1"
+ inkscape:snap-smooth-nodes="true"
+ inkscape:object-nodes="true"
+ inkscape:document-rotation="0">
+ <inkscape:grid
+ type="xygrid"
+ id="grid4136"
+ empspacing="4" />
+ </sodipodi:namedview>
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(0,-1020.3623)">
+ <path
+ style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-variant-east-asian:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#e0e0e0;fill-opacity:0.78431374;fill-rule:nonzero;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
+ d="M 24 4.0019531 C 17.3693 4.0019531 12 9.3673469 12 15.998047 C 12 22.628747 17.3693 27.998047 24 27.998047 L 40 27.998047 C 46.6307 27.998047 52 22.628747 52 15.998047 C 52 9.3673469 46.6307 4.0019531 40 4.0019531 L 24 4.0019531 z M 41 10.998047 A 1 1 0 0 1 42 11.998047 L 42 19.998047 A 1.0001 1.0001 0 0 1 40.248047 20.660156 L 35 14.660156 L 35 19.998047 A 1 1 0 0 1 34 20.998047 A 1 1 0 0 1 33 19.998047 L 33 11.998047 A 1.0001 1.0001 0 0 1 34.751953 11.339844 L 40 17.339844 L 40 11.998047 A 1 1 0 0 1 41 10.998047 z M 26 11.001953 C 28.749579 11.001953 31 13.252353 31 16.001953 C 31 18.751553 28.749579 21.001953 26 21.001953 C 23.250421 21.001953 21 18.751553 21 16.001953 C 21 13.252353 23.250421 11.001953 26 11.001953 z M 26 13.001953 C 24.331301 13.001953 23 14.333253 23 16.001953 C 23 17.670653 24.331301 19.001953 26 19.001953 C 27.668699 19.001953 29 17.670653 29 16.001953 C 29 14.333253 27.668699 13.001953 26 13.001953 z "
+ transform="translate(0,1020.3623)"
+ id="path4272" />
+ </g>
+</svg>
diff --git a/editor/icons/source/icon_tree_arrow_down.svg b/editor/icons/source/icon_GUI_tree_arrow_down.svg
index 1dd209720f..1dd209720f 100644
--- a/editor/icons/source/icon_tree_arrow_down.svg
+++ b/editor/icons/source/icon_GUI_tree_arrow_down.svg
diff --git a/editor/icons/source/icon_tree_arrow_right.svg b/editor/icons/source/icon_GUI_tree_arrow_right.svg
index 43134ba1b1..43134ba1b1 100644
--- a/editor/icons/source/icon_tree_arrow_right.svg
+++ b/editor/icons/source/icon_GUI_tree_arrow_right.svg
diff --git a/editor/icons/source/icon_unchecked.svg b/editor/icons/source/icon_GUI_unchecked.svg
index 053cbe6de5..053cbe6de5 100644
--- a/editor/icons/source/icon_unchecked.svg
+++ b/editor/icons/source/icon_GUI_unchecked.svg
diff --git a/editor/icons/source/icon_GUI_vslider_bg.svg b/editor/icons/source/icon_GUI_vslider_bg.svg
new file mode 100644
index 0000000000..cfa4feeca6
--- /dev/null
+++ b/editor/icons/source/icon_GUI_vslider_bg.svg
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="16"
+ height="16"
+ viewBox="0 0 16 15.999999"
+ id="svg2"
+ version="1.1"
+ inkscape:version="0.92+devel unknown"
+ sodipodi:docname="icon_GUI_vslider_bg.svg"
+ inkscape:export-filename="/home/djrm/Projects/godot/scene/resources/default_theme/checked.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90">
+ <defs
+ id="defs4" />
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="32"
+ inkscape:cx="8.3954629"
+ inkscape:cy="7.6047847"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="true"
+ units="px"
+ inkscape:object-paths="false"
+ inkscape:snap-intersection-paths="false"
+ inkscape:snap-bbox="true"
+ inkscape:bbox-paths="true"
+ inkscape:bbox-nodes="true"
+ inkscape:snap-bbox-edge-midpoints="true"
+ inkscape:window-width="1920"
+ inkscape:window-height="1016"
+ inkscape:window-x="0"
+ inkscape:window-y="27"
+ inkscape:window-maximized="1"
+ inkscape:snap-smooth-nodes="true"
+ inkscape:object-nodes="true"
+ inkscape:document-rotation="0">
+ <inkscape:grid
+ type="xygrid"
+ id="grid4136"
+ empspacing="4" />
+ </sodipodi:namedview>
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(0,-1036.3623)">
+ <rect
+ style="fill:#000000;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:0.3254902;fill-opacity:0.39215687"
+ id="rect4267"
+ width="4"
+ height="14"
+ x="6"
+ y="1037.3623"
+ ry="0" />
+ </g>
+</svg>
diff --git a/editor/icons/source/icon_vsplit_bg.svg b/editor/icons/source/icon_GUI_vsplit_bg.svg
index e11940cf53..e11940cf53 100644
--- a/editor/icons/source/icon_vsplit_bg.svg
+++ b/editor/icons/source/icon_GUI_vsplit_bg.svg
diff --git a/editor/icons/source/icon_vsplitter.svg b/editor/icons/source/icon_GUI_vsplitter.svg
index 80f7c2ce12..80f7c2ce12 100644
--- a/editor/icons/source/icon_vsplitter.svg
+++ b/editor/icons/source/icon_GUI_vsplitter.svg
diff --git a/editor/icons/source/icon_animation_tree_player.svg b/editor/icons/source/icon_animation_tree_player.svg
index 1c5c41e5f2..fa5803489e 100644
--- a/editor/icons/source/icon_animation_tree_player.svg
+++ b/editor/icons/source/icon_animation_tree_player.svg
@@ -28,9 +28,9 @@
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
- inkscape:zoom="22.627416"
- inkscape:cx="-0.31764706"
- inkscape:cy="5.3536612"
+ inkscape:zoom="31.999999"
+ inkscape:cx="5.6353556"
+ inkscape:cy="8.4280346"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
@@ -70,7 +70,7 @@
transform="translate(0,-1036.3622)">
<path
style="opacity:1;fill:#fbe87a;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- d="M 1 1 L 1 15 L 2.1660156 15 L 2.1660156 13 L 4 13 L 4 15 L 12 15 L 12 13 L 14 13 L 14 15 L 15 15 L 15 1 L 14 1 L 14 3 L 12 3 L 12 1 L 4 1 L 4 3 L 2.1660156 3 L 2.1660156 1 L 1 1 z M 5.984375 2.9863281 A 1.0001 1.0001 0 0 1 7 4 L 7 6.3828125 L 9.5527344 5.1054688 A 1.0001 1.0001 0 0 1 10.003906 4.9941406 A 1.0001 1.0001 0 0 1 10.447266 6.8945312 L 7 8.6171875 L 7 12 A 1.0001 1.0001 0 1 1 5 12 L 5 7.9921875 L 5 4 A 1.0001 1.0001 0 0 1 5.984375 2.9863281 z M 2.1660156 5 L 4 5 L 4 7 L 2.1660156 7 L 2.1660156 5 z M 12 5 L 14 5 L 14 7 L 12 7 L 12 5 z M 2.1660156 9 L 4 9 L 4 11 L 2.1660156 11 L 2.1660156 9 z M 12 9 L 14 9 L 14 11 L 12 11 L 12 9 z "
+ d="M 1 1 L 1 15 L 2.1660156 15 L 2.1660156 13 L 4 13 L 4 15 L 12 15 L 12 13 L 14 13 L 14 15 L 15 15 L 15 1 L 14 1 L 14 3 L 12 3 L 12 1 L 4 1 L 4 3 L 2.1660156 3 L 2.1660156 1 L 1 1 z M 5 4 L 7 4 L 7 5 L 7 6 L 8 6 L 11 6 L 11 8 L 9 8 L 9 9 L 9 10 L 10 10 L 11 10 L 11 12 L 10 12 L 8 12 A 1.0001 1.0001 0 0 1 7 11 L 7 10 L 7 8 L 6 8 A 1.0001 1.0001 0 0 1 5 7 L 5 6 L 5 5 L 5 4 z M 2.1660156 5 L 4 5 L 4 7 L 2.1660156 7 L 2.1660156 5 z M 12 5 L 14 5 L 14 7 L 12 7 L 12 5 z M 2.1660156 9 L 4 9 L 4 11 L 2.1660156 11 L 2.1660156 9 z M 12 9 L 14 9 L 14 11 L 12 11 L 12 9 z "
transform="translate(0,1036.3622)"
id="rect4136" />
</g>
diff --git a/editor/icons/source/icon_audio_player.svg b/editor/icons/source/icon_audio_stream_player.svg
index 2d9c5f4e6c..2d9c5f4e6c 100644
--- a/editor/icons/source/icon_audio_player.svg
+++ b/editor/icons/source/icon_audio_stream_player.svg
diff --git a/editor/icons/source/icon_audio_stream_player_2_d.svg b/editor/icons/source/icon_audio_stream_player_2_d.svg
new file mode 100644
index 0000000000..39149786c4
--- /dev/null
+++ b/editor/icons/source/icon_audio_stream_player_2_d.svg
@@ -0,0 +1,114 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="16"
+ height="16"
+ viewBox="0 0 16 16"
+ id="svg2"
+ version="1.1"
+ inkscape:version="0.92+devel unknown"
+ inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_add_track.png"
+ inkscape:export-xdpi="45"
+ inkscape:export-ydpi="45"
+ sodipodi:docname="icon_audio_player_2d.svg">
+ <defs
+ id="defs4">
+ <linearGradient
+ id="linearGradient959-5"
+ inkscape:collect="always">
+ <stop
+ style="stop-color:#ff8484;stop-opacity:1"
+ offset="0"
+ id="stop957-3" />
+ <stop
+ id="stop955-5"
+ offset="0.5"
+ style="stop-color:#e1dc7a;stop-opacity:1" />
+ <stop
+ style="stop-color:#84ffb1;stop-opacity:1"
+ offset="1"
+ id="stop953-6" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient959-5"
+ id="linearGradient4552"
+ x1="8"
+ y1="1"
+ x2="8"
+ y2="15"
+ gradientUnits="userSpaceOnUse" />
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="11.313709"
+ inkscape:cx="12.877013"
+ inkscape:cy="3.5679216"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="true"
+ units="px"
+ inkscape:snap-bbox="true"
+ inkscape:bbox-paths="true"
+ inkscape:bbox-nodes="true"
+ inkscape:snap-bbox-edge-midpoints="true"
+ inkscape:snap-bbox-midpoints="false"
+ inkscape:snap-object-midpoints="true"
+ inkscape:snap-center="true"
+ inkscape:window-width="1920"
+ inkscape:window-height="1016"
+ inkscape:window-x="0"
+ inkscape:window-y="27"
+ inkscape:window-maximized="1"
+ inkscape:snap-midpoints="true"
+ inkscape:snap-smooth-nodes="true"
+ inkscape:object-nodes="true"
+ inkscape:document-rotation="0">
+ <inkscape:grid
+ type="xygrid"
+ id="grid3336" />
+ </sodipodi:namedview>
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(0,-1036.3622)">
+ <path
+ style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#a5b7f1;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1.97227669;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
+ d="m 10.023235,1044.3625 c -0.5613918,-0.013 -1.0235345,0.4264 -1.0234377,0.9724 v 5.0542 c 6.911e-4,0.7482 0.8336124,1.2154 1.4999997,0.8414 l 4,-2.5262 c 0.666937,-0.3743 0.666937,-1.3104 0,-1.6847 l -4,-2.5261 c -0.145049,-0.082 -0.308928,-0.1269 -0.476562,-0.131 z"
+ id="path4507"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cccccccc" />
+ <path
+ style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:url(#linearGradient4552);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
+ d="M 11.970703 1.0019531 A 1.0001 1.0001 0 0 0 11.724609 1.0390625 L 4.7246094 3.0390625 A 1.0001 1.0001 0 0 0 4 4 L 4 9.5507812 A 2.5 2.4999914 0 0 0 3.5 9.5 A 2.5 2.4999914 0 0 0 1 12 A 2.5 2.4999914 0 0 0 3.5 14.5 A 2.5 2.4999914 0 0 0 5.9960938 12.087891 A 1.0001 1.0001 0 0 0 6 12 L 6 4.7558594 L 11 3.328125 L 11 6.5 L 13 5.5 L 13 2 A 1.0001 1.0001 0 0 0 11.970703 1.0019531 z "
+ transform="translate(0,1036.3622)"
+ id="path4514" />
+ </g>
+</svg>
diff --git a/editor/icons/source/icon_audio_stream_sample.svg b/editor/icons/source/icon_audio_stream_sample.svg
new file mode 100644
index 0000000000..0724daa333
--- /dev/null
+++ b/editor/icons/source/icon_audio_stream_sample.svg
@@ -0,0 +1,108 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="16"
+ height="16"
+ viewBox="0 0 16 16"
+ id="svg2"
+ version="1.1"
+ inkscape:version="0.92+devel unknown"
+ inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_add_track.png"
+ inkscape:export-xdpi="45"
+ inkscape:export-ydpi="45"
+ sodipodi:docname="icon_audio_stream_sample.svg">
+ <defs
+ id="defs4">
+ <linearGradient
+ id="linearGradient959-5"
+ inkscape:collect="always">
+ <stop
+ style="stop-color:#ff8484;stop-opacity:1"
+ offset="0"
+ id="stop957-3" />
+ <stop
+ id="stop955-5"
+ offset="0.5"
+ style="stop-color:#e1dc7a;stop-opacity:1" />
+ <stop
+ style="stop-color:#84ffb1;stop-opacity:1"
+ offset="1"
+ id="stop953-6" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient959-5"
+ id="linearGradient4552"
+ x1="8"
+ y1="1"
+ x2="8"
+ y2="15"
+ gradientUnits="userSpaceOnUse" />
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="11.313708"
+ inkscape:cx="0.86295209"
+ inkscape:cy="-2.4874516"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="true"
+ units="px"
+ inkscape:snap-bbox="true"
+ inkscape:bbox-paths="true"
+ inkscape:bbox-nodes="true"
+ inkscape:snap-bbox-edge-midpoints="true"
+ inkscape:snap-bbox-midpoints="false"
+ inkscape:snap-object-midpoints="true"
+ inkscape:snap-center="true"
+ inkscape:window-width="1920"
+ inkscape:window-height="1016"
+ inkscape:window-x="0"
+ inkscape:window-y="27"
+ inkscape:window-maximized="1"
+ inkscape:snap-midpoints="true"
+ inkscape:snap-smooth-nodes="true"
+ inkscape:object-nodes="true"
+ inkscape:document-rotation="0">
+ <inkscape:grid
+ type="xygrid"
+ id="grid3336" />
+ </sodipodi:namedview>
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(0,-1036.3622)">
+ <path
+ style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:url(#linearGradient4552);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
+ d="M 11.970703 1.0019531 C 11.887443 1.0040231 11.804775 1.0164945 11.724609 1.0390625 L 4.7246094 3.0390625 C 4.2958022 3.1619372 4.0002098 3.5539354 4 4 L 4 9.5507812 C 3.8354622 9.5171023 3.6679493 9.5000892 3.5 9.5 C 2.1192848 9.5 0.99999525 10.61929 1 12 C 0.99999525 13.38071 2.1192848 14.5 3.5 14.5 C 4.8455926 14.4987 5.9487926 13.432648 5.9960938 12.087891 C 5.9986844 12.058665 5.9999878 12.02934 6 12 L 6 4.7558594 L 11 3.328125 L 11 6.5 L 13 5.5 L 13 2 C 12.999084 1.4368608 12.533603 0.98551202 11.970703 1.0019531 z M 10.5 8 C 10.223 8 10 8.223 10 8.5 L 10 13.5 C 10 13.777 10.223 14 10.5 14 C 10.777 14 11 13.777 11 13.5 L 11 8.5 C 11 8.223 10.777 8 10.5 8 z M 12.5 9 C 12.223 9 12 9.223 12 9.5 L 12 12.5 C 12 12.777 12.223 13 12.5 13 C 12.777 13 13 12.777 13 12.5 L 13 9.5 C 13 9.223 12.777 9 12.5 9 z M 8.5 10 C 8.223 10 8 10.223 8 10.5 L 8 11.5 C 8 11.777 8.223 12 8.5 12 C 8.777 12 9 11.777 9 11.5 L 9 10.5 C 9 10.223 8.777 10 8.5 10 z M 14.5 10 C 14.223 10 14 10.223 14 10.5 L 14 11.5 C 14 11.777 14.223 12 14.5 12 C 14.777 12 15 11.777 15 11.5 L 15 10.5 C 15 10.223 14.777 10 14.5 10 z "
+ transform="translate(0,1036.3622)"
+ id="path4514" />
+ </g>
+</svg>
diff --git a/editor/icons/source/icon_bit_map.svg b/editor/icons/source/icon_bit_map.svg
index fbaf573af6..5c1ad9139a 100644
--- a/editor/icons/source/icon_bit_map.svg
+++ b/editor/icons/source/icon_bit_map.svg
@@ -14,7 +14,7 @@
viewBox="0 0 16 16"
id="svg2"
version="1.1"
- inkscape:version="0.91 r13725"
+ inkscape:version="0.92.1 r"
inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_collision_shape.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90"
@@ -29,8 +29,8 @@
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="32"
- inkscape:cx="-0.178935"
- inkscape:cy="8.367044"
+ inkscape:cx="3.664815"
+ inkscape:cy="7.867044"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
@@ -42,8 +42,8 @@
inkscape:snap-bbox-midpoints="true"
inkscape:snap-object-midpoints="true"
inkscape:snap-center="true"
- inkscape:window-width="1920"
- inkscape:window-height="1016"
+ inkscape:window-width="1600"
+ inkscape:window-height="836"
inkscape:window-x="0"
inkscape:window-y="27"
inkscape:window-maximized="1"
@@ -74,7 +74,7 @@
id="layer1"
transform="translate(0,-1036.3622)">
<path
- style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ style="opacity:1;fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 1 1 L 1 3 L 3 3 L 3 1 L 1 1 z M 3 3 L 3 5 L 5 5 L 5 3 L 3 3 z M 5 3 L 7 3 L 7 1 L 5 1 L 5 3 z M 7 3 L 7 5 L 9 5 L 9 3 L 7 3 z M 9 3 L 11 3 L 11 1 L 9 1 L 9 3 z M 11 3 L 11 5 L 13 5 L 13 3 L 11 3 z M 13 3 L 15 3 L 15 1 L 13 1 L 13 3 z M 13 5 L 13 7 L 15 7 L 15 5 L 13 5 z M 13 7 L 11 7 L 11 9 L 13 9 L 13 7 z M 13 9 L 13 11 L 15 11 L 15 9 L 13 9 z M 13 11 L 11 11 L 11 13 L 13 13 L 13 11 z M 13 13 L 13 15 L 15 15 L 15 13 L 13 13 z M 11 13 L 9 13 L 9 15 L 11 15 L 11 13 z M 9 13 L 9 11 L 7 11 L 7 13 L 9 13 z M 7 13 L 5 13 L 5 15 L 7 15 L 7 13 z M 5 13 L 5 11 L 3 11 L 3 13 L 5 13 z M 3 13 L 1 13 L 1 15 L 3 15 L 3 13 z M 3 11 L 3 9 L 1 9 L 1 11 L 3 11 z M 3 9 L 5 9 L 5 7 L 3 7 L 3 9 z M 3 7 L 3 5 L 1 5 L 1 7 L 3 7 z M 5 7 L 7 7 L 7 5 L 5 5 L 5 7 z M 7 7 L 7 9 L 9 9 L 9 7 L 7 7 z M 9 7 L 11 7 L 11 5 L 9 5 L 9 7 z M 9 9 L 9 11 L 11 11 L 11 9 L 9 9 z M 7 9 L 5 9 L 5 11 L 7 11 L 7 9 z "
id="rect4170"
transform="translate(0,1036.3622)" />
diff --git a/editor/icons/source/icon_button.svg b/editor/icons/source/icon_button.svg
index 54644ecb9b..f095b169ca 100644
--- a/editor/icons/source/icon_button.svg
+++ b/editor/icons/source/icon_button.svg
@@ -14,7 +14,7 @@
viewBox="0 0 16 16"
id="svg2"
version="1.1"
- inkscape:version="0.91 r13725"
+ inkscape:version="0.92.1 r"
inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_button.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90"
@@ -28,9 +28,9 @@
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
- inkscape:zoom="45.254834"
- inkscape:cx="6.249456"
- inkscape:cy="9.3054468"
+ inkscape:zoom="32"
+ inkscape:cx="9.0492367"
+ inkscape:cy="8.5595615"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
@@ -42,8 +42,8 @@
inkscape:snap-bbox-midpoints="true"
inkscape:snap-object-midpoints="true"
inkscape:snap-center="true"
- inkscape:window-width="1920"
- inkscape:window-height="1016"
+ inkscape:window-width="1600"
+ inkscape:window-height="836"
inkscape:window-x="0"
inkscape:window-y="27"
inkscape:window-maximized="1">
@@ -60,7 +60,7 @@
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:title></dc:title>
+ <dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
@@ -69,26 +69,40 @@
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-1036.3622)">
- <path
- style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- d="M 1 3 L 1 11 L 15 11 L 15 3 L 1 3 z M 4 5 L 7 5 L 7 9 L 4 9 L 4 5 z M 9 5 L 10 5 L 10 6 L 11 6 L 11 5 L 12 5 L 12 6 L 11 6 L 11 7 L 12 7 L 12 9 L 11 9 L 11 7 L 10 7 L 10 9 L 9 9 L 9 5 z M 5 6 L 5 8 L 6 8 L 6 6 L 5 6 z "
- transform="translate(0,1036.3622)"
- id="rect4139" />
<rect
- transform="scale(1,-1)"
- style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- id="rect4160"
- width="14"
- height="2.0000522"
- x="1"
- y="-1049.3622" />
+ style="fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ id="rect829"
+ width="8"
+ height="4.0000172"
+ x="4"
+ y="1045.3622"
+ ry="1.5" />
+ <rect
+ style="fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:1.92153788;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ id="rect825"
+ width="12"
+ height="2"
+ x="2"
+ y="1048.3622"
+ ry="0" />
<rect
- y="-1049.3622"
- x="1"
- height="2.0000522"
- width="14"
- id="rect4142"
- style="opacity:1;fill:#000000;fill-opacity:0.07843138;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- transform="scale(1,-1)" />
+ style="fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ id="rect827"
+ width="8"
+ height="2"
+ x="4"
+ y="1047.3622"
+ ry="0" />
+ <path
+ style="fill:none;stroke:#a5efac;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="m 5,1040.3622 3,2 3,-2"
+ id="path831"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:none;stroke:#a5efac;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="m 8,1037.3622 v 5"
+ id="path833"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cc" />
</g>
</svg>
diff --git a/editor/icons/source/icon_button_group.svg b/editor/icons/source/icon_button_group.svg
index 9d5df99deb..d1433634df 100644
--- a/editor/icons/source/icon_button_group.svg
+++ b/editor/icons/source/icon_button_group.svg
@@ -14,7 +14,7 @@
viewBox="0 0 16 16"
id="svg2"
version="1.1"
- inkscape:version="0.91 r13725"
+ inkscape:version="0.92.1 r"
inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_button_group.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90"
@@ -29,8 +29,8 @@
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="32"
- inkscape:cx="3.5392558"
- inkscape:cy="8.9453899"
+ inkscape:cx="10.59901"
+ inkscape:cy="8.8192036"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
@@ -42,8 +42,8 @@
inkscape:snap-bbox-midpoints="true"
inkscape:snap-object-midpoints="true"
inkscape:snap-center="true"
- inkscape:window-width="1920"
- inkscape:window-height="1016"
+ inkscape:window-width="1600"
+ inkscape:window-height="836"
inkscape:window-x="0"
inkscape:window-y="27"
inkscape:window-maximized="1">
@@ -69,110 +69,10 @@
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-1036.3622)">
- <rect
- style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- id="rect4172"
- width="1"
- height="10"
- x="0"
- y="1039.3622" />
- <rect
- y="1039.3622"
- x="15"
- height="10"
- width="1"
- id="rect4174"
- style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
<path
- style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- id="path4176"
- sodipodi:type="arc"
- sodipodi:cx="1"
- sodipodi:cy="1049.3622"
- sodipodi:rx="1"
- sodipodi:ry="1"
- sodipodi:start="0"
- sodipodi:end="4.712389"
- d="m 2,1049.3622 a 1,1 0 0 1 -0.6173166,0.9239 1,1 0 0 1 -1.08979019,-0.2168 1,1 0 0 1 -0.21677274,-1.0898 A 1,1 0 0 1 1,1048.3622 l 0,1 z" />
- <rect
- y="-15"
- x="1049.3622"
- height="14"
- width="1"
- id="rect4178"
- style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- transform="matrix(0,1,-1,0,0,0)" />
- <path
- d="m -14,1049.3622 a 1,1 0 0 1 -0.617317,0.9239 1,1 0 0 1 -1.08979,-0.2168 1,1 0 0 1 -0.216773,-1.0898 1,1 0 0 1 0.92388,-0.6173 l 0,1 z"
- sodipodi:end="4.712389"
- sodipodi:start="0"
- sodipodi:ry="1"
- sodipodi:rx="1"
- sodipodi:cy="1049.3622"
- sodipodi:cx="-15"
- sodipodi:type="arc"
- id="path4180"
- style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- transform="scale(-1,1)" />
- <path
- d="m 2,-1039.3622 a 1,1 0 0 1 -0.6173166,0.9239 1,1 0 0 1 -1.08979019,-0.2168 1,1 0 0 1 -0.21677274,-1.0898 A 1,1 0 0 1 1,-1040.3622 l 0,1 z"
- sodipodi:end="4.712389"
- sodipodi:start="0"
- sodipodi:ry="1"
- sodipodi:rx="1"
- sodipodi:cy="-1039.3622"
- sodipodi:cx="1"
- sodipodi:type="arc"
- id="path4182"
- style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- transform="scale(1,-1)" />
- <path
- transform="scale(-1,-1)"
- style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- id="path4184"
- sodipodi:type="arc"
- sodipodi:cx="-15"
- sodipodi:cy="-1039.3622"
- sodipodi:rx="1"
- sodipodi:ry="1"
- sodipodi:start="0"
- sodipodi:end="4.712389"
- d="m -14,-1039.3622 a 1,1 0 0 1 -0.617317,0.9239 1,1 0 0 1 -1.08979,-0.2168 1,1 0 0 1 -0.216773,-1.0898 1,1 0 0 1 0.92388,-0.6173 l 0,1 z" />
- <rect
- transform="matrix(0,1,-1,0,0,0)"
- style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- id="rect4186"
- width="1"
- height="14"
- x="1038.3622"
- y="-15" />
- <rect
- style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- id="rect4188"
- width="4"
- height="6.0000172"
- x="3"
- y="1041.3622" />
- <rect
- y="1041.3622"
- x="9"
- height="6.0000172"
- width="4"
- id="rect4190"
- style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
- <rect
- y="1045.3622"
- x="3"
- height="1.9999998"
- width="4"
- id="rect4192"
- style="opacity:1;fill:#98dc9f;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
- <rect
- style="opacity:1;fill:#98dc9f;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- id="rect4194"
- width="4"
- height="1.9999998"
- x="9"
- y="1045.3622" />
+ style="fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="M 4 1 C 3.446 1 3 1.446 3 2 L 3 14 C 3 14.554 3.446 15 4 15 L 12 15 C 12.554 15 13 14.554 13 14 L 13 2 C 13 1.446 12.554 1 12 1 L 4 1 z M 5 2 L 7 2 C 7.554 2 8 2.446 8 3 C 8 3.554 7.554 4 7 4 L 5 4 C 4.446 4 4 3.554 4 3 C 4 2.446 4.446 2 5 2 z M 11 2 C 11.552285 2 12 2.4477153 12 3 C 12 3.5522847 11.552285 4 11 4 C 10.447715 4 10 3.5522847 10 3 C 10 2.4477153 10.447715 2 11 2 z M 6 6 A 2 2 0 0 1 8 8 A 2 2 0 0 1 6 10 A 2 2 0 0 1 4 8 A 2 2 0 0 1 6 6 z M 11 6 C 11.552285 6 12 6.4477153 12 7 C 12 7.5522847 11.552285 8 11 8 C 10.447715 8 10 7.5522847 10 7 C 10 6.4477153 10.447715 6 11 6 z M 11 10 C 11.552285 10 12 10.447715 12 11 C 12 11.552285 11.552285 12 11 12 C 10.447715 12 10 11.552285 10 11 C 10 10.447715 10.447715 10 11 10 z M 4 12 L 5 12 L 5 14 L 4 14 L 4 12 z M 6 12 L 7 12 L 7 14 L 6 14 L 6 12 z M 8 12 L 9 12 L 9 14 L 8 14 L 8 12 z "
+ transform="translate(0,1036.3622)"
+ id="rect4500" />
</g>
</svg>
diff --git a/editor/icons/source/icon_capsule_mesh.svg b/editor/icons/source/icon_capsule_mesh.svg
new file mode 100644
index 0000000000..38975b3d25
--- /dev/null
+++ b/editor/icons/source/icon_capsule_mesh.svg
@@ -0,0 +1,93 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="16"
+ height="16"
+ viewBox="0 0 16 16"
+ id="svg2"
+ version="1.1"
+ inkscape:version="0.92+devel unknown"
+ inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_node_2d.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90"
+ sodipodi:docname="icon_capsule_mesh.svg">
+ <defs
+ id="defs4" />
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="32"
+ inkscape:cx="10.821682"
+ inkscape:cy="9.8571693"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="true"
+ units="px"
+ inkscape:snap-bbox="true"
+ inkscape:bbox-paths="true"
+ inkscape:bbox-nodes="true"
+ inkscape:snap-bbox-edge-midpoints="true"
+ inkscape:snap-bbox-midpoints="true"
+ inkscape:snap-object-midpoints="true"
+ inkscape:snap-center="true"
+ inkscape:window-width="1920"
+ inkscape:window-height="1016"
+ inkscape:window-x="0"
+ inkscape:window-y="27"
+ inkscape:window-maximized="1"
+ inkscape:document-rotation="0">
+ <inkscape:grid
+ type="xygrid"
+ id="grid3336"
+ empspacing="4" />
+ </sodipodi:namedview>
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(0,-1036.3622)">
+ <rect
+ style="fill:none;stroke:#ffd684;stroke-width:1.93995905;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ id="rect4266"
+ width="8"
+ height="11.999983"
+ x="4"
+ y="1038.3622"
+ ry="4" />
+ <path
+ style="fill:none;stroke:#ffd684;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="m 4,1044.3622 c 2.7376816,1.306 5.3946358,1.3618 8,0"
+ id="path4268"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cc" />
+ <path
+ style="fill:none;stroke:#ffd684;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none"
+ d="m 8,1038.3622 v 12"
+ id="path4270"
+ inkscape:connector-curvature="0" />
+ </g>
+</svg>
diff --git a/editor/icons/source/icon_color_rect.svg b/editor/icons/source/icon_color_rect.svg
index 76bf6596a9..f352c5552a 100644
--- a/editor/icons/source/icon_color_rect.svg
+++ b/editor/icons/source/icon_color_rect.svg
@@ -14,7 +14,7 @@
viewBox="0 0 16 16"
id="svg2"
version="1.1"
- inkscape:version="0.91 r13725"
+ inkscape:version="0.92.1 r"
inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_center_container.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90"
@@ -66,8 +66,8 @@
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="32"
- inkscape:cx="9.9050022"
- inkscape:cy="11.383887"
+ inkscape:cx="9.1237522"
+ inkscape:cy="7.790137"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
@@ -79,8 +79,8 @@
inkscape:snap-bbox-midpoints="true"
inkscape:snap-object-midpoints="true"
inkscape:snap-center="true"
- inkscape:window-width="1920"
- inkscape:window-height="1016"
+ inkscape:window-width="1600"
+ inkscape:window-height="836"
inkscape:window-x="0"
inkscape:window-y="27"
inkscape:window-maximized="1"
@@ -99,7 +99,7 @@
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:title></dc:title>
+ <dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
@@ -109,46 +109,46 @@
id="layer1"
transform="translate(0,-1036.3622)">
<rect
- style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2.82842708;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect4154"
- width="1"
+ width="2"
height="14"
x="1"
y="1037.3622" />
<rect
- y="1050.3622"
+ y="1049.3622"
x="1"
- height="0.9999826"
+ height="1.9999652"
width="14"
id="rect4156"
- style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+ style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2.82842708;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
<rect
- style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2.82846403;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect4158"
width="14"
- height="0.9999826"
+ height="2.0000174"
x="1"
y="1037.3622" />
<rect
y="1037.3622"
- x="14"
+ x="13"
height="14"
- width="1"
+ width="2"
id="rect4160"
- style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+ style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2.82842708;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
<path
- style="fill:#70bfff;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;fill-opacity:1"
- d="m 13,1049.3622 -6,0 6,-6 z"
+ style="fill:#70bfff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.80000001px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 12,1048.3622 H 7.2 l 4.8,-4.8 z"
id="path4168"
inkscape:connector-curvature="0" />
<path
inkscape:connector-curvature="0"
id="path4170"
- d="m 3,1039.3622 6,0 -6,6 z"
- style="fill:#ff7070;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
+ d="m 4,1040.3622 h 4.8 l -4.8,4.8 z"
+ style="fill:#ff7070;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.80000001px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
<path
- style="fill:#7aff70;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
- d="m 3,1049.3622 0,-4 6,-6 4,0 0,4 -6,6 z"
+ style="fill:#7aff70;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.80000001px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="m 4,1048.3622 v -3.2 l 4.8,-4.8 H 12 v 3.2 l -4.8,4.8 z"
id="path4172"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccccccc" />
diff --git a/editor/icons/source/icon_confirmation_dialog.svg b/editor/icons/source/icon_confirmation_dialog.svg
index 49dbc21e92..52cdf7618e 100644
--- a/editor/icons/source/icon_confirmation_dialog.svg
+++ b/editor/icons/source/icon_confirmation_dialog.svg
@@ -14,7 +14,7 @@
viewBox="0 0 16 16"
id="svg2"
version="1.1"
- inkscape:version="0.91 r13725"
+ inkscape:version="0.92.1 r"
inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_confirmation_dialog.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90"
@@ -28,9 +28,9 @@
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
- inkscape:zoom="16"
- inkscape:cx="7.6980886"
- inkscape:cy="13.203824"
+ inkscape:zoom="32"
+ inkscape:cx="8.6970479"
+ inkscape:cy="7.4854117"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
@@ -42,8 +42,8 @@
inkscape:snap-bbox-midpoints="true"
inkscape:snap-object-midpoints="true"
inkscape:snap-center="true"
- inkscape:window-width="1920"
- inkscape:window-height="1016"
+ inkscape:window-width="1600"
+ inkscape:window-height="836"
inkscape:window-x="0"
inkscape:window-y="27"
inkscape:window-maximized="1">
@@ -59,7 +59,7 @@
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:title></dc:title>
+ <dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
@@ -70,7 +70,7 @@
transform="translate(0,-1036.3622)">
<path
style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- d="M 3 1 C 1.89543 1 1 1.8954 1 3 L 1 4 L 15 4 L 15 3 C 15 1.8954 14.104569 1 13 1 L 3 1 z M 12 2 L 13 2 L 13 3 L 12 3 L 12 2 z M 1 5 L 1 13 C 1 14.1046 1.89543 15 3 15 L 13 15 C 14.104569 15 15 14.1046 15 13 L 15 5 L 1 5 z M 2.5859375 8.8789062 L 4 10.292969 L 5.4140625 8.8789062 L 6.1210938 9.5859375 L 4.7070312 11 L 6.1210938 12.414062 L 5.4140625 13.121094 L 4 11.707031 L 2.5859375 13.121094 L 1.8789062 12.414062 L 3.2929688 11 L 1.8789062 9.5859375 L 2.5859375 8.8789062 z M 12.949219 8.8789062 L 13.65625 9.5859375 L 10.828125 12.414062 L 10.121094 13.121094 L 9.4140625 12.414062 L 8 11 L 8.7070312 10.292969 L 10.121094 11.707031 L 12.949219 8.8789062 z "
+ d="M 3 1 C 1.89543 1 1 1.8954 1 3 L 1 4 L 15 4 L 15 3 C 15 1.8954 14.104569 1 13 1 L 3 1 z M 12 2 L 13 2 L 13 3 L 12 3 L 12 2 z M 1 5 L 1 13 C 1 14.1046 1.89543 15 3 15 L 13 15 C 14.104569 15 15 14.1046 15 13 L 15 5 L 1 5 z M 7.9863281 6.0019531 C 8.3332141 5.9996687 8.6849305 6.0577156 9.0253906 6.1816406 C 10.387231 6.6772406 11.206736 8.0942844 10.955078 9.5214844 C 10.764025 10.604982 9.9933535 11.46759 9 11.822266 L 9 12 L 8 12 L 7 12 L 7 11.158203 A 1.0001 1.0001 0 0 1 8 10 C 8.4919343 10 8.898952 9.6582281 8.984375 9.1738281 C 9.0697985 8.6893281 8.8040639 8.2287469 8.3417969 8.0605469 C 7.8795298 7.8922469 7.3807328 8.074 7.1347656 8.5 A 1.0001606 1.0001606 0 0 1 5.4023438 7.5 C 5.9458088 6.558525 6.9456702 6.0088063 7.9863281 6.0019531 z M 7 13 L 9 13 L 9 14 L 7 14 L 7 13 z "
transform="translate(0,1036.3622)"
id="rect4140" />
</g>
diff --git a/editor/icons/source/icon_cube_mesh.svg b/editor/icons/source/icon_cube_mesh.svg
new file mode 100644
index 0000000000..1506b3e434
--- /dev/null
+++ b/editor/icons/source/icon_cube_mesh.svg
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="16"
+ height="16"
+ viewBox="0 0 14.999999 14.999999"
+ id="svg2"
+ version="1.1"
+ inkscape:version="0.92+devel unknown"
+ inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_collision_shape.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90"
+ sodipodi:docname="icon_cube_mesh.svg">
+ <defs
+ id="defs4" />
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="45.254834"
+ inkscape:cx="10.638124"
+ inkscape:cy="7.9587327"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="true"
+ units="px"
+ inkscape:snap-bbox="true"
+ inkscape:bbox-paths="true"
+ inkscape:bbox-nodes="true"
+ inkscape:snap-bbox-edge-midpoints="true"
+ inkscape:snap-bbox-midpoints="true"
+ inkscape:snap-object-midpoints="true"
+ inkscape:snap-center="true"
+ inkscape:window-width="1920"
+ inkscape:window-height="1016"
+ inkscape:window-x="0"
+ inkscape:window-y="27"
+ inkscape:window-maximized="1"
+ inkscape:object-paths="false"
+ inkscape:snap-intersection-paths="false"
+ inkscape:object-nodes="false"
+ inkscape:snap-smooth-nodes="false"
+ inkscape:snap-midpoints="true"
+ inkscape:document-rotation="0">
+ <inkscape:grid
+ type="xygrid"
+ id="grid3336"
+ originx="0"
+ originy="0"
+ spacingx="0.93749994"
+ spacingy="0.93749994" />
+ </sodipodi:namedview>
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(0,-1037.3622)">
+ <path
+ style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-variant-east-asian:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#ffd684;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1.7735548;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
+ d="m 7.4999994,1038.1958 -6.56249953,3.2804 v 6.772 l 0.49015243,0.246 6.0723471,3.0344 6.5624996,-3.2804 v -6.772 z m 0,1.9831 3.6925976,1.8463 -3.6925977,1.8463 -3.6925967,-1.8463 z m -4.7889446,3.2804 3.9021671,1.9502 v 3.6944 l -3.9021671,-1.952 z m 9.5778892,0 v 3.6926 l -3.9021673,1.952 v -3.6944 z"
+ id="path4298"
+ inkscape:connector-curvature="0" />
+ </g>
+</svg>
diff --git a/editor/icons/source/icon_sample_player_2d.svg b/editor/icons/source/icon_curve.svg
index 33a7eba019..a58e08d950 100644
--- a/editor/icons/source/icon_sample_player_2d.svg
+++ b/editor/icons/source/icon_curve.svg
@@ -14,11 +14,11 @@
viewBox="0 0 16 16"
id="svg2"
version="1.1"
- inkscape:version="0.91 r13725"
+ inkscape:version="0.92+devel unknown"
inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_node_2d.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90"
- sodipodi:docname="icon_sample_player_2d.svg">
+ sodipodi:docname="icon_curve.svg">
<defs
id="defs4" />
<sodipodi:namedview
@@ -28,9 +28,9 @@
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
- inkscape:zoom="31.999999"
- inkscape:cx="8.6950163"
- inkscape:cy="7.1009775"
+ inkscape:zoom="32"
+ inkscape:cx="7.6124179"
+ inkscape:cy="9.8854217"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
@@ -46,7 +46,8 @@
inkscape:window-height="1016"
inkscape:window-x="0"
inkscape:window-y="27"
- inkscape:window-maximized="1">
+ inkscape:window-maximized="1"
+ inkscape:document-rotation="0">
<inkscape:grid
type="xygrid"
id="grid3336"
@@ -70,9 +71,15 @@
id="layer1"
transform="translate(0,-1036.3622)">
<path
- style="opacity:1;fill:#a5b7f7;fill-opacity:0.98823529;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.99607843"
- d="M 8 1 L 4 6 L 1 6 L 1 10 L 4 10 L 8 15 L 8 1 z M 13 3 L 13 13 L 14 13 L 14 3 L 13 3 z M 10 6 L 10 11 L 11 11 L 11 6 L 10 6 z "
- transform="translate(0,1036.3622)"
- id="rect4154" />
+ style="fill:none;stroke:#e0e0e0;stroke-width:2;stroke-linecap:square;stroke-linejoin:miter;stroke-opacity:0.32549021;stroke-miterlimit:4;stroke-dasharray:none"
+ d="m 2,1038.3622 v 12 h 12"
+ id="path4289"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:none;stroke:#e0e0e0;stroke-width:2;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="m 2,1050.3622 c 8,0 12,-4 12,-12"
+ id="path4285"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cc" />
</g>
</svg>
diff --git a/editor/icons/source/icon_cylinder_mesh.svg b/editor/icons/source/icon_cylinder_mesh.svg
new file mode 100644
index 0000000000..26003365bc
--- /dev/null
+++ b/editor/icons/source/icon_cylinder_mesh.svg
@@ -0,0 +1,89 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="16"
+ height="16"
+ viewBox="0 0 14.999999 14.999999"
+ id="svg2"
+ version="1.1"
+ inkscape:version="0.92+devel unknown"
+ inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_collision_shape.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90"
+ sodipodi:docname="icon_cylinder_mesh.svg">
+ <defs
+ id="defs4" />
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="32"
+ inkscape:cx="8.8446434"
+ inkscape:cy="10.246909"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="true"
+ units="px"
+ inkscape:snap-bbox="true"
+ inkscape:bbox-paths="true"
+ inkscape:bbox-nodes="true"
+ inkscape:snap-bbox-edge-midpoints="true"
+ inkscape:snap-bbox-midpoints="true"
+ inkscape:snap-object-midpoints="true"
+ inkscape:snap-center="true"
+ inkscape:window-width="1920"
+ inkscape:window-height="1016"
+ inkscape:window-x="0"
+ inkscape:window-y="27"
+ inkscape:window-maximized="1"
+ inkscape:object-paths="true"
+ inkscape:snap-intersection-paths="true"
+ inkscape:object-nodes="true"
+ inkscape:snap-smooth-nodes="true"
+ inkscape:snap-midpoints="true"
+ inkscape:document-rotation="0">
+ <inkscape:grid
+ type="xygrid"
+ id="grid3336"
+ originx="0"
+ originy="0"
+ spacingx="0.93749994"
+ spacingy="0.93749994" />
+ </sodipodi:namedview>
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(0,-1037.3622)">
+ <path
+ style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-variant-east-asian:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#ffd684;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
+ d="M 8,1 C 6.2530724,1 4.6719569,1.2264786 3.4414062,1.6367188 2.8261309,1.8418388 2.2942826,2.0885933 1.8515625,2.4375 1.4088424,2.7864067 1,3.3185066 1,4 v 8 c 0,0.681493 0.4088424,1.215546 0.8515625,1.564453 0.4427201,0.348907 0.9745684,0.595768 1.5898437,0.800781 C 4.6719569,14.775474 6.2530724,15 8,15 c 1.7469276,0 3.328042,-0.224526 4.558594,-0.634766 0.615274,-0.205013 1.147122,-0.451874 1.589844,-0.800781 C 14.591158,13.215546 15,12.681493 15,12 V 4 C 15,3.3185066 14.591158,2.7864067 14.148438,2.4375 13.705716,2.0885933 13.173868,1.8418388 12.558594,1.6367188 11.328042,1.2264786 9.7469276,1 8,1 Z m 0,2 c 1.5667809,0 2.986711,0.2214496 3.927734,0.5351562 0.463676,0.1545602 0.801384,0.3374102 0.96875,0.4667969 -0.167523,0.12928 -0.505463,0.3104971 -0.96875,0.4648438 C 10.986711,4.7805036 9.5667809,5 8,5 6.4332191,5 5.0132879,4.7805036 4.0722656,4.4667969 3.6089791,4.3124502 3.271039,4.1312331 3.1035156,4.0019531 3.2708819,3.8725664 3.6085896,3.6897164 4.0722656,3.5351562 5.0132879,3.2214496 6.4332191,3 8,3 Z M 3,6.1875 C 3.1467977,6.2465706 3.2834962,6.3126178 3.4414062,6.3652344 4.6719569,6.7754744 6.2530724,7 8,7 9.7469276,7 11.328042,6.7754744 12.558594,6.3652344 12.716504,6.3126178 12.853202,6.2465706 13,6.1875 V 12 c -0.167523,0.12928 -0.608979,0.31245 -1.072266,0.466797 C 10.986711,12.780504 9.5667809,13 8,13 6.4332191,13 5.0132879,12.780504 4.0722656,12.466797 3.6089791,12.31245 3.1675234,12.12928 3,12 Z"
+ transform="matrix(0.93749994,0,0,0.93749994,0,1037.3622)"
+ id="path4385"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="sssssscsccsscssscccscccsccsccccsccc" />
+ </g>
+</svg>
diff --git a/editor/icons/source/icon_debug.svg b/editor/icons/source/icon_debug.svg
index 1b3e748668..25ca0d6a11 100644
--- a/editor/icons/source/icon_debug.svg
+++ b/editor/icons/source/icon_debug.svg
@@ -29,8 +29,8 @@
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="32"
- inkscape:cx="8.8380296"
- inkscape:cy="8.0475262"
+ inkscape:cx="6.6351189"
+ inkscape:cy="7.5931892"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
@@ -62,7 +62,7 @@
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:title></dc:title>
+ <dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
@@ -72,22 +72,72 @@
id="layer1"
transform="translate(0,-1036.3622)">
<path
- style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#e0e0e0;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
- d="M 3 3.9863281 A 1.0001 1.0001 0 0 0 2.015625 5.1816406 C 2.2178415 6.2802406 2.7057331 7.1756813 3.390625 7.8007812 C 3.6768866 8.0620519 3.9944862 8.2637767 4.3242188 8.4375 A 4 4 0 0 0 4.1289062 9 L 2 9 A 1.0001 1.0001 0 1 0 2 11 L 4.1328125 11 A 4 4 0 0 0 4.3652344 11.658203 C 4.2801416 11.696657 4.2143084 11.719391 4.1210938 11.765625 C 3.5374123 12.055025 2.8673634 12.538772 2.2089844 13.388672 A 1.0003084 1.0003084 0 1 0 3.7910156 14.613281 C 4.2919543 13.966681 4.6296764 13.745141 5.0097656 13.556641 C 5.205099 13.459768 5.4352695 13.372568 5.6953125 13.263672 A 4 4 0 0 0 8 14 A 4 4 0 0 0 10.332031 13.244141 C 11.496007 13.78538 11.98739 14.238118 12.128906 14.490234 A 1.0001 1.0001 0 1 0 13.871094 13.511719 C 13.471096 12.799229 12.778174 12.20655 11.644531 11.634766 A 4 4 0 0 0 11.869141 11 L 14 11 A 1.0001 1.0001 0 1 0 14 9 L 11.867188 9 A 4 4 0 0 0 11.685547 8.4550781 C 12.182886 8.1889169 12.596375 7.860606 12.908203 7.4804688 C 13.491193 6.7697687 13.74859 5.9803156 13.957031 5.2910156 A 1.0001 1.0001 0 0 0 12.982422 3.9882812 A 1.0001 1.0001 0 0 0 12.042969 4.7109375 C 11.850379 5.3477375 11.656068 5.8559906 11.363281 6.2128906 C 11.080302 6.5578365 10.697905 6.8305531 9.8867188 7 L 6.1503906 7 C 5.5504757 6.8482606 5.0764053 6.630863 4.7382812 6.3222656 C 4.3835001 5.9984656 4.1227361 5.5721125 3.984375 4.8203125 A 1.0001 1.0001 0 0 0 3 3.9863281 z M 8.046875 4 A 2 2 0 0 0 7 4.2675781 A 2 2 0 0 0 6 6 L 10 6 A 2 2 0 0 0 9 4.2675781 A 2 2 0 0 0 8.046875 4 z "
- id="path4507"
- transform="translate(0,1036.3622)" />
- <path
- style="fill:none;fill-opacity:1;stroke:#e0e0e0;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.78431373"
+ style="fill:none;fill-opacity:1;stroke:#f0f0f0;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path4548"
sodipodi:type="arc"
sodipodi:cx="8"
- sodipodi:cy="-1041.3622"
+ sodipodi:cy="-1042.3622"
sodipodi:rx="4"
sodipodi:ry="4"
sodipodi:start="0.78539816"
sodipodi:end="2.3561945"
- d="M 10.828427,-1038.5338 A 4,4 0 0 1 8,-1037.3622 a 4,4 0 0 1 -2.8284272,-1.1716"
+ d="M 10.828427,-1039.5338 A 4,4 0 0 1 8,-1038.3622 a 4,4 0 0 1 -2.8284272,-1.1716"
transform="scale(1,-1)"
sodipodi:open="true" />
+ <ellipse
+ style="fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:0;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.97303921"
+ id="path4491"
+ cx="8"
+ cy="1047.3572"
+ rx="3.644531"
+ ry="1.6348" />
+ <circle
+ style="fill:#f0f0f0;fill-opacity:1;stroke:#4c4c4c;stroke-width:0;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.78431373"
+ id="path4493"
+ cx="8"
+ cy="1047.3622"
+ r="3.9999993" />
+ <path
+ style="fill:none;stroke:#f0f0f0;stroke-width:2;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="M 5,1047.3622 H 2"
+ id="path4495"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cc" />
+ <path
+ style="fill:none;stroke:#f0f0f0;stroke-width:2;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="m 10,1047.3622 h 4"
+ id="path4497"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cc" />
+ <path
+ style="fill:none;stroke:#f0f0f0;stroke-width:2;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="m 6,1045.3572 c -2,0 -3,-2 -3,-3"
+ id="path4499"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cc" />
+ <path
+ style="fill:none;stroke:#f0f0f0;stroke-width:2;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="m 10,1045.3572 c 2,0 3,-2 3,-3"
+ id="path4501"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cc" />
+ <path
+ style="fill:none;stroke:#f0f0f0;stroke-width:2;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="m 6,1049.3572 c -1,0 -2,1 -3,2"
+ id="path4503"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cc" />
+ <path
+ style="fill:none;stroke:#f0f0f0;stroke-width:2;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="m 10,1049.3572 c 1,0 2,1 3,2"
+ id="path4505"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cc" />
+ <circle
+ style="fill:#f0f0f0;fill-opacity:1;stroke:none;stroke-width:4;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.78431373"
+ id="path4508"
+ cx="8"
+ cy="1043.3622"
+ r="2" />
</g>
</svg>
diff --git a/editor/icons/source/icon_environment.svg b/editor/icons/source/icon_environment.svg
index 45add2c7f7..96d0f7e29c 100644
--- a/editor/icons/source/icon_environment.svg
+++ b/editor/icons/source/icon_environment.svg
@@ -14,7 +14,7 @@
viewBox="0 0 16 16"
id="svg2"
version="1.1"
- inkscape:version="0.91 r13725"
+ inkscape:version="0.92.1 r"
inkscape:export-filename="/home/djrm/icon_node_2d.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90"
@@ -28,9 +28,9 @@
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
- inkscape:zoom="16"
- inkscape:cx="10.741006"
- inkscape:cy="10.690232"
+ inkscape:zoom="22.627417"
+ inkscape:cx="4.0727417"
+ inkscape:cy="8.9873869"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
@@ -42,8 +42,8 @@
inkscape:snap-bbox-midpoints="true"
inkscape:snap-object-midpoints="true"
inkscape:snap-center="true"
- inkscape:window-width="1920"
- inkscape:window-height="1016"
+ inkscape:window-width="1600"
+ inkscape:window-height="836"
inkscape:window-x="0"
inkscape:window-y="27"
inkscape:window-maximized="1"
@@ -64,7 +64,7 @@
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:title></dc:title>
+ <dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
@@ -73,10 +73,29 @@
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-1036.3622)">
+ <circle
+ style="fill:none;fill-opacity:1;stroke:#e0e0e0;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ id="path814"
+ cx="8"
+ cy="1044.3622"
+ r="6" />
<path
- style="opacity:1;fill:#e1e1e1;fill-opacity:0.99215686;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.99607843"
- d="M 8 1 A 7 7 0 0 0 1 8 A 7 7 0 0 0 8 15 A 7 7 0 0 0 15 8 A 7 7 0 0 0 8 1 z M 7.0273438 2.0820312 C 6.3462908 2.6213949 5.3431503 3.5860946 4.6757812 5 L 2.8105469 5 A 6 6 0 0 1 7.0273438 2.0820312 z M 8.9785156 2.0859375 A 6 6 0 0 1 13.1875 5 L 11.324219 5 C 10.658501 3.5895934 9.6595492 2.6261235 8.9785156 2.0859375 z M 8 2.6054688 C 8.3858776 2.856627 9.3974911 3.6104334 10.185547 5 L 5.8144531 5 C 6.6025089 3.6104334 7.6141224 2.856627 8 2.6054688 z M 2.3515625 6 L 4.2949219 6 C 4.1145279 6.6059544 4 7.2695302 4 8 C 4 8.7306855 4.1144398 9.3938115 4.2949219 10 L 2.3496094 10 A 6 6 0 0 1 2 8 A 6 6 0 0 1 2.3515625 6 z M 5.3398438 6 L 10.660156 6 C 10.868048 6.5934731 11 7.2583063 11 8 C 11 8.7421382 10.866303 9.4061377 10.658203 10 L 5.3417969 10 C 5.1336971 9.4061377 5 8.7421382 5 8 C 5 7.2583063 5.1319522 6.5934731 5.3398438 6 z M 11.705078 6 L 13.650391 6 A 6 6 0 0 1 14 8 A 6 6 0 0 1 13.648438 10 L 11.705078 10 C 11.88556 9.3938115 12 8.7306855 12 8 C 12 7.2695302 11.885472 6.6059544 11.705078 6 z M 2.8125 11 L 4.6777344 11 C 5.343895 12.410381 6.3427806 13.374042 7.0234375 13.914062 A 6 6 0 0 1 2.8125 11 z M 5.8144531 11 L 10.185547 11 C 9.3971916 12.390235 8.3853773 13.145488 8 13.396484 C 7.6146227 13.145488 6.6028084 12.390235 5.8144531 11 z M 11.322266 11 L 13.189453 11 A 6 6 0 0 1 8.9707031 13.917969 C 9.651376 13.378771 10.654456 12.413873 11.322266 11 z "
- transform="translate(0,1036.3622)"
- id="path4158" />
+ style="fill:none;stroke:#e0e0e0;stroke-width:1.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none"
+ d="m 2,1044.3622 c 4.5932382,1.582 8.398513,1.0627 12,0"
+ id="path816"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cc" />
+ <path
+ sodipodi:nodetypes="cc"
+ inkscape:connector-curvature="0"
+ id="path820"
+ d="m 8,1038.3622 c -3,4 -3,8 0,12"
+ style="fill:none;stroke:#e0e0e0;stroke-width:1.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+ <path
+ style="fill:none;stroke:#e0e0e0;stroke-width:1.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="m 8,1038.3622 c 3,4 3,8 0,12"
+ id="path822"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cc" />
</g>
</svg>
diff --git a/editor/icons/source/icon_file_big.svg b/editor/icons/source/icon_file_big.svg
index 38ad9b707a..084247937b 100644
--- a/editor/icons/source/icon_file_big.svg
+++ b/editor/icons/source/icon_file_big.svg
@@ -14,7 +14,7 @@
viewBox="0 0 64 64"
id="svg2"
version="1.1"
- inkscape:version="0.91 r13725"
+ inkscape:version="0.92.1 r"
inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_new.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90"
@@ -28,9 +28,9 @@
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
- inkscape:zoom="11.313708"
- inkscape:cx="32.899003"
- inkscape:cy="32.88081"
+ inkscape:zoom="8"
+ inkscape:cx="29.157928"
+ inkscape:cy="37.490712"
inkscape:document-units="px"
inkscape:current-layer="layer1-8"
showgrid="true"
@@ -42,14 +42,16 @@
inkscape:snap-bbox-midpoints="false"
inkscape:snap-object-midpoints="true"
inkscape:snap-center="true"
- inkscape:window-width="1920"
- inkscape:window-height="1016"
+ inkscape:window-width="1600"
+ inkscape:window-height="836"
inkscape:window-x="0"
inkscape:window-y="27"
inkscape:window-maximized="1"
- inkscape:object-paths="false"
- inkscape:snap-intersection-paths="false"
- inkscape:object-nodes="false">
+ inkscape:object-paths="true"
+ inkscape:snap-intersection-paths="true"
+ inkscape:object-nodes="true"
+ inkscape:snap-midpoints="true"
+ inkscape:snap-smooth-nodes="true">
<inkscape:grid
type="xygrid"
id="grid3336" />
@@ -76,12 +78,10 @@
inkscape:label="Layer 1"
transform="translate(0,-1.6949463e-5)">
<path
- style="opacity:1;fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- d="m 10,5 0,54 44,0 0,-36 -18,0 0,-18 z m 31,0 0,13 13,0 z"
+ style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#ffffff;fill-opacity:0.58823532;fill-rule:nonzero;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
+ d="M 14 5 C 11.801312 5 10 6.80131 10 9 L 10 55 C 10 57.1987 11.801312 59 14 59 L 50 59 C 52.198688 59 54 57.1987 54 55 L 54 22 L 53.992188 22 C 53.994308 21.751685 53.912915 21.499015 53.707031 21.292969 L 37.707031 5.2929688 C 37.519176 5.1060418 37.264574 5.003582 37 5.0039062 L 37 5 L 14 5 z M 14 7 L 36 7 L 36 9 L 36 19 C 36 21.1987 37.801349 23 40 23 L 50 23 L 52 23 L 52 55 C 52 56.1253 51.125282 57 50 57 L 14 57 C 12.874718 57 12 56.1253 12 55 L 12 9 C 12 7.87472 12.874718 7 14 7 z "
transform="translate(0,988.36222)"
- id="rect4158"
- inkscape:connector-curvature="0"
- sodipodi:nodetypes="ccccccccccc" />
+ id="rect815" />
</g>
</g>
</svg>
diff --git a/editor/icons/source/icon_file_dialog.svg b/editor/icons/source/icon_file_dialog.svg
index 9dee04c220..a3af269bee 100644
--- a/editor/icons/source/icon_file_dialog.svg
+++ b/editor/icons/source/icon_file_dialog.svg
@@ -14,7 +14,7 @@
viewBox="0 0 16 16"
id="svg2"
version="1.1"
- inkscape:version="0.91 r13725"
+ inkscape:version="0.92.1 r"
inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_confirmation_dialog.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90"
@@ -28,9 +28,9 @@
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
- inkscape:zoom="16"
- inkscape:cx="2.7469423"
- inkscape:cy="8.766806"
+ inkscape:zoom="22.627417"
+ inkscape:cx="6.7929949"
+ inkscape:cy="8.3839819"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
@@ -42,8 +42,8 @@
inkscape:snap-bbox-midpoints="true"
inkscape:snap-object-midpoints="true"
inkscape:snap-center="true"
- inkscape:window-width="1920"
- inkscape:window-height="1016"
+ inkscape:window-width="1600"
+ inkscape:window-height="836"
inkscape:window-x="0"
inkscape:window-y="27"
inkscape:window-maximized="1">
@@ -59,7 +59,7 @@
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:title></dc:title>
+ <dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
@@ -70,8 +70,10 @@
transform="translate(0,-1036.3622)">
<path
style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- d="M 3 1 C 1.89543 1 1 1.8954 1 3 L 1 4 L 15 4 L 15 3 C 15 1.8954 14.104569 1 13 1 L 3 1 z M 12 2 L 13 2 L 13 3 L 12 3 L 12 2 z M 1 5 L 1 13 C 1 14.1046 1.89543 15 3 15 L 13 15 C 14.104569 15 15 14.1046 15 13 L 15 5 L 1 5 z M 5 7 L 8 7 L 8 8 L 11 8 L 11 13 L 5 13 L 5 7 z "
+ d="M 3,1 C 1.89543,1 1,1.8954 1,3 V 4 H 15 V 3 C 15,1.8954 14.104569,1 13,1 Z m 9,1 h 1 V 3 H 12 Z M 1,5 v 8 c 0,1.1046 0.89543,2 2,2 h 10 c 1.104569,0 2,-0.8954 2,-2 V 5 Z m 3,2 h 3 c 1,0 1,2 2,2 h 3 v 4 H 4 Z"
transform="translate(0,1036.3622)"
- id="rect4140" />
+ id="rect4140"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="ssccsssccccccssssccccccccc" />
</g>
</svg>
diff --git a/editor/icons/source/icon_g_d_native_library.svg b/editor/icons/source/icon_g_d_native_library.svg
new file mode 100644
index 0000000000..9eae07c69b
--- /dev/null
+++ b/editor/icons/source/icon_g_d_native_library.svg
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="16"
+ height="16"
+ viewBox="0 0 16 16"
+ id="svg2"
+ version="1.1"
+ inkscape:version="0.92.1 r"
+ inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_g_d_script.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90"
+ sodipodi:docname="icon_g_d_native_library.svg">
+ <defs
+ id="defs4" />
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="32"
+ inkscape:cx="9.2871559"
+ inkscape:cy="8.7634992"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="true"
+ units="px"
+ inkscape:snap-bbox="true"
+ inkscape:bbox-paths="true"
+ inkscape:bbox-nodes="true"
+ inkscape:snap-bbox-edge-midpoints="true"
+ inkscape:snap-bbox-midpoints="true"
+ inkscape:snap-object-midpoints="true"
+ inkscape:snap-center="true"
+ inkscape:window-width="1600"
+ inkscape:window-height="836"
+ inkscape:window-x="0"
+ inkscape:window-y="27"
+ inkscape:window-maximized="1">
+ <inkscape:grid
+ type="xygrid"
+ id="grid3336" />
+ </sodipodi:namedview>
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(0,-1036.3622)">
+ <path
+ style="opacity:1;fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:3;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ d="M 7 1 L 6.4355469 3.2578125 A 5.0000172 5.0000172 0 0 0 5.7460938 3.5371094 L 3.7578125 2.34375 L 2.34375 3.7578125 L 3.5390625 5.7519531 A 5.0000172 5.0000172 0 0 0 3.2539062 6.4375 L 1 7 L 1 9 L 3.2578125 9.5644531 A 5.0000172 5.0000172 0 0 0 3.5371094 10.251953 L 2.34375 12.242188 L 3.7578125 13.65625 L 5.7519531 12.460938 A 5.0000172 5.0000172 0 0 0 6.4375 12.746094 L 7 15 L 7 9.7304688 A 2.0000174 2.0000174 0 0 1 6 8 A 2.0000174 2.0000174 0 0 1 7 6.2714844 L 7 6 L 8 6 L 12.576172 6 A 5.0000172 5.0000172 0 0 0 12.462891 5.7480469 L 13.65625 3.7578125 L 12.242188 2.34375 L 10.248047 3.5390625 A 5.0000172 5.0000172 0 0 0 9.5625 3.2539062 L 9 1 L 7 1 z "
+ transform="translate(0,1036.3622)"
+ id="path4176" />
+ <path
+ inkscape:connector-curvature="0"
+ style="opacity:1;fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ d="m 9,1044.3622 v 1 5 1 h 5 c 0.552285,0 1,-0.4477 1,-1 v -5 c 0,-0.5523 -0.447715,-1 -1,-1 v 4 l -1,-1 -1,1 v -4 z"
+ id="path4162"
+ sodipodi:nodetypes="ccccssscccccc" />
+ </g>
+</svg>
diff --git a/editor/icons/source/icon_godot.svg b/editor/icons/source/icon_godot.svg
new file mode 100644
index 0000000000..8f90c4c91a
--- /dev/null
+++ b/editor/icons/source/icon_godot.svg
@@ -0,0 +1,176 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="16"
+ height="16"
+ viewBox="0 0 16 16"
+ id="svg2"
+ version="1.1"
+ inkscape:version="0.92+devel unknown"
+ inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_collision_shape_2d.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90"
+ sodipodi:docname="icon_godot.svg">
+ <defs
+ id="defs4" />
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="22.627417"
+ inkscape:cx="18.673414"
+ inkscape:cy="10.896798"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="true"
+ units="px"
+ inkscape:snap-bbox="true"
+ inkscape:bbox-paths="true"
+ inkscape:bbox-nodes="true"
+ inkscape:snap-bbox-edge-midpoints="true"
+ inkscape:snap-bbox-midpoints="true"
+ inkscape:snap-object-midpoints="true"
+ inkscape:snap-center="true"
+ inkscape:window-width="1920"
+ inkscape:window-height="1016"
+ inkscape:window-x="0"
+ inkscape:window-y="27"
+ inkscape:window-maximized="1"
+ inkscape:document-rotation="0">
+ <inkscape:grid
+ type="xygrid"
+ id="grid3336" />
+ </sodipodi:namedview>
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(0,-1036.3622)">
+ <g
+ transform="matrix(0.01724138,0,0,0.01724138,-0.82758616,1033.7378)"
+ id="layer1-6"
+ inkscape:label="Layer 1">
+ <g
+ style="stroke-width:0.32031175"
+ transform="matrix(4.162611,0,0,-4.162611,919.24059,771.67186)"
+ id="g78">
+ <path
+ inkscape:connector-curvature="0"
+ id="path80"
+ style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.32031175"
+ d="m 0,0 c 0,0 -0.325,1.994 -0.515,1.976 l -36.182,-3.491 c -2.879,-0.278 -5.115,-2.574 -5.317,-5.459 l -0.994,-14.247 -27.992,-1.997 -1.904,12.912 c -0.424,2.872 -2.932,5.037 -5.835,5.037 h -38.188 c -2.902,0 -5.41,-2.165 -5.834,-5.037 l -1.905,-12.912 -27.992,1.997 -0.994,14.247 c -0.202,2.886 -2.438,5.182 -5.317,5.46 l -36.2,3.49 c -0.187,0.018 -0.324,-1.978 -0.511,-1.978 l -0.049,-7.83 30.658,-4.944 1.004,-14.374 c 0.203,-2.91 2.551,-5.263 5.463,-5.472 l 38.551,-2.75 c 0.146,-0.01 0.29,-0.016 0.434,-0.016 2.897,0 5.401,2.166 5.825,5.038 l 1.959,13.286 h 28.005 l 1.959,-13.286 c 0.423,-2.871 2.93,-5.037 5.831,-5.037 0.142,0 0.284,0.005 0.423,0.015 l 38.556,2.75 c 2.911,0.209 5.26,2.562 5.463,5.472 l 1.003,14.374 30.645,4.966 z" />
+ </g>
+ <g
+ style="stroke-width:0.32031175"
+ transform="matrix(4.162611,0,0,-4.162611,104.69892,525.90697)"
+ id="g82-3">
+ <path
+ inkscape:connector-curvature="0"
+ id="path84-6"
+ style="fill:#478cbf;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.32031175"
+ d="m 0,0 v -47.514 -6.035 -5.492 c 0.108,-0.001 0.216,-0.005 0.323,-0.015 l 36.196,-3.49 c 1.896,-0.183 3.382,-1.709 3.514,-3.609 l 1.116,-15.978 31.574,-2.253 2.175,14.747 c 0.282,1.912 1.922,3.329 3.856,3.329 h 38.188 c 1.933,0 3.573,-1.417 3.855,-3.329 l 2.175,-14.747 31.575,2.253 1.115,15.978 c 0.133,1.9 1.618,3.425 3.514,3.609 l 36.182,3.49 c 0.107,0.01 0.214,0.014 0.322,0.015 v 4.711 l 0.015,0.005 V 0 h 0.134 c 4.795,6.12 9.232,12.569 13.487,19.449 -5.651,9.62 -12.575,18.217 -19.976,26.182 -6.864,-3.455 -13.531,-7.369 -19.828,-11.534 -3.151,3.132 -6.7,5.694 -10.186,8.372 -3.425,2.751 -7.285,4.768 -10.946,7.118 1.09,8.117 1.629,16.108 1.846,24.448 -9.446,4.754 -19.519,7.906 -29.708,10.17 -4.068,-6.837 -7.788,-14.241 -11.028,-21.479 -3.842,0.642 -7.702,0.88 -11.567,0.926 v 0.006 c -0.027,0 -0.052,-0.006 -0.075,-0.006 -0.024,0 -0.049,0.006 -0.073,0.006 V 63.652 C 93.903,63.606 90.046,63.368 86.203,62.726 82.965,69.964 79.247,77.368 75.173,84.205 64.989,81.941 54.915,78.789 45.47,74.035 45.686,65.695 46.225,57.704 47.318,49.587 43.65,47.237 39.795,45.22 36.369,42.469 32.888,39.791 29.333,37.229 26.181,34.097 19.884,38.262 13.219,42.176 6.353,45.631 -1.048,37.666 -7.968,29.069 -13.621,19.449 -9.368,12.569 -4.928,6.12 -0.134,0 Z" />
+ </g>
+ <g
+ style="stroke-width:0.32031175"
+ transform="matrix(4.162611,0,0,-4.162611,784.07144,817.24284)"
+ id="g86-7">
+ <path
+ inkscape:connector-curvature="0"
+ id="path88-5"
+ style="fill:#478cbf;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.32031175"
+ d="m 0,0 -1.121,-16.063 c -0.135,-1.936 -1.675,-3.477 -3.611,-3.616 l -38.555,-2.751 c -0.094,-0.007 -0.188,-0.01 -0.281,-0.01 -1.916,0 -3.569,1.406 -3.852,3.33 l -2.211,14.994 H -81.09 l -2.211,-14.994 c -0.297,-2.018 -2.101,-3.469 -4.133,-3.32 l -38.555,2.751 c -1.936,0.139 -3.476,1.68 -3.611,3.616 L -130.721,0 -163.268,3.138 c 0.015,-3.498 0.06,-7.33 0.06,-8.093 0,-34.374 43.605,-50.896 97.781,-51.086 h 0.066 0.067 c 54.176,0.19 97.766,16.712 97.766,51.086 0,0.777 0.047,4.593 0.063,8.093 z" />
+ </g>
+ <g
+ style="stroke-width:0.32031175"
+ transform="matrix(4.162611,0,0,-4.162611,389.21484,625.67104)"
+ id="g90-3">
+ <path
+ inkscape:connector-curvature="0"
+ id="path92-5"
+ style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.32031175"
+ d="m 0,0 c 0,-12.052 -9.765,-21.815 -21.813,-21.815 -12.042,0 -21.81,9.763 -21.81,21.815 0,12.044 9.768,21.802 21.81,21.802 C -9.765,21.802 0,12.044 0,0" />
+ </g>
+ <g
+ style="stroke-width:0.32031175"
+ transform="matrix(4.162611,0,0,-4.162611,367.36686,631.05679)"
+ id="g94-6">
+ <path
+ inkscape:connector-curvature="0"
+ id="path96-2"
+ style="fill:#414042;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.32031175"
+ d="m 0,0 c 0,-7.994 -6.479,-14.473 -14.479,-14.473 -7.996,0 -14.479,6.479 -14.479,14.473 0,7.994 6.483,14.479 14.479,14.479 C -6.479,14.479 0,7.994 0,0" />
+ </g>
+ <g
+ style="stroke-width:0.32031175"
+ transform="matrix(4.162611,0,0,-4.162611,511.99336,724.73954)"
+ id="g98-9">
+ <path
+ inkscape:connector-curvature="0"
+ id="path100-1"
+ style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.32031175"
+ d="m 0,0 c -3.878,0 -7.021,2.858 -7.021,6.381 v 20.081 c 0,3.52 3.143,6.381 7.021,6.381 3.878,0 7.028,-2.861 7.028,-6.381 V 6.381 C 7.028,2.858 3.878,0 0,0" />
+ </g>
+ <g
+ style="stroke-width:0.32031175"
+ transform="matrix(4.162611,0,0,-4.162611,634.78706,625.67104)"
+ id="g102-2">
+ <path
+ inkscape:connector-curvature="0"
+ id="path104-7"
+ style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.32031175"
+ d="m 0,0 c 0,-12.052 9.765,-21.815 21.815,-21.815 12.041,0 21.808,9.763 21.808,21.815 0,12.044 -9.767,21.802 -21.808,21.802 C 9.765,21.802 0,12.044 0,0" />
+ </g>
+ <g
+ style="stroke-width:0.32031175"
+ transform="matrix(4.162611,0,0,-4.162611,656.64056,631.05679)"
+ id="g106-0">
+ <path
+ inkscape:connector-curvature="0"
+ id="path108-9"
+ style="fill:#414042;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.32031175"
+ d="m 0,0 c 0,-7.994 6.477,-14.473 14.471,-14.473 8.002,0 14.479,6.479 14.479,14.473 0,7.994 -6.477,14.479 -14.479,14.479 C 6.477,14.479 0,7.994 0,0" />
+ </g>
+ </g>
+ <path
+ style="opacity:1;fill:#000000;fill-opacity:1;stroke:none;stroke-width:6;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.44162436"
+ d="m 4,1041.3622 a 3,3 0 0 0 -3,3 3,3 0 0 0 3,3 3,3 0 0 0 3,-3 3,3 0 0 0 -3,-3 z m 0,1 a 2.0000174,2.0000174 0 0 1 2,2 2.0000174,2.0000174 0 0 1 -2,2 2.0000174,2.0000174 0 0 1 -2,-2 2.0000174,2.0000174 0 0 1 2,-2 z"
+ id="path4151"
+ inkscape:connector-curvature="0" />
+ <path
+ inkscape:connector-curvature="0"
+ id="path4156"
+ d="m 12,1041.3622 a 3,3 0 0 0 -3,3 3,3 0 0 0 3,3 3,3 0 0 0 3,-3 3,3 0 0 0 -3,-3 z m 0,1 a 2.0000174,2.0000174 0 0 1 2,2 2.0000174,2.0000174 0 0 1 -2,2 2.0000174,2.0000174 0 0 1 -2,-2 2.0000174,2.0000174 0 0 1 2,-2 z"
+ style="opacity:1;fill:#000000;fill-opacity:1;stroke:none;stroke-width:6;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.44162436" />
+ <rect
+ style="opacity:1;fill:#000000;fill-opacity:1;stroke:none;stroke-width:6;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.44162436"
+ id="rect4160"
+ width="4"
+ height="1"
+ x="6"
+ y="1043.3622"
+ ry="0" />
+ </g>
+</svg>
diff --git a/editor/icons/source/icon_godot_docs.svg b/editor/icons/source/icon_godot_docs.svg
deleted file mode 100644
index 77aa92b31f..0000000000
--- a/editor/icons/source/icon_godot_docs.svg
+++ /dev/null
@@ -1,173 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!-- Created with Inkscape (http://www.inkscape.org/) -->
-
-<svg
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:cc="http://creativecommons.org/ns#"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:svg="http://www.w3.org/2000/svg"
- xmlns="http://www.w3.org/2000/svg"
- xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
- xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
- width="16"
- height="16"
- viewBox="0 0 15 15"
- id="svg2"
- version="1.1"
- inkscape:version="0.92.1 r15371"
- inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_collision_shape_2d.png"
- inkscape:export-xdpi="90"
- inkscape:export-ydpi="90"
- sodipodi:docname="icon_godot_docs.svg">
- <defs
- id="defs4" />
- <sodipodi:namedview
- id="base"
- pagecolor="#ffffff"
- bordercolor="#666666"
- borderopacity="1.0"
- inkscape:pageopacity="0.0"
- inkscape:pageshadow="2"
- inkscape:zoom="22.627417"
- inkscape:cx="-14.305844"
- inkscape:cy="5.1981046"
- inkscape:document-units="px"
- inkscape:current-layer="layer1"
- showgrid="false"
- units="px"
- inkscape:snap-bbox="true"
- inkscape:bbox-paths="true"
- inkscape:bbox-nodes="true"
- inkscape:snap-bbox-edge-midpoints="true"
- inkscape:snap-bbox-midpoints="true"
- inkscape:snap-object-midpoints="true"
- inkscape:snap-center="true"
- inkscape:window-width="1920"
- inkscape:window-height="1011"
- inkscape:window-x="0"
- inkscape:window-y="0"
- inkscape:window-maximized="1">
- <inkscape:grid
- type="xygrid"
- id="grid3336"
- originx="0"
- originy="0"
- spacingx="1"
- spacingy="1" />
- </sodipodi:namedview>
- <metadata
- id="metadata7">
- <rdf:RDF>
- <cc:Work
- rdf:about="">
- <dc:format>image/svg+xml</dc:format>
- <dc:type
- rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:title></dc:title>
- </cc:Work>
- </rdf:RDF>
- </metadata>
- <g
- inkscape:label="Layer 1"
- inkscape:groupmode="layer"
- id="layer1"
- transform="translate(0,-1037.3622)">
- <g
- id="g78"
- transform="matrix(0.06307836,0,0,-0.06307664,13.671143,1047.293)"
- style="stroke-width:19.8168869">
- <path
- d="m 0,0 c 0,0 -0.325,1.994 -0.515,1.976 l -36.182,-3.491 c -2.879,-0.278 -5.115,-2.574 -5.317,-5.459 l -0.994,-14.247 -27.992,-1.997 -1.904,12.912 c -0.424,2.872 -2.932,5.037 -5.835,5.037 h -38.188 c -2.902,0 -5.41,-2.165 -5.834,-5.037 l -1.905,-12.912 -27.992,1.997 -0.994,14.247 c -0.202,2.886 -2.438,5.182 -5.317,5.46 l -36.2,3.49 c -0.187,0.018 -0.324,-1.978 -0.511,-1.978 l -0.049,-7.83 30.658,-4.944 1.004,-14.374 c 0.203,-2.91 2.551,-5.263 5.463,-5.472 l 38.551,-2.75 c 0.146,-0.01 0.29,-0.016 0.434,-0.016 2.897,0 5.401,2.166 5.825,5.038 l 1.959,13.286 h 28.005 l 1.959,-13.286 c 0.423,-2.871 2.93,-5.037 5.831,-5.037 0.142,0 0.284,0.005 0.423,0.015 l 38.556,2.75 c 2.911,0.209 5.26,2.562 5.463,5.472 l 1.003,14.374 30.645,4.966 z"
- style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:19.8168869"
- id="path80"
- inkscape:connector-curvature="0" />
- </g>
- <g
- id="g82-3"
- transform="matrix(0.06307836,0,0,-0.06307664,1.3279404,1043.5689)"
- style="stroke-width:19.8168869">
- <path
- d="m 0,0 v -47.514 -6.035 -5.492 c 0.108,-0.001 0.216,-0.005 0.323,-0.015 l 36.196,-3.49 c 1.896,-0.183 3.382,-1.709 3.514,-3.609 l 1.116,-15.978 31.574,-2.253 2.175,14.747 c 0.282,1.912 1.922,3.329 3.856,3.329 h 38.188 c 1.933,0 3.573,-1.417 3.855,-3.329 l 2.175,-14.747 31.575,2.253 1.115,15.978 c 0.133,1.9 1.618,3.425 3.514,3.609 l 36.182,3.49 c 0.107,0.01 0.214,0.014 0.322,0.015 v 4.711 l 0.015,0.005 V 0 h 0.134 c 4.795,6.12 9.232,12.569 13.487,19.449 -5.651,9.62 -12.575,18.217 -19.976,26.182 -6.864,-3.455 -13.531,-7.369 -19.828,-11.534 -3.151,3.132 -6.7,5.694 -10.186,8.372 -3.425,2.751 -7.285,4.768 -10.946,7.118 1.09,8.117 1.629,16.108 1.846,24.448 -9.446,4.754 -19.519,7.906 -29.708,10.17 -4.068,-6.837 -7.788,-14.241 -11.028,-21.479 -3.842,0.642 -7.702,0.88 -11.567,0.926 v 0.006 c -0.027,0 -0.052,-0.006 -0.075,-0.006 -0.024,0 -0.049,0.006 -0.073,0.006 V 63.652 C 93.903,63.606 90.046,63.368 86.203,62.726 82.965,69.964 79.247,77.368 75.173,84.205 64.989,81.941 54.915,78.789 45.47,74.035 45.686,65.695 46.225,57.704 47.318,49.587 43.65,47.237 39.795,45.22 36.369,42.469 32.888,39.791 29.333,37.229 26.181,34.097 19.884,38.262 13.219,42.176 6.353,45.631 -1.048,37.666 -7.968,29.069 -13.621,19.449 -9.368,12.569 -4.928,6.12 -0.134,0 Z"
- style="fill:#478cbf;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:19.8168869"
- id="path84-6"
- inkscape:connector-curvature="0" />
- </g>
- <g
- id="g86-7"
- transform="matrix(0.06307836,0,0,-0.06307664,11.62285,1047.9836)"
- style="stroke-width:19.8168869">
- <path
- d="m 0,0 -1.121,-16.063 c -0.135,-1.936 -1.675,-3.477 -3.611,-3.616 l -38.555,-2.751 c -0.094,-0.007 -0.188,-0.01 -0.281,-0.01 -1.916,0 -3.569,1.406 -3.852,3.33 l -2.211,14.994 H -81.09 l -2.211,-14.994 c -0.297,-2.018 -2.101,-3.469 -4.133,-3.32 l -38.555,2.751 c -1.936,0.139 -3.476,1.68 -3.611,3.616 L -130.721,0 -163.268,3.138 c 0.015,-3.498 0.06,-7.33 0.06,-8.093 0,-34.374 43.605,-50.896 97.781,-51.086 h 0.066 0.067 c 54.176,0.19 97.766,16.712 97.766,51.086 0,0.777 0.047,4.593 0.063,8.093 z"
- style="fill:#478cbf;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:19.8168869"
- id="path88-5"
- inkscape:connector-curvature="0" />
- </g>
- <g
- id="g90-3"
- transform="matrix(0.06307836,0,0,-0.06307664,5.6393685,1045.0806)"
- style="stroke-width:19.8168869">
- <path
- d="m 0,0 c 0,-12.052 -9.765,-21.815 -21.813,-21.815 -12.042,0 -21.81,9.763 -21.81,21.815 0,12.044 9.768,21.802 21.81,21.802 C -9.765,21.802 0,12.044 0,0"
- style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:19.8168869"
- id="path92-5"
- inkscape:connector-curvature="0" />
- </g>
- <g
- id="g94-6"
- transform="matrix(0.06307836,0,0,-0.06307664,5.3082938,1045.1623)"
- style="stroke-width:19.8168869">
- <path
- d="m 0,0 c 0,-7.994 -6.479,-14.473 -14.479,-14.473 -7.996,0 -14.479,6.479 -14.479,14.473 0,7.994 6.483,14.479 14.479,14.479 C -6.479,14.479 0,7.994 0,0"
- style="fill:#414042;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:19.8168869"
- id="path96-2"
- inkscape:connector-curvature="0" />
- </g>
- <g
- id="g98-9"
- transform="matrix(0.06307836,0,0,-0.06307664,7.4998997,1046.5818)"
- style="stroke-width:19.8168869">
- <path
- d="m 0,0 c -3.878,0 -7.021,2.858 -7.021,6.381 v 20.081 c 0,3.52 3.143,6.381 7.021,6.381 3.878,0 7.028,-2.861 7.028,-6.381 V 6.381 C 7.028,2.858 3.878,0 0,0"
- style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:19.8168869"
- id="path100-1"
- inkscape:connector-curvature="0" />
- </g>
- <g
- id="g102-2"
- transform="matrix(0.06307836,0,0,-0.06307664,9.3606615,1045.0806)"
- style="stroke-width:19.8168869">
- <path
- d="m 0,0 c 0,-12.052 9.765,-21.815 21.815,-21.815 12.041,0 21.808,9.763 21.808,21.815 0,12.044 -9.767,21.802 -21.808,21.802 C 9.765,21.802 0,12.044 0,0"
- style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:19.8168869"
- id="path104-7"
- inkscape:connector-curvature="0" />
- </g>
- <g
- id="g106-0"
- transform="matrix(0.06307836,0,0,-0.06307664,9.6918191,1045.1623)"
- style="stroke-width:19.8168869">
- <path
- d="m 0,0 c 0,-7.994 6.477,-14.473 14.471,-14.473 8.002,0 14.479,6.479 14.479,14.473 0,7.994 -6.477,14.479 -14.479,14.479 C 6.477,14.479 0,7.994 0,0"
- style="fill:#414042;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:19.8168869"
- id="path108-9"
- inkscape:connector-curvature="0" />
- </g>
- <path
- inkscape:connector-curvature="0"
- id="path4392"
- d="m 4.3227149,1042.5597 a 2.5297459,2.5296773 0 0 0 -2.5297461,2.5297 2.5297459,2.5296773 0 0 0 2.5297461,2.5297 2.5297459,2.5296773 0 0 0 2.5297463,-2.5297 2.5297459,2.5296773 0 0 0 -2.5297463,-2.5297 z m 0,0.5084 a 2.0213759,2.021321 0 0 1 2.0213758,2.0213 2.0213759,2.021321 0 0 1 -2.0213758,2.0213 2.0213759,2.021321 0 0 1 -2.0213757,-2.0213 2.0213759,2.021321 0 0 1 2.0213757,-2.0213 z"
- style="opacity:1;fill:#414042;fill-opacity:1;stroke:none;stroke-width:1.94780529;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;filter:url(#filter4200);enable-background:new" />
- <path
- style="opacity:1;fill:#414042;fill-opacity:1;stroke:none;stroke-width:1.94780529;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;filter:url(#filter4200);enable-background:new"
- d="m 10.679126,1042.5597 a 2.5297459,2.5296773 0 0 0 -2.5297472,2.5297 2.5297459,2.5296773 0 0 0 2.5297472,2.5297 2.5297459,2.5296773 0 0 0 2.529744,-2.5297 2.5297459,2.5296773 0 0 0 -2.529744,-2.5297 z m 0,0.5084 a 2.0213759,2.021321 0 0 1 2.021373,2.0213 2.0213759,2.021321 0 0 1 -2.021373,2.0213 2.0213759,2.021321 0 0 1 -2.0213767,-2.0213 2.0213759,2.021321 0 0 1 2.0213767,-2.0213 z"
- id="path4403"
- inkscape:connector-curvature="0" />
- <rect
- style="opacity:1;fill:#414042;fill-opacity:1;stroke:none;stroke-width:5.625;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.44162436"
- id="rect4160"
- width="2.3136585"
- height="0.53352129"
- x="6.3440895"
- y="1043.9767" />
- </g>
-</svg>
diff --git a/editor/icons/source/icon_image_sky_box.svg b/editor/icons/source/icon_gradient.svg
index 9a89c04e58..4ce1b3232f 100644
--- a/editor/icons/source/icon_image_sky_box.svg
+++ b/editor/icons/source/icon_gradient.svg
@@ -10,78 +10,75 @@
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
- sodipodi:docname="icon_image_sky_box.svg"
- inkscape:export-ydpi="90"
- inkscape:export-xdpi="90"
- inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_box_shape.png"
- inkscape:version="0.91 r13725"
- version="1.1"
- id="svg2"
- viewBox="0 0 16 16"
+ width="16"
height="16"
- width="16">
- <sodipodi:namedview
- inkscape:snap-smooth-nodes="true"
- inkscape:object-nodes="true"
- inkscape:snap-intersection-paths="false"
- inkscape:object-paths="false"
- inkscape:window-maximized="1"
- inkscape:window-y="27"
- inkscape:window-x="0"
- inkscape:window-height="1016"
- inkscape:window-width="1920"
- inkscape:snap-center="true"
- inkscape:snap-object-midpoints="true"
- inkscape:snap-bbox-midpoints="true"
- inkscape:snap-bbox-edge-midpoints="true"
- inkscape:bbox-nodes="true"
- inkscape:bbox-paths="true"
- inkscape:snap-bbox="true"
- units="px"
- showgrid="true"
- inkscape:current-layer="layer1"
- inkscape:document-units="px"
- inkscape:cy="9.413879"
- inkscape:cx="10.701686"
- inkscape:zoom="32"
- inkscape:pageshadow="2"
- inkscape:pageopacity="0.0"
- borderopacity="1.0"
- bordercolor="#666666"
- pagecolor="#ffffff"
- id="base"
- inkscape:snap-midpoints="true">
- <inkscape:grid
- id="grid3336"
- type="xygrid"
- empspacing="4" />
- </sodipodi:namedview>
+ viewBox="0 0 16 16"
+ id="svg2"
+ version="1.1"
+ inkscape:version="0.92+devel unknown"
+ inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_key.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90"
+ sodipodi:docname="icon_gradient.svg">
<defs
id="defs4">
<linearGradient
inkscape:collect="always"
- id="linearGradient4142">
+ id="linearGradient848">
<stop
- style="stop-color:#84c2ff;stop-opacity:1"
+ style="stop-color:#e0e0e0;stop-opacity:1;"
offset="0"
- id="stop4144" />
+ id="stop844" />
<stop
- style="stop-color:#46a3ff;stop-opacity:1"
+ style="stop-color:#e0e0e0;stop-opacity:0;"
offset="1"
- id="stop4146" />
+ id="stop846" />
</linearGradient>
- <radialGradient
+ <linearGradient
inkscape:collect="always"
- xlink:href="#linearGradient4142"
- id="radialGradient4148"
- cx="9.9399967"
- cy="1051.0801"
- fx="9.9399967"
- fy="1051.0801"
- r="7"
- gradientTransform="matrix(1.3337828e-5,-1.9999995,1.5714282,2.7945105e-6,-1643.697,1071.2392)"
+ xlink:href="#linearGradient848"
+ id="linearGradient850"
+ x1="10"
+ y1="1"
+ x2="10"
+ y2="15"
gradientUnits="userSpaceOnUse" />
</defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="32"
+ inkscape:cx="9.5330742"
+ inkscape:cy="10.782845"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="true"
+ units="px"
+ inkscape:snap-bbox="true"
+ inkscape:bbox-paths="true"
+ inkscape:bbox-nodes="true"
+ inkscape:snap-bbox-edge-midpoints="true"
+ inkscape:snap-bbox-midpoints="false"
+ inkscape:snap-object-midpoints="true"
+ inkscape:snap-center="true"
+ inkscape:window-width="1920"
+ inkscape:window-height="1016"
+ inkscape:window-x="0"
+ inkscape:window-y="27"
+ inkscape:window-maximized="1"
+ inkscape:object-paths="false"
+ inkscape:snap-intersection-paths="false"
+ inkscape:object-nodes="false"
+ inkscape:snap-smooth-nodes="false"
+ inkscape:document-rotation="0">
+ <inkscape:grid
+ type="xygrid"
+ id="grid3336" />
+ </sodipodi:namedview>
<metadata
id="metadata7">
<rdf:RDF>
@@ -90,27 +87,21 @@
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:title />
+ <dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
- transform="translate(0,-1036.3622)"
- id="layer1"
+ inkscape:label="Layer 1"
inkscape:groupmode="layer"
- inkscape:label="Layer 1">
- <rect
- style="opacity:1;fill:url(#radialGradient4148);fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
- id="rect4140"
- width="14"
- height="13.999983"
- x="1"
- y="1037.3622"
- ry="2.0000174" />
+ id="layer1"
+ transform="translate(0,-1036.3622)">
<path
- style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
- d="M 6 4 A 1 1 0 0 0 5 5 A 1 1 0 0 0 6 6 A 1 1 0 0 0 7 5 A 1 1 0 0 0 6 4 z M 11 5 A 2 2 0 0 0 9 7 A 1 1 0 0 0 8 8 A 1 1 0 0 0 9 9 L 13 9 A 1 1 0 0 0 14 8 A 1 1 0 0 0 13 7 A 2 2 0 0 0 11 5 z M 3 9 A 1 1 0 0 0 2 10 A 1 1 0 0 0 3 11 L 5 11 A 1 1 0 0 0 4 12 A 1 1 0 0 0 5 13 L 8 13 A 1 1 0 0 0 9 12 A 1 1 0 0 0 8 11 L 6 11 A 1 1 0 0 0 7 10 A 1 1 0 0 0 6 9 L 3 9 z "
+ style="opacity:1;fill:url(#linearGradient850);fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.99607843"
+ d="M 2,1 C 1.4477153,1 1,1.4477153 1,2 v 12 c 0,0.552285 0.4477153,1 1,1 h 12 c 0.552285,0 1,-0.447715 1,-1 V 2 C 15,1.4477153 14.552285,1 14,1 Z"
transform="translate(0,1036.3622)"
- id="path4150" />
+ id="rect4156"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="sssssssss" />
</g>
</svg>
diff --git a/editor/icons/source/icon_grid_map.svg b/editor/icons/source/icon_grid_map.svg
index 5bbea0ff2c..83b831abd4 100644
--- a/editor/icons/source/icon_grid_map.svg
+++ b/editor/icons/source/icon_grid_map.svg
@@ -14,7 +14,7 @@
viewBox="0 0 16 16"
id="svg2"
version="1.1"
- inkscape:version="0.91 r13725"
+ inkscape:version="0.92.1 r"
inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_collision_shape_2d.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90"
@@ -28,9 +28,9 @@
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
- inkscape:zoom="32"
- inkscape:cx="9.49128"
- inkscape:cy="9.6074202"
+ inkscape:zoom="16"
+ inkscape:cx="10.766846"
+ inkscape:cy="6.0751122"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
@@ -42,8 +42,8 @@
inkscape:snap-bbox-midpoints="true"
inkscape:snap-object-midpoints="true"
inkscape:snap-center="true"
- inkscape:window-width="1920"
- inkscape:window-height="1016"
+ inkscape:window-width="1600"
+ inkscape:window-height="836"
inkscape:window-x="0"
inkscape:window-y="27"
inkscape:window-maximized="1">
@@ -59,7 +59,7 @@
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:title></dc:title>
+ <dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
@@ -68,68 +68,10 @@
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-1036.3622)">
- <rect
- style="opacity:1;fill:#fc9c9c;fill-opacity:0.99607843;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- id="rect4170"
- width="4"
- height="4.0000172"
- x="1"
- y="1037.3622" />
- <rect
- y="1037.3622"
- x="11"
- height="4.0000172"
- width="4"
- id="rect4172"
- style="opacity:1;fill:#fc9c9c;fill-opacity:0.99607843;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
- <rect
- style="opacity:1;fill:#fc9c9c;fill-opacity:0.99607843;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- id="rect4174"
- width="4"
- height="4.0000172"
- x="6"
- y="1037.3622" />
- <rect
- y="1042.3622"
- x="1"
- height="4.0000172"
- width="4"
- id="rect4176"
- style="opacity:1;fill:#fc9c9c;fill-opacity:0.99607843;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
- <rect
- style="opacity:1;fill:#fc9c9c;fill-opacity:0.99607843;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- id="rect4178"
- width="4"
- height="4.0000172"
- x="11"
- y="1042.3622" />
- <rect
- y="1042.3622"
- x="6"
- height="4.0000172"
- width="4"
- id="rect4180"
- style="opacity:1;fill:#fc9c9c;fill-opacity:0.99607843;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
- <rect
- style="opacity:1;fill:#fc9c9c;fill-opacity:0.99607843;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- id="rect4182"
- width="4"
- height="4.0000172"
- x="1"
- y="1047.3622" />
- <rect
- y="1047.3622"
- x="11"
- height="4.0000172"
- width="4"
- id="rect4184"
- style="opacity:1;fill:#fc9c9c;fill-opacity:0.99607843;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
- <rect
- style="opacity:1;fill:#fc9c9c;fill-opacity:0.99607843;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- id="rect4186"
- width="4"
- height="4.0000172"
- x="6"
- y="1047.3622" />
+ <path
+ style="fill:#fc9c9c;fill-opacity:0.99607843;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 8 1 L 6 2 L 4 3 L 2 4 L 2 6 L 2 8 L 2 10 L 2 12 L 4 13 L 6 14 L 8 15 L 10 14 L 12 13 L 14 12 L 14 10 L 12 9 L 10 10 L 8 11 L 6 10 L 6 8 L 6 6 L 8 5 L 8 3 L 10 2 L 8 1 z M 12 3 L 10 4 L 10 6 L 12 7 L 14 6 L 14 4 L 12 3 z "
+ transform="translate(0,1036.3622)"
+ id="path1047" />
</g>
</svg>
diff --git a/editor/icons/source/icon_gui_close_dark.svg b/editor/icons/source/icon_gui_close_dark.svg
new file mode 100644
index 0000000000..ccb4239784
--- /dev/null
+++ b/editor/icons/source/icon_gui_close_dark.svg
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="16"
+ height="16"
+ viewBox="0 0 16 16"
+ id="svg2"
+ version="1.1"
+ inkscape:version="0.92+devel unknown"
+ inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_add_track.png"
+ inkscape:export-xdpi="45"
+ inkscape:export-ydpi="45"
+ sodipodi:docname="icon_gui_close_dark.svg">
+ <defs
+ id="defs4" />
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="32.000001"
+ inkscape:cx="5.2641929"
+ inkscape:cy="7.5472551"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="true"
+ units="px"
+ inkscape:snap-bbox="true"
+ inkscape:bbox-paths="true"
+ inkscape:bbox-nodes="true"
+ inkscape:snap-bbox-edge-midpoints="true"
+ inkscape:snap-bbox-midpoints="false"
+ inkscape:snap-object-midpoints="true"
+ inkscape:snap-center="true"
+ inkscape:window-width="1920"
+ inkscape:window-height="1016"
+ inkscape:window-x="0"
+ inkscape:window-y="27"
+ inkscape:window-maximized="1"
+ inkscape:document-rotation="0">
+ <inkscape:grid
+ type="xygrid"
+ id="grid3336"
+ empspacing="4" />
+ </sodipodi:namedview>
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(0,-1036.3622)">
+ <path
+ style="fill:#000000;fill-opacity:0.89803922;stroke:none;stroke-width:3;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="M 3.7578125 2.34375 L 2.34375 3.7578125 L 6.5859375 8 L 2.34375 12.242188 L 3.7578125 13.65625 L 8 9.4140625 L 12.242188 13.65625 L 13.65625 12.242188 L 9.4140625 8 L 13.65625 3.7578125 L 12.242188 2.34375 L 8 6.5859375 L 3.7578125 2.34375 z "
+ transform="translate(0,1036.3622)"
+ id="rect4137" />
+ </g>
+</svg>
diff --git a/editor/icons/source/icon_gui_close_light.svg b/editor/icons/source/icon_gui_close_light.svg
new file mode 100644
index 0000000000..90d811965b
--- /dev/null
+++ b/editor/icons/source/icon_gui_close_light.svg
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="16"
+ height="16"
+ viewBox="0 0 16 16"
+ id="svg2"
+ version="1.1"
+ inkscape:version="0.92+devel unknown"
+ inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_add_track.png"
+ inkscape:export-xdpi="45"
+ inkscape:export-ydpi="45"
+ sodipodi:docname="icon_gui_close_light.svg">
+ <defs
+ id="defs4" />
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="32.000001"
+ inkscape:cx="5.2641929"
+ inkscape:cy="7.5472551"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="true"
+ units="px"
+ inkscape:snap-bbox="true"
+ inkscape:bbox-paths="true"
+ inkscape:bbox-nodes="true"
+ inkscape:snap-bbox-edge-midpoints="true"
+ inkscape:snap-bbox-midpoints="false"
+ inkscape:snap-object-midpoints="true"
+ inkscape:snap-center="true"
+ inkscape:window-width="1920"
+ inkscape:window-height="1016"
+ inkscape:window-x="0"
+ inkscape:window-y="27"
+ inkscape:window-maximized="1"
+ inkscape:document-rotation="0">
+ <inkscape:grid
+ type="xygrid"
+ id="grid3336"
+ empspacing="4" />
+ </sodipodi:namedview>
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(0,-1036.3622)">
+ <path
+ style="fill:#ffffff;fill-opacity:0.89803922;stroke:none;stroke-width:3;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="M 3.7578125 2.34375 L 2.34375 3.7578125 L 6.5859375 8 L 2.34375 12.242188 L 3.7578125 13.65625 L 8 9.4140625 L 12.242188 13.65625 L 13.65625 12.242188 L 9.4140625 8 L 13.65625 3.7578125 L 12.242188 2.34375 L 8 6.5859375 L 3.7578125 2.34375 z "
+ transform="translate(0,1036.3622)"
+ id="rect4137" />
+ </g>
+</svg>
diff --git a/editor/icons/source/icon_h_button_array.svg b/editor/icons/source/icon_h_button_array.svg
index 9470aeb370..0dad9ee8b8 100644
--- a/editor/icons/source/icon_h_button_array.svg
+++ b/editor/icons/source/icon_h_button_array.svg
@@ -14,7 +14,7 @@
viewBox="0 0 16 16"
id="svg2"
version="1.1"
- inkscape:version="0.91 r13725"
+ inkscape:version="0.92.1 r"
inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_button.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90"
@@ -28,9 +28,9 @@
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
- inkscape:zoom="32"
- inkscape:cx="12.020131"
- inkscape:cy="9.3264403"
+ inkscape:zoom="16"
+ inkscape:cx="13.231578"
+ inkscape:cy="12.996902"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
@@ -42,11 +42,15 @@
inkscape:snap-bbox-midpoints="true"
inkscape:snap-object-midpoints="true"
inkscape:snap-center="true"
- inkscape:window-width="1920"
- inkscape:window-height="1016"
+ inkscape:window-width="1600"
+ inkscape:window-height="836"
inkscape:window-x="0"
inkscape:window-y="27"
- inkscape:window-maximized="1">
+ inkscape:window-maximized="1"
+ inkscape:snap-intersection-paths="true"
+ inkscape:object-paths="true"
+ inkscape:snap-smooth-nodes="true"
+ inkscape:snap-midpoints="true">
<inkscape:grid
type="xygrid"
id="grid3336"
@@ -60,7 +64,7 @@
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:title></dc:title>
+ <dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
@@ -69,29 +73,21 @@
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-1036.3622)">
- <rect
- style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- id="rect4156"
- width="6"
- height="5.9999828"
- x="2"
- y="1041.3622" />
+ <g
+ id="layer1-7"
+ inkscape:label="Layer 1"
+ transform="translate(9,-1.9999826)"
+ style="fill:#a5efac;fill-opacity:1" />
<path
- style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- d="m 10,1041.3622 0,6 4,0 -1,-2 1,-2 -1,-2 -3,0 z"
- id="rect4158"
+ style="fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="m 12,1041.3622 v 2 h -2 v 2 h 2 v 2 h 2 v -2 h 2 v -2 h -2 v -2 z"
+ id="rect836"
inkscape:connector-curvature="0" />
- <rect
- y="1046.3622"
- x="2"
- height="0.99996543"
- width="6"
- id="rect4161"
- style="opacity:1;fill:#98dc9f;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
<path
- style="opacity:1;fill:#98dc9f;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- d="m 10,1046.3622 0,1 4,0 -0.5,-1 -3.5,0 z"
- id="rect4163"
- inkscape:connector-curvature="0" />
+ style="fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="m 4,1037.3622 v 3.1328 l -1.445312,-0.9648 -1.109376,1.664 3,2 c 0.335902,0.2239 0.773474,0.2239 1.109376,0 l 3,-2 -1.109376,-1.664 L 6,1040.495 v -3.1328 z m -0.5,8 c -0.831,0 -1.5,0.669 -1.5,1.5 v 0.5 1 H 1 v 2 h 8 v -2 H 8 v -1 -0.5 c 0,-0.831 -0.669,-1.5 -1.5,-1.5 z"
+ id="rect829-9"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cccccccccccssccccccccsss" />
</g>
</svg>
diff --git a/editor/icons/source/icon_h_scroll_bar.svg b/editor/icons/source/icon_h_scroll_bar.svg
index 2f007c7c94..fbcee056b3 100644
--- a/editor/icons/source/icon_h_scroll_bar.svg
+++ b/editor/icons/source/icon_h_scroll_bar.svg
@@ -14,7 +14,7 @@
viewBox="0 0 16 16"
id="svg2"
version="1.1"
- inkscape:version="0.91 r13725"
+ inkscape:version="0.92.1 r"
inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_center_container.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90"
@@ -29,7 +29,7 @@
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="32"
- inkscape:cx="9.1371771"
+ inkscape:cx="2.7934271"
inkscape:cy="7.8450604"
inkscape:document-units="px"
inkscape:current-layer="layer1"
@@ -42,8 +42,8 @@
inkscape:snap-bbox-midpoints="true"
inkscape:snap-object-midpoints="true"
inkscape:snap-center="true"
- inkscape:window-width="1920"
- inkscape:window-height="1016"
+ inkscape:window-width="1600"
+ inkscape:window-height="836"
inkscape:window-x="0"
inkscape:window-y="27"
inkscape:window-maximized="1"
@@ -63,7 +63,7 @@
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:title></dc:title>
+ <dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
@@ -73,25 +73,9 @@
id="layer1"
transform="translate(0,-1036.3622)">
<path
- style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- d="M 3,3 C 1.8954305,3 1,3.8954305 1,5 l 0,6 c 0,1.104569 0.8954305,2 2,2 l 10,0 c 1.104569,0 2,-0.895431 2,-2 L 15,5 C 15,3.8954305 14.104569,3 13,3 Z m 0,2 10,0 0,6 -10,0 z"
- transform="translate(0,1036.3622)"
- id="rect4140"
inkscape:connector-curvature="0"
- sodipodi:nodetypes="sssssssssccccc" />
- <rect
- style="opacity:1;fill:none;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.99607843"
- id="rect4181"
- width="4"
- height="4"
- x="4"
- y="1042.3622" />
- <rect
- style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.99607843"
- id="rect4187"
- width="4"
- height="4"
- x="4"
- y="1042.3622" />
+ style="fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="m 15,1041.3622 c 0,-1.108 -0.892,-2 -2,-2 H 3 c -1.108,0 -2,0.892 -2,2 v 6 c 0,1.108 0.892,2 2,2 h 10 c 1.108,0 2,-0.892 2,-2 z m -1,2.9883 a 1.0001,1.0001 0 0 1 -0.168,0.5664 l -2,3 a 1.0001,1.0001 0 1 1 -1.664,-1.1094 l 1.6289,-2.4453 -1.6289,-2.4453 a 1.0001,1.0001 0 1 1 1.664,-1.1094 l 2,3 a 1.0001,1.0001 0 0 1 0.168,0.543 z m -7.9922,-2.9981 a 1.0001,1.0001 0 0 1 -0.1758,0.5645 l -1.6308,2.4453 1.6308,2.4453 a 1.0001,1.0001 0 1 1 -1.664,1.1094 l -2,-3 a 1.0001,1.0001 0 0 1 0,-1.1094 l 2,-3 a 1.0001,1.0001 0 0 1 1.8398,0.5449 z"
+ id="rect825" />
</g>
</svg>
diff --git a/editor/icons/source/icon_h_slider.svg b/editor/icons/source/icon_h_slider.svg
index beee5f8b6a..b3e8a956da 100644
--- a/editor/icons/source/icon_h_slider.svg
+++ b/editor/icons/source/icon_h_slider.svg
@@ -14,7 +14,7 @@
viewBox="0 0 16 16"
id="svg2"
version="1.1"
- inkscape:version="0.91 r13725"
+ inkscape:version="0.92.1 r"
inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_center_container.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90"
@@ -28,9 +28,9 @@
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
- inkscape:zoom="32"
- inkscape:cx="9.3533577"
- inkscape:cy="8.3875011"
+ inkscape:zoom="22.627417"
+ inkscape:cx="7.7094459"
+ inkscape:cy="9.5190595"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
@@ -42,8 +42,8 @@
inkscape:snap-bbox-midpoints="true"
inkscape:snap-object-midpoints="true"
inkscape:snap-center="true"
- inkscape:window-width="1920"
- inkscape:window-height="1016"
+ inkscape:window-width="1600"
+ inkscape:window-height="836"
inkscape:window-x="0"
inkscape:window-y="27"
inkscape:window-maximized="1"
@@ -63,7 +63,7 @@
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:title></dc:title>
+ <dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
@@ -73,27 +73,38 @@
id="layer1"
transform="translate(0,-1036.3622)">
<path
- style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- d="M 2 7 L 2 9 L 5.1738281 9 A 3 3 0 0 1 5 8 A 3 3 0 0 1 5.1757812 7 L 2 7 z M 10.826172 7 A 3 3 0 0 1 11 8 A 3 3 0 0 1 10.824219 9 L 14 9 L 14 7 L 10.826172 7 z "
- transform="translate(0,1036.3622)"
- id="rect4157" />
- <circle
- style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.99607843"
- id="path4159"
- cx="2"
- cy="1044.3622"
- r="1" />
+ style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#a5efac;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
+ d="m 2,1046.3622 a 1.0001,1.0001 0 1 0 0,2 h 2.1308594 a 4,4 0 0 1 -0.1308594,-1 4,4 0 0 1 0.1328125,-1 z m 9.869141,0 a 4,4 0 0 1 0.130859,1 4,4 0 0 1 -0.132812,1 H 14 a 1.0001,1.0001 0 1 0 0,-2 z"
+ id="path817"
+ inkscape:connector-curvature="0" />
<circle
- r="1"
- cy="1044.3622"
- cx="14"
- id="circle4161"
- style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.99607843" />
- <circle
- style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.99607843"
- id="path4167"
- cx="8"
- cy="1044.3622"
+ style="fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:4;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ id="path824"
+ cx="13"
+ cy="1047.3622"
r="2" />
+ <path
+ style="fill:none;stroke:#a5efac;stroke-width:2;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="m 2,1040.3622 v 2"
+ id="path835"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cc" />
+ <path
+ style="fill:none;stroke:#a5efac;stroke-width:2;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="m 8,1041.3622 v 0"
+ id="path837"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cc" />
+ <path
+ style="fill:none;stroke:#a5efac;stroke-width:2;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="m 14,1040.3622 v 2"
+ id="path839"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cc" />
+ <path
+ style="fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="M 3 10 L 3 12 L 9.1308594 12 A 4 4 0 0 1 9 11 A 4 4 0 0 1 9.1328125 10 L 3 10 z "
+ transform="translate(0,1036.3622)"
+ id="rect841" />
</g>
</svg>
diff --git a/editor/icons/source/icon_help.svg b/editor/icons/source/icon_help.svg
index 01e85e0f55..cc8517d2d1 100644
--- a/editor/icons/source/icon_help.svg
+++ b/editor/icons/source/icon_help.svg
@@ -14,7 +14,7 @@
viewBox="0 0 16 16"
id="svg2"
version="1.1"
- inkscape:version="0.91 r13725"
+ inkscape:version="0.92+devel unknown"
inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_help.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90"
@@ -29,8 +29,8 @@
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="31.999999"
- inkscape:cx="5.4018713"
- inkscape:cy="8.2308388"
+ inkscape:cx="9.7940153"
+ inkscape:cy="7.5068869"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
@@ -46,7 +46,8 @@
inkscape:window-height="1016"
inkscape:window-x="0"
inkscape:window-y="27"
- inkscape:window-maximized="1">
+ inkscape:window-maximized="1"
+ inkscape:document-rotation="0">
<inkscape:grid
type="xygrid"
id="grid3336" />
@@ -59,7 +60,7 @@
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:title></dc:title>
+ <dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
@@ -69,42 +70,9 @@
id="layer1"
transform="translate(0,-1036.3622)">
<path
- style="opacity:1;fill:#f1f1f1;fill-opacity:1;stroke:none;stroke-width:3;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- d="M 8 1 A 7 7 0 0 0 1 8 A 7 7 0 0 0 8 15 A 7 7 0 0 0 15 8 A 7 7 0 0 0 8 1 z M 8 4 A 4.0000172 4.0000172 0 0 1 12 8 A 4.0000172 4.0000172 0 0 1 8 12 A 4.0000172 4.0000172 0 0 1 4 8 A 4.0000172 4.0000172 0 0 1 8 4 z "
+ style="fill:#e0e0e0;fill-opacity:0.58823532;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:0.3254902"
+ d="M 5.0292969 1 C 4.0296094 0.989075 3.0196929 1.31165 2 2 L 2 9 C 4.0172141 7.6471 6.0167145 7.6864 8 9 C 9.9832855 7.6864 11.982786 7.6471 14 9 L 14 2 C 12.980307 1.31165 11.970391 0.989075 10.970703 1 C 10.309402 1.007227 9.6532285 1.1734956 9 1.4628906 L 9 6 L 8 6 L 8 2 C 7.0184429 1.35535 6.0289844 1.010925 5.0292969 1 z M 0 10 L 0 16 L 2 16 A 3 3 0 0 0 5 13 A 3 3 0 0 0 2 10 L 0 10 z M 5 13 A 3 3 0 0 0 8 16 A 3 3 0 0 0 11 13 A 3 3 0 0 0 8 10 A 3 3 0 0 0 5 13 z M 11 13 A 3 3 0 0 0 14 16 L 15 16 L 15 14 L 14 14 A 1.0000174 1.0000174 0 0 1 13 13 A 1.0000174 1.0000174 0 0 1 14 12 L 15 12 L 15 10 L 14 10 A 3 3 0 0 0 11 13 z M 2 12 A 1 1 0 0 1 3 13 A 1 1 0 0 1 2 14 L 2 12 z M 8 12 A 1.0000174 1.0000174 0 0 1 9 13 A 1.0000174 1.0000174 0 0 1 8 14 A 1.0000174 1.0000174 0 0 1 7 13 A 1.0000174 1.0000174 0 0 1 8 12 z "
transform="translate(0,1036.3622)"
- id="circle4160" />
- <path
- style="opacity:1;fill:#ff8484;fill-opacity:1;stroke:none;stroke-width:3;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- d="m 8,1 0,3 c 1.1045715,-4.8e-6 2.104267,0.4480167 2.828125,1.171875 L 12.949219,3.0507812 C 11.68247,1.7840321 9.9329986,1.0000047 8,1 Z"
- transform="translate(0,1036.3622)"
- id="circle4154"
- inkscape:connector-curvature="0"
- sodipodi:nodetypes="ccccc"
- inkscape:transform-center-x="-2.4746095"
- inkscape:transform-center-y="-4.9140625" />
- <path
- inkscape:transform-center-y="2.4746"
- inkscape:transform-center-x="-4.9140625"
- sodipodi:nodetypes="ccccc"
- inkscape:connector-curvature="0"
- id="path4163"
- d="m 15,1044.3622 -3,0 c 5e-6,1.1046 -0.448017,2.1043 -1.171875,2.8281 l 2.121094,2.1211 c 1.266749,-1.2667 2.050776,-3.0162 2.050781,-4.9492 z"
- style="opacity:1;fill:#ff8484;fill-opacity:1;stroke:none;stroke-width:3;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
- <path
- style="opacity:1;fill:#ff8484;fill-opacity:1;stroke:none;stroke-width:3;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- d="m 8,1051.3622 0,-3 c -1.1046,0 -2.1043,-0.448 -2.8281,-1.1719 l -2.1211,2.1211 c 1.2667,1.2668 3.0162,2.0508 4.9492,2.0508 z"
- id="path4165"
- inkscape:connector-curvature="0"
- sodipodi:nodetypes="ccccc"
- inkscape:transform-center-x="2.4746"
- inkscape:transform-center-y="4.91405" />
- <path
- inkscape:transform-center-y="-2.4746"
- inkscape:transform-center-x="4.91405"
- sodipodi:nodetypes="ccccc"
- inkscape:connector-curvature="0"
- id="path4167"
- d="m 1,1044.3622 3,0 c 0,-1.1046 0.448,-2.1043 1.1719,-2.8281 L 3.0508,1039.413 C 1.784,1040.6797 1,1042.4292 1,1044.3622 Z"
- style="opacity:1;fill:#ff8484;fill-opacity:1;stroke:none;stroke-width:3;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+ id="path4270" />
</g>
</svg>
diff --git a/editor/icons/source/icon_help_search.svg b/editor/icons/source/icon_help_search.svg
new file mode 100644
index 0000000000..ab914c0c64
--- /dev/null
+++ b/editor/icons/source/icon_help_search.svg
@@ -0,0 +1,91 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="16"
+ height="16"
+ viewBox="0 0 16 16"
+ id="svg2"
+ version="1.1"
+ inkscape:version="0.92+devel unknown"
+ inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_help.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90"
+ sodipodi:docname="icon_help_search.svg">
+ <defs
+ id="defs4" />
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="22.627417"
+ inkscape:cx="10.167683"
+ inkscape:cy="7.1383117"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="true"
+ units="px"
+ inkscape:snap-bbox="true"
+ inkscape:bbox-paths="true"
+ inkscape:bbox-nodes="true"
+ inkscape:snap-bbox-edge-midpoints="true"
+ inkscape:snap-bbox-midpoints="true"
+ inkscape:snap-object-midpoints="true"
+ inkscape:snap-center="true"
+ inkscape:window-width="1920"
+ inkscape:window-height="1016"
+ inkscape:window-x="0"
+ inkscape:window-y="27"
+ inkscape:window-maximized="1"
+ inkscape:document-rotation="0">
+ <inkscape:grid
+ type="xygrid"
+ id="grid3336" />
+ </sodipodi:namedview>
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(0,-1036.3622)">
+ <path
+ style="fill:#e0e0e0;fill-opacity:1;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:0.3254902"
+ d="m 0,10 v 6 H 2 C 3.6568542,16 5,14.656854 5,13 5,11.343146 3.6568542,10 2,10 Z m 5,3 c 0,1.656854 1.3431458,3 3,3 1.6568542,0 3,-1.343146 3,-3 0,-1.656854 -1.3431458,-3 -3,-3 -1.6568542,0 -3,1.343146 -3,3 z m 6,0 c 0,1.656854 1.343146,3 3,3 h 1 v -2 h -1 c -0.552281,-10e-6 -0.99999,-0.447719 -1,-1 10e-6,-0.552281 0.447719,-0.99999 1,-1 h 1 v -2 h -1 c -1.656854,0 -3,1.343146 -3,3 z M 2,12 c 0.5522847,0 1,0.447715 1,1 0,0.552285 -0.4477153,1 -1,1 z m 6,0 c 0.5522808,10e-6 0.9999904,0.447719 1,1 -9.6e-6,0.552281 -0.4477192,0.99999 -1,1 -0.5522808,-10e-6 -0.9999904,-0.447719 -1,-1 9.6e-6,-0.552281 0.4477192,-0.99999 1,-1 z"
+ transform="translate(0,1036.3622)"
+ id="path4270"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="ccssscssssssscccccccsscsccccccc" />
+ <path
+ style="fill:#e0e0e0;fill-opacity:1;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:0.3254902"
+ d="m 9,1036.3622 a 4,4 0 0 0 -4,4 4,4 0 0 0 4,4 4,4 0 0 0 4,-4 4,4 0 0 0 -4,-4 z m 0,2 a 2.0000174,2.0000174 0 0 1 2,2 2.0000174,2.0000174 0 0 1 -2,2 2.0000174,2.0000174 0 0 1 -2,-2 2.0000174,2.0000174 0 0 1 2,-2 z"
+ id="path4285"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:none;stroke:#e0e0e0;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="m 7,1042.3622 -3,3"
+ id="path4290"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cc" />
+ </g>
+</svg>
diff --git a/editor/icons/source/icon_line_edit.svg b/editor/icons/source/icon_line_edit.svg
index 61ba1ebe7e..ccd94b92ed 100644
--- a/editor/icons/source/icon_line_edit.svg
+++ b/editor/icons/source/icon_line_edit.svg
@@ -14,7 +14,7 @@
viewBox="0 0 16 16"
id="svg2"
version="1.1"
- inkscape:version="0.91 r13725"
+ inkscape:version="0.92.1 r"
inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_center_container.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90"
@@ -28,9 +28,9 @@
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
- inkscape:zoom="45.254834"
- inkscape:cx="4.4635244"
- inkscape:cy="8.6660933"
+ inkscape:zoom="32"
+ inkscape:cx="10.632447"
+ inkscape:cy="9.3208726"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
@@ -42,8 +42,8 @@
inkscape:snap-bbox-midpoints="true"
inkscape:snap-object-midpoints="true"
inkscape:snap-center="true"
- inkscape:window-width="1920"
- inkscape:window-height="1016"
+ inkscape:window-width="1600"
+ inkscape:window-height="836"
inkscape:window-x="0"
inkscape:window-y="27"
inkscape:window-maximized="1"
@@ -63,7 +63,7 @@
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:title></dc:title>
+ <dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
@@ -74,17 +74,15 @@
transform="translate(0,-1036.3622)">
<path
style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- d="M 3,3 C 1.8954305,3 1,3.8954305 1,5 l 0,6 c 0,1.104569 0.8954305,2 2,2 l 10,0 c 1.104569,0 2,-0.895431 2,-2 L 15,5 C 15,3.8954305 14.104569,3 13,3 Z m 0,2 10,0 0,6 -10,0 z"
+ d="M 1 11 C 1 12.104569 1.8954305 13 3 13 L 13 13 C 14.104569 13 15 12.104569 15 11 L 13 11 L 3 11 L 1 11 z "
transform="translate(0,1036.3622)"
- id="rect4140"
- inkscape:connector-curvature="0"
- sodipodi:nodetypes="sssssssssccccc" />
+ id="rect4140" />
<rect
- style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:3.16227078;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect4167"
- width="1"
- height="4.0000172"
- x="4"
- y="1042.3622" />
+ width="2"
+ height="5"
+ x="2"
+ y="1040.3622" />
</g>
</svg>
diff --git a/editor/icons/source/icon_mini_matrix32.svg b/editor/icons/source/icon_mini_matrix32.svg
deleted file mode 100644
index 5159ea0b87..0000000000
--- a/editor/icons/source/icon_mini_matrix32.svg
+++ /dev/null
@@ -1,145 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!-- Created with Inkscape (http://www.inkscape.org/) -->
-
-<svg
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:cc="http://creativecommons.org/ns#"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:svg="http://www.w3.org/2000/svg"
- xmlns="http://www.w3.org/2000/svg"
- xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
- xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
- width="16"
- height="12"
- viewBox="0 0 16 12"
- id="svg2"
- version="1.1"
- inkscape:version="0.91 r13725"
- inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_add_track.png"
- inkscape:export-xdpi="45"
- inkscape:export-ydpi="45"
- sodipodi:docname="icon_mini_matrix32.svg">
- <defs
- id="defs4" />
- <sodipodi:namedview
- id="base"
- pagecolor="#ffffff"
- bordercolor="#666666"
- borderopacity="1.0"
- inkscape:pageopacity="0.0"
- inkscape:pageshadow="2"
- inkscape:zoom="32.000001"
- inkscape:cx="1.5471383"
- inkscape:cy="5.978497"
- inkscape:document-units="px"
- inkscape:current-layer="layer1"
- showgrid="true"
- units="px"
- inkscape:snap-bbox="true"
- inkscape:bbox-paths="true"
- inkscape:bbox-nodes="true"
- inkscape:snap-bbox-edge-midpoints="true"
- inkscape:snap-bbox-midpoints="false"
- inkscape:snap-object-midpoints="true"
- inkscape:snap-center="true"
- inkscape:window-width="1920"
- inkscape:window-height="1016"
- inkscape:window-x="0"
- inkscape:window-y="27"
- inkscape:window-maximized="1"
- inkscape:object-nodes="true"
- inkscape:snap-smooth-nodes="true">
- <inkscape:grid
- type="xygrid"
- id="grid3336" />
- </sodipodi:namedview>
- <metadata
- id="metadata7">
- <rdf:RDF>
- <cc:Work
- rdf:about="">
- <dc:format>image/svg+xml</dc:format>
- <dc:type
- rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:title />
- </cc:Work>
- </rdf:RDF>
- </metadata>
- <g
- inkscape:label="Layer 1"
- inkscape:groupmode="layer"
- id="layer1"
- transform="translate(0,-1040.3622)">
- <path
- style="fill:#ddf4aa;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
- d="M 8 2 L 8 4 L 9 4 L 10 4 A 1 1 0 0 1 9 5 L 9 7 A 1 1 0 0 1 10 8 A 1 1 0 0 1 9 9 L 8 9 L 8 11 L 9 11 A 3 3 0 0 0 11.597656 9.5 A 3 3 0 0 0 11.597656 6.5 A 3 3 0 0 0 11.232422 5.9980469 A 3 3 0 0 0 11.597656 5.5 A 3 3 0 0 0 11.994141 4 L 12 4 L 12 2 L 9 2 L 8 2 z "
- transform="translate(0,1040.3622)"
- id="path4753" />
- <rect
- y="1048.3622"
- x="11"
- height="2"
- width="5"
- id="rect4763"
- style="fill:#c4ec69;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
- <path
- sodipodi:open="true"
- d="m 13,1050.3622 a 2,2 0 0 1 -1.732051,-1 2,2 0 0 1 0,-2 2,2 0 0 1 1.732051,-1"
- sodipodi:end="4.712389"
- sodipodi:start="1.5707963"
- sodipodi:ry="2"
- sodipodi:rx="2"
- sodipodi:cy="1048.3622"
- sodipodi:cx="13"
- sodipodi:type="arc"
- id="path4765"
- style="fill:#c4ec69;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
- <path
- inkscape:connector-curvature="0"
- id="path4767"
- d="m 13,1042.3622 0,2 a 1,1 0 0 1 1,1 1,1 0 0 1 -1,1 l 0,2 a 3,3 0 0 0 2.597656,-1.5 3,3 0 0 0 0,-3 3,3 0 0 0 -2.597656,-1.5 z"
- style="fill:#c4ec69;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
- <path
- style="fill:#c4ec69;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
- d="m 2,1044.3622 a 3,3 0 0 1 3,3 l -2,0 a 1.0000174,1.0000174 0 0 0 -1,-1 l 0,-2 z"
- id="path4771"
- inkscape:connector-curvature="0" />
- <rect
- y="-1050.3622"
- x="3"
- height="3"
- width="2"
- id="rect4773"
- style="fill:#c4ec69;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
- transform="scale(1,-1)" />
- <rect
- style="fill:#c4ec69;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
- id="rect4775"
- width="2"
- height="5.9999828"
- x="0"
- y="-1050.3622"
- transform="scale(1,-1)" />
- <rect
- transform="scale(1,-1)"
- y="-1050.3622"
- x="3"
- height="5.9999828"
- width="2"
- id="rect4777"
- style="fill:#c4ec69;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
- <path
- inkscape:connector-curvature="0"
- id="path4779"
- d="m 5,1044.3622 a 3,3 0 0 1 3,3 l -2,0 a 1.0000174,1.0000174 0 0 0 -1,-1 l 0,-2 z"
- style="fill:#c4ec69;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
- <rect
- style="fill:#c4ec69;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
- id="rect4781"
- width="2"
- height="3.0000002"
- x="6"
- y="-1050.3622"
- transform="scale(1,-1)" />
- </g>
-</svg>
diff --git a/editor/icons/source/icon_multi_script.svg b/editor/icons/source/icon_multi_script.svg
new file mode 100644
index 0000000000..07c49383a9
--- /dev/null
+++ b/editor/icons/source/icon_multi_script.svg
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="16"
+ height="16"
+ viewBox="0 0 16 16"
+ id="svg2"
+ version="1.1"
+ inkscape:version="0.92.1 r"
+ inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_g_d_script.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90"
+ sodipodi:docname="icon_multi_script.svg">
+ <defs
+ id="defs4" />
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="32"
+ inkscape:cx="8.3086348"
+ inkscape:cy="8.7213858"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="true"
+ units="px"
+ inkscape:snap-bbox="true"
+ inkscape:bbox-paths="true"
+ inkscape:bbox-nodes="true"
+ inkscape:snap-bbox-edge-midpoints="true"
+ inkscape:snap-bbox-midpoints="true"
+ inkscape:snap-object-midpoints="true"
+ inkscape:snap-center="true"
+ inkscape:window-width="1600"
+ inkscape:window-height="836"
+ inkscape:window-x="0"
+ inkscape:window-y="27"
+ inkscape:window-maximized="1">
+ <inkscape:grid
+ type="xygrid"
+ id="grid3336" />
+ </sodipodi:namedview>
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(0,-1036.3622)">
+ <path
+ style="opacity:1;fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:3;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ d="M 7 1 L 6.4355469 3.2578125 A 5.0000172 5.0000172 0 0 0 5.7460938 3.5371094 L 3.7578125 2.34375 L 2.34375 3.7578125 L 3.5390625 5.7519531 A 5.0000172 5.0000172 0 0 0 3.2539062 6.4375 L 1 7 L 1 9 L 3.2578125 9.5644531 A 5.0000172 5.0000172 0 0 0 3.5371094 10.251953 L 2.34375 12.242188 L 3.7578125 13.65625 L 5 12.912109 L 5 8 L 6 8 A 2.0000174 2.0000174 0 0 1 8 6 L 8 5 L 12.912109 5 L 13.65625 3.7578125 L 12.242188 2.34375 L 10.248047 3.5390625 A 5.0000172 5.0000172 0 0 0 9.5625 3.2539062 L 9 1 L 7 1 z "
+ transform="translate(0,1036.3622)"
+ id="path4176" />
+ <path
+ style="fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:0.99999714;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="m 10,1043.3622 v 3 H 7 v 2 h 3 v 3 h 2 v -3 h 3 v -2 h -3 v -3 z"
+ id="rect817"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="ccccccccccccc" />
+ </g>
+</svg>
diff --git a/editor/icons/source/icon_nine_patch_rect.svg b/editor/icons/source/icon_nine_patch_rect.svg
index f12789c19e..0a6b94094a 100644
--- a/editor/icons/source/icon_nine_patch_rect.svg
+++ b/editor/icons/source/icon_nine_patch_rect.svg
@@ -14,11 +14,11 @@
viewBox="0 0 16 16"
id="svg2"
version="1.1"
- inkscape:version="0.91 r13725"
+ inkscape:version="0.92.1 r"
inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_center_container.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90"
- sodipodi:docname="icon_patch_9_frame.svg">
+ sodipodi:docname="icon_nine_patch_rect.svg">
<defs
id="defs4" />
<sodipodi:namedview
@@ -29,8 +29,8 @@
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="32"
- inkscape:cx="10.35114"
- inkscape:cy="9.1140348"
+ inkscape:cx="8.03864"
+ inkscape:cy="8.0827848"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
@@ -42,8 +42,8 @@
inkscape:snap-bbox-midpoints="true"
inkscape:snap-object-midpoints="true"
inkscape:snap-center="true"
- inkscape:window-width="1920"
- inkscape:window-height="1016"
+ inkscape:window-width="1600"
+ inkscape:window-height="836"
inkscape:window-x="0"
inkscape:window-y="27"
inkscape:window-maximized="1">
@@ -69,35 +69,35 @@
id="layer1"
transform="translate(0,-1036.3622)">
<rect
- style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2.82842708;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect4154"
- width="1"
+ width="2"
height="14"
x="1"
y="1037.3622" />
<rect
- y="1050.3622"
+ y="1049.3622"
x="1"
- height="0.9999826"
+ height="1.9999652"
width="14"
id="rect4156"
- style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+ style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2.82842708;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
<rect
- style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2.82846403;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect4158"
width="14"
- height="0.9999826"
+ height="2.0000174"
x="1"
y="1037.3622" />
<rect
y="1037.3622"
- x="14"
+ x="13"
height="14"
- width="1"
+ width="2"
id="rect4160"
- style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+ style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2.82842708;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
<rect
- y="1040.3622"
+ y="1041.3622"
x="1"
height="0.9999826"
width="14"
@@ -109,18 +109,18 @@
width="14"
height="0.9999826"
x="1"
- y="1047.3622" />
+ y="1046.3622" />
<rect
style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect4166"
width="14"
height="0.9999826"
x="1037.3622"
- y="-5"
- transform="matrix(0,1,-1,0,0,0)" />
+ y="-6"
+ transform="rotate(90)" />
<rect
- transform="matrix(0,1,-1,0,0,0)"
- y="-12"
+ transform="rotate(90)"
+ y="-10.999983"
x="1037.3622"
height="0.9999826"
width="14"
diff --git a/editor/icons/source/icon_option_button.svg b/editor/icons/source/icon_option_button.svg
index 4537b14616..a58d3d9c06 100644
--- a/editor/icons/source/icon_option_button.svg
+++ b/editor/icons/source/icon_option_button.svg
@@ -14,7 +14,7 @@
viewBox="0 0 16 16"
id="svg2"
version="1.1"
- inkscape:version="0.91 r13725"
+ inkscape:version="0.92.1 r"
inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_center_container.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90"
@@ -29,8 +29,8 @@
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="32"
- inkscape:cx="3.751238"
- inkscape:cy="7.999659"
+ inkscape:cx="10.188738"
+ inkscape:cy="6.593409"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
@@ -42,8 +42,8 @@
inkscape:snap-bbox-midpoints="true"
inkscape:snap-object-midpoints="true"
inkscape:snap-center="true"
- inkscape:window-width="1920"
- inkscape:window-height="1016"
+ inkscape:window-width="1600"
+ inkscape:window-height="836"
inkscape:window-x="0"
inkscape:window-y="27"
inkscape:window-maximized="1"
@@ -63,7 +63,7 @@
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:title></dc:title>
+ <dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
@@ -74,11 +74,9 @@
transform="translate(0,-1036.3622)">
<path
style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- d="M 3,3 C 1.8954305,3 1,3.8954305 1,5 l 0,6 c 0,1.104569 0.8954305,2 2,2 L 9,13 9,3 Z m 7,0 0,10 3,0 c 1.104569,0 2,-0.895431 2,-2 L 15,5 C 15,3.8954305 14.104569,3 13,3 Z m 1,4 3,0 -1.5,2 z"
- id="rect4140"
+ d="M 3 3 C 1.8954305 3 1 3.8954305 1 5 L 1 11 C 1 12.104569 1.8954305 13 3 13 L 8 13 L 9 13 L 10 13 L 12 13 L 13 13 C 14.104569 13 15 12.104569 15 11 L 15 5 C 15 3.8954305 14.104569 3 13 3 L 12 3 L 10 3 L 9 3 L 8 3 L 3 3 z M 11 5.9863281 A 1.0001 1.0001 0 0 1 11.716797 7.7070312 L 8.7167969 10.707031 A 1.0001 1.0001 0 0 1 7.3027344 10.707031 L 4.3027344 7.7070312 A 1.0001 1.0001 0 0 1 5 5.9902344 A 1.0001 1.0001 0 0 1 5.7167969 6.2929688 L 8.0097656 8.5859375 L 10.302734 6.2929688 A 1.0001 1.0001 0 0 1 11 5.9863281 z "
transform="translate(0,1036.3622)"
- inkscape:connector-curvature="0"
- sodipodi:nodetypes="ssssccsccssssccccc" />
+ id="rect4140" />
<rect
style="opacity:1;fill:none;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.99607843"
id="rect4181"
diff --git a/editor/icons/source/icon_panorama_sky.svg b/editor/icons/source/icon_panorama_sky.svg
new file mode 100644
index 0000000000..32a5253fe3
--- /dev/null
+++ b/editor/icons/source/icon_panorama_sky.svg
@@ -0,0 +1,131 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="16"
+ height="16"
+ viewBox="0 0 16 16"
+ id="svg2"
+ version="1.1"
+ inkscape:version="0.92+devel unknown"
+ inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_confirmation_dialog.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90"
+ sodipodi:docname="icon_panorama_sky.svg">
+ <defs
+ id="defs4">
+ <linearGradient
+ inkscape:collect="always"
+ id="linearGradient4291">
+ <stop
+ style="stop-color:#1ec3ff;stop-opacity:1"
+ offset="0"
+ id="stop4287" />
+ <stop
+ style="stop-color:#b2e1ff;stop-opacity:1"
+ offset="1"
+ id="stop4289" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient4291"
+ id="linearGradient4293"
+ x1="8"
+ y1="1038.3622"
+ x2="8"
+ y2="1050.3622"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(1.0096153,0,0,1.0227214,-0.00961532,-22.593074)" />
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="45.254834"
+ inkscape:cx="8.0139922"
+ inkscape:cy="7.7749171"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="true"
+ units="px"
+ inkscape:snap-bbox="true"
+ inkscape:bbox-paths="true"
+ inkscape:bbox-nodes="true"
+ inkscape:snap-bbox-edge-midpoints="true"
+ inkscape:snap-bbox-midpoints="true"
+ inkscape:snap-object-midpoints="true"
+ inkscape:snap-center="true"
+ inkscape:window-width="1920"
+ inkscape:window-height="1016"
+ inkscape:window-x="0"
+ inkscape:window-y="27"
+ inkscape:window-maximized="1"
+ inkscape:document-rotation="0">
+ <inkscape:grid
+ type="xygrid"
+ id="grid3336"
+ originx="0"
+ originy="0"
+ spacingx="1"
+ spacingy="1" />
+ </sodipodi:namedview>
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(0,-1037.3622)">
+ <path
+ style="fill:url(#linearGradient4293);fill-opacity:1;stroke-width:15.24220753"
+ d="m 1,1039.3622 c 4.2748686,2.6091 10.764971,2.7449 14,0 v 12 c -3.58489,-2.6849 -9.7929096,-2.6544 -14,0 z"
+ id="rect4285"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="ccccc" />
+ <rect
+ style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:square;stroke-linejoin:round;stroke-opacity:0.3254902"
+ id="rect4273"
+ width="3"
+ height="2"
+ x="2"
+ y="1046.3622"
+ ry="1" />
+ <rect
+ style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:square;stroke-linejoin:round;stroke-opacity:0.3254902"
+ id="rect4275"
+ width="4"
+ height="2"
+ x="8"
+ y="1044.3622"
+ ry="1" />
+ <rect
+ style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:square;stroke-linejoin:round;stroke-opacity:0.3254902"
+ id="rect4277"
+ width="4"
+ height="2"
+ x="10"
+ y="1043.3622"
+ ry="1" />
+ </g>
+</svg>
diff --git a/editor/icons/source/icon_particles_shader.svg b/editor/icons/source/icon_particles_shader.svg
deleted file mode 100644
index b4c2ef7ccd..0000000000
--- a/editor/icons/source/icon_particles_shader.svg
+++ /dev/null
@@ -1,159 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!-- Created with Inkscape (http://www.inkscape.org/) -->
-
-<svg
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:cc="http://creativecommons.org/ns#"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:svg="http://www.w3.org/2000/svg"
- xmlns="http://www.w3.org/2000/svg"
- xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
- xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
- width="16"
- height="16"
- viewBox="0 0 16 16"
- id="svg2"
- version="1.1"
- inkscape:version="0.91 r13725"
- inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_node_2d.png"
- inkscape:export-xdpi="90"
- inkscape:export-ydpi="90"
- sodipodi:docname="icon_particles_shader.svg">
- <defs
- id="defs4">
- <clipPath
- clipPathUnits="userSpaceOnUse"
- id="clipPath4253">
- <path
- style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:4;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
- d="m 16.458984,1024.37 a 12.000027,12.000027 0 0 0 -3.564453,0.4004 12.000027,12.000027 0 0 0 -8.4863279,14.6973 12.000027,12.000027 0 0 0 14.6972659,8.4863 12.000027,12.000027 0 0 0 8.486328,-14.6973 12.000027,12.000027 0 0 0 -11.132813,-8.8867 z M 16.25,1029.8212 a 6.5451717,6.5451717 0 0 1 6.072266,4.8476 6.5451717,6.5451717 0 0 1 -4.628907,8.0157 6.5451717,6.5451717 0 0 1 -8.0156246,-4.6289 6.5451717,6.5451717 0 0 1 4.6289066,-8.0157 6.5451717,6.5451717 0 0 1 1.943359,-0.2187 z"
- id="path4255"
- inkscape:connector-curvature="0" />
- </clipPath>
- <clipPath
- clipPathUnits="userSpaceOnUse"
- id="clipPath4199">
- <path
- inkscape:connector-curvature="0"
- id="path4201"
- d="m 16.5,1025.8622 a 11.8125,10.499999 0 0 0 -11.8125001,10.5 11.8125,10.499999 0 0 0 11.8125001,10.5 11.8125,10.499999 0 0 0 11.8125,-10.5 11.8125,10.499999 0 0 0 -11.8125,-10.5 z m -3.375,3 a 3.375,2.9999997 0 0 1 3.375,3 3.375,2.9999997 0 0 1 -3.375,3 3.375,2.9999997 0 0 1 -3.3750001,-3 3.375,2.9999997 0 0 1 3.3750001,-3 z"
- style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
- </clipPath>
- <clipPath
- clipPathUnits="userSpaceOnUse"
- id="clipPath4208">
- <path
- style="opacity:1;fill:#a5b7f5;fill-opacity:0.98823529;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.99607843"
- d="M 8,1037.3622 A 4.4999948,4.9999847 0 0 0 3.5859375,1041.3934 3,3 0 0 0 1,1044.3622 a 3,3 0 0 0 3,3 l 8,0 a 3,3 0 0 0 3,-3 3,3 0 0 0 -2.589844,-2.9668 A 4.4999948,4.9999847 0 0 0 8,1037.3622 Z m -4,11 a 1,1 0 0 0 -1,1 1,1 0 0 0 1,1 1,1 0 0 0 1,-1 1,1 0 0 0 -1,-1 z m 8,0 a 1,1 0 0 0 -1,1 1,1 0 0 0 1,1 1,1 0 0 0 1,-1 1,1 0 0 0 -1,-1 z m -4,1 a 1,1 0 0 0 -1,1 1,1 0 0 0 1,1 1,1 0 0 0 1,-1 1,1 0 0 0 -1,-1 z"
- id="path4210"
- inkscape:connector-curvature="0" />
- </clipPath>
- </defs>
- <sodipodi:namedview
- id="base"
- pagecolor="#ffffff"
- bordercolor="#666666"
- borderopacity="1.0"
- inkscape:pageopacity="0.0"
- inkscape:pageshadow="2"
- inkscape:zoom="15.999999"
- inkscape:cx="8.2922739"
- inkscape:cy="6.6952763"
- inkscape:document-units="px"
- inkscape:current-layer="layer1"
- showgrid="true"
- units="px"
- inkscape:snap-bbox="true"
- inkscape:bbox-paths="true"
- inkscape:bbox-nodes="true"
- inkscape:snap-bbox-edge-midpoints="true"
- inkscape:snap-bbox-midpoints="true"
- inkscape:snap-object-midpoints="true"
- inkscape:snap-center="true"
- inkscape:window-width="1920"
- inkscape:window-height="1016"
- inkscape:window-x="0"
- inkscape:window-y="27"
- inkscape:window-maximized="1"
- inkscape:object-paths="true"
- inkscape:snap-intersection-paths="true"
- inkscape:object-nodes="true"
- inkscape:snap-smooth-nodes="true">
- <inkscape:grid
- type="xygrid"
- id="grid3336"
- empspacing="4" />
- </sodipodi:namedview>
- <metadata
- id="metadata7">
- <rdf:RDF>
- <cc:Work
- rdf:about="">
- <dc:format>image/svg+xml</dc:format>
- <dc:type
- rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:title></dc:title>
- </cc:Work>
- </rdf:RDF>
- </metadata>
- <g
- inkscape:label="Layer 1"
- inkscape:groupmode="layer"
- id="layer1"
- transform="translate(0,-1036.3622)">
- <g
- id="g4271"
- clip-path="url(#clipPath4208)"
- transform="translate(0,1.8694115e-5)">
- <rect
- y="1037.3622"
- x="0"
- height="2.0000031"
- width="16"
- id="rect4159"
- style="fill:#ff7070;fill-opacity:1;stroke:none;stroke-width:4;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
- <rect
- style="fill:#ffeb70;fill-opacity:1;stroke:none;stroke-width:4;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
- id="rect4161"
- width="16"
- height="2.0000029"
- x="0"
- y="1039.3622" />
- <rect
- style="fill:#9dff70;fill-opacity:1;stroke:none;stroke-width:4;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
- id="rect4163"
- width="16"
- height="1.9999999"
- x="0"
- y="1041.3622" />
- <rect
- y="1043.3622"
- x="0"
- height="2.0000024"
- width="16"
- id="rect4165"
- style="fill:#70ffb9;fill-opacity:1;stroke:none;stroke-width:4;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
- <rect
- y="1045.3622"
- x="0"
- height="2.0000021"
- width="16"
- id="rect4167"
- style="fill:#70deff;fill-opacity:1;stroke:none;stroke-width:4;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
- <rect
- style="fill:#ff70ac;fill-opacity:1;stroke:none;stroke-width:4;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
- id="rect4169"
- width="16"
- height="1.9999987"
- x="0"
- y="1049.3622" />
- <rect
- style="fill:#9f70ff;fill-opacity:1;stroke:none;stroke-width:4;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
- id="rect4146"
- width="16"
- height="2.0000021"
- x="0"
- y="1047.3622" />
- </g>
- </g>
-</svg>
diff --git a/editor/icons/source/icon_patch_9_rect.svg b/editor/icons/source/icon_patch_9_rect.svg
deleted file mode 100644
index c5a09603a6..0000000000
--- a/editor/icons/source/icon_patch_9_rect.svg
+++ /dev/null
@@ -1,130 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!-- Created with Inkscape (http://www.inkscape.org/) -->
-
-<svg
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:cc="http://creativecommons.org/ns#"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:svg="http://www.w3.org/2000/svg"
- xmlns="http://www.w3.org/2000/svg"
- xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
- xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
- width="16"
- height="16"
- viewBox="0 0 16 16"
- id="svg2"
- version="1.1"
- inkscape:version="0.91 r13725"
- inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_center_container.png"
- inkscape:export-xdpi="90"
- inkscape:export-ydpi="90"
- sodipodi:docname="icon_patch_9_rect.svg">
- <defs
- id="defs4" />
- <sodipodi:namedview
- id="base"
- pagecolor="#ffffff"
- bordercolor="#666666"
- borderopacity="1.0"
- inkscape:pageopacity="0.0"
- inkscape:pageshadow="2"
- inkscape:zoom="32"
- inkscape:cx="10.35114"
- inkscape:cy="9.1140348"
- inkscape:document-units="px"
- inkscape:current-layer="layer1"
- showgrid="true"
- units="px"
- inkscape:snap-bbox="true"
- inkscape:bbox-paths="true"
- inkscape:bbox-nodes="true"
- inkscape:snap-bbox-edge-midpoints="true"
- inkscape:snap-bbox-midpoints="true"
- inkscape:snap-object-midpoints="true"
- inkscape:snap-center="true"
- inkscape:window-width="1920"
- inkscape:window-height="1016"
- inkscape:window-x="0"
- inkscape:window-y="27"
- inkscape:window-maximized="1">
- <inkscape:grid
- type="xygrid"
- id="grid3336" />
- </sodipodi:namedview>
- <metadata
- id="metadata7">
- <rdf:RDF>
- <cc:Work
- rdf:about="">
- <dc:format>image/svg+xml</dc:format>
- <dc:type
- rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:title />
- </cc:Work>
- </rdf:RDF>
- </metadata>
- <g
- inkscape:label="Layer 1"
- inkscape:groupmode="layer"
- id="layer1"
- transform="translate(0,-1036.3622)">
- <rect
- style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- id="rect4154"
- width="1"
- height="14"
- x="1"
- y="1037.3622" />
- <rect
- y="1050.3622"
- x="1"
- height="0.9999826"
- width="14"
- id="rect4156"
- style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
- <rect
- style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- id="rect4158"
- width="14"
- height="0.9999826"
- x="1"
- y="1037.3622" />
- <rect
- y="1037.3622"
- x="14"
- height="14"
- width="1"
- id="rect4160"
- style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
- <rect
- y="1040.3622"
- x="1"
- height="0.9999826"
- width="14"
- id="rect4162"
- style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
- <rect
- style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- id="rect4164"
- width="14"
- height="0.9999826"
- x="1"
- y="1047.3622" />
- <rect
- style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- id="rect4166"
- width="14"
- height="0.9999826"
- x="1037.3622"
- y="-5"
- transform="matrix(0,1,-1,0,0,0)" />
- <rect
- transform="matrix(0,1,-1,0,0,0)"
- y="-12"
- x="1037.3622"
- height="0.9999826"
- width="14"
- id="rect4168"
- style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
- </g>
-</svg>
diff --git a/editor/icons/source/icon_sample_player.svg b/editor/icons/source/icon_plane_mesh.svg
index 2254718a9b..5273900606 100644
--- a/editor/icons/source/icon_sample_player.svg
+++ b/editor/icons/source/icon_plane_mesh.svg
@@ -14,11 +14,11 @@
viewBox="0 0 16 16"
id="svg2"
version="1.1"
- inkscape:version="0.91 r13725"
+ inkscape:version="0.92+devel unknown"
inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_node_2d.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90"
- sodipodi:docname="icon_sample_player.svg">
+ sodipodi:docname="icon_quad_mesh.svg">
<defs
id="defs4" />
<sodipodi:namedview
@@ -29,8 +29,8 @@
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="31.999999"
- inkscape:cx="10.445016"
- inkscape:cy="6.2884774"
+ inkscape:cx="13.201653"
+ inkscape:cy="9.702363"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
@@ -46,7 +46,8 @@
inkscape:window-height="1016"
inkscape:window-x="0"
inkscape:window-y="27"
- inkscape:window-maximized="1">
+ inkscape:window-maximized="1"
+ inkscape:document-rotation="0">
<inkscape:grid
type="xygrid"
id="grid3336"
@@ -60,7 +61,7 @@
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:title></dc:title>
+ <dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
@@ -70,9 +71,9 @@
id="layer1"
transform="translate(0,-1036.3622)">
<path
- style="opacity:1;fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.99607843"
- d="M 8 1 L 4 6 L 1 6 L 1 10 L 4 10 L 8 15 L 8 1 z M 13 3 L 13 13 L 14 13 L 14 3 L 13 3 z M 10 6 L 10 11 L 11 11 L 11 6 L 10 6 z "
- transform="translate(0,1036.3622)"
- id="rect4154" />
+ style="fill:none;stroke:#ffd684;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none"
+ d="m 2,1048.3622 h 12 l -3,-8 H 5 Z"
+ id="path4266"
+ inkscape:connector-curvature="0" />
</g>
</svg>
diff --git a/editor/icons/source/icon_prism_mesh.svg b/editor/icons/source/icon_prism_mesh.svg
new file mode 100644
index 0000000000..310d8f1a28
--- /dev/null
+++ b/editor/icons/source/icon_prism_mesh.svg
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="16"
+ height="16"
+ viewBox="0 0 16 16"
+ id="svg2"
+ version="1.1"
+ inkscape:version="0.92+devel unknown"
+ inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_node_2d.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90"
+ sodipodi:docname="icon_prism_mesh.svg">
+ <defs
+ id="defs4" />
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="31.999999"
+ inkscape:cx="9.3129802"
+ inkscape:cy="9.9193702"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="true"
+ units="px"
+ inkscape:snap-bbox="true"
+ inkscape:bbox-paths="true"
+ inkscape:bbox-nodes="true"
+ inkscape:snap-bbox-edge-midpoints="true"
+ inkscape:snap-bbox-midpoints="true"
+ inkscape:snap-object-midpoints="true"
+ inkscape:snap-center="true"
+ inkscape:window-width="1920"
+ inkscape:window-height="1016"
+ inkscape:window-x="0"
+ inkscape:window-y="27"
+ inkscape:window-maximized="1"
+ inkscape:document-rotation="0">
+ <inkscape:grid
+ type="xygrid"
+ id="grid3336"
+ empspacing="4" />
+ </sodipodi:namedview>
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(0,-1036.3622)">
+ <path
+ style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-variant-east-asian:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#ffd684;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;filter-blend-mode:normal;filter-gaussianBlur-deviation:0;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate;opacity:1"
+ d="M 7.9824219 1.0019531 A 1.0001 1.0001 0 0 0 7.1679688 1.4453125 L 1.1953125 10.40625 L 1.1679688 10.445312 A 1 1 0 0 0 1.1054688 10.552734 A 1 1 0 0 0 1.5527344 11.894531 L 7.5527344 14.894531 A 1.0001 1.0001 0 0 0 8.4472656 14.894531 L 14.447266 11.894531 A 1 1 0 0 0 14.894531 10.552734 A 1 1 0 0 0 14.832031 10.445312 L 8.8320312 1.4453125 A 1.0001 1.0001 0 0 0 7.9824219 1.0019531 z M 7 5.3027344 L 7 12.382812 L 3.4609375 10.611328 L 7 5.3027344 z M 9 5.3027344 L 12.539062 10.611328 L 9 12.382812 L 9 5.3027344 z "
+ transform="translate(0,1036.3622)"
+ id="path4309" />
+ </g>
+</svg>
diff --git a/editor/icons/source/icon_procedural_sky.svg b/editor/icons/source/icon_procedural_sky.svg
new file mode 100644
index 0000000000..97162f3efa
--- /dev/null
+++ b/editor/icons/source/icon_procedural_sky.svg
@@ -0,0 +1,129 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="16"
+ height="16"
+ viewBox="0 0 16 16"
+ id="svg2"
+ version="1.1"
+ inkscape:version="0.92+devel unknown"
+ inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_confirmation_dialog.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90"
+ sodipodi:docname="icon_procedural_sky.svg">
+ <defs
+ id="defs4">
+ <linearGradient
+ inkscape:collect="always"
+ id="linearGradient4291">
+ <stop
+ style="stop-color:#1ec3ff;stop-opacity:1"
+ offset="0"
+ id="stop4287" />
+ <stop
+ style="stop-color:#b2e1ff;stop-opacity:1"
+ offset="1"
+ id="stop4289" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient4291"
+ id="linearGradient4303"
+ x1="8"
+ y1="1040.3622"
+ x2="8"
+ y2="1050.3622"
+ gradientUnits="userSpaceOnUse" />
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="45.254834"
+ inkscape:cx="12.704839"
+ inkscape:cy="7.3549048"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="true"
+ units="px"
+ inkscape:snap-bbox="true"
+ inkscape:bbox-paths="true"
+ inkscape:bbox-nodes="true"
+ inkscape:snap-bbox-edge-midpoints="true"
+ inkscape:snap-bbox-midpoints="true"
+ inkscape:snap-object-midpoints="true"
+ inkscape:snap-center="true"
+ inkscape:window-width="1920"
+ inkscape:window-height="1016"
+ inkscape:window-x="0"
+ inkscape:window-y="27"
+ inkscape:window-maximized="1"
+ inkscape:document-rotation="0">
+ <inkscape:grid
+ type="xygrid"
+ id="grid3336"
+ originx="0"
+ originy="0"
+ spacingx="1"
+ spacingy="1" />
+ </sodipodi:namedview>
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(0,-1037.3622)">
+ <path
+ style="fill:url(#linearGradient4303);fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:square;stroke-linejoin:round;stroke-opacity:0.3254902"
+ d="m 8,1040.3622 a 7,7 0 0 0 -7,7 7,7 0 0 0 0.6855469,3 H 14.316406 a 7,7 0 0 0 0.683594,-3 7,7 0 0 0 -7,-7 z"
+ id="path4292"
+ inkscape:connector-curvature="0" />
+ <rect
+ style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:square;stroke-linejoin:round;stroke-opacity:0.3254902"
+ id="rect4305"
+ width="3"
+ height="2"
+ x="2"
+ y="1047.3622"
+ ry="1" />
+ <rect
+ style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:square;stroke-linejoin:round;stroke-opacity:0.3254902"
+ id="rect4307"
+ width="4"
+ height="2"
+ x="7"
+ y="1045.3622"
+ ry="1" />
+ <rect
+ style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:square;stroke-linejoin:round;stroke-opacity:0.3254902"
+ id="rect4309"
+ width="4"
+ height="2"
+ x="9"
+ y="1044.3622"
+ ry="1" />
+ </g>
+</svg>
diff --git a/editor/icons/source/icon_quad_mesh.svg b/editor/icons/source/icon_quad_mesh.svg
new file mode 100644
index 0000000000..f511dd8a12
--- /dev/null
+++ b/editor/icons/source/icon_quad_mesh.svg
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="16"
+ height="16"
+ viewBox="0 0 16 16"
+ id="svg2"
+ version="1.1"
+ inkscape:version="0.92+devel unknown"
+ inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_node_2d.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90"
+ sodipodi:docname="icon_quad_mesh.svg">
+ <defs
+ id="defs4" />
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="31.999999"
+ inkscape:cx="11.701653"
+ inkscape:cy="9.702363"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="true"
+ units="px"
+ inkscape:snap-bbox="true"
+ inkscape:bbox-paths="true"
+ inkscape:bbox-nodes="true"
+ inkscape:snap-bbox-edge-midpoints="true"
+ inkscape:snap-bbox-midpoints="true"
+ inkscape:snap-object-midpoints="true"
+ inkscape:snap-center="true"
+ inkscape:window-width="1920"
+ inkscape:window-height="1016"
+ inkscape:window-x="0"
+ inkscape:window-y="27"
+ inkscape:window-maximized="1"
+ inkscape:document-rotation="0">
+ <inkscape:grid
+ type="xygrid"
+ id="grid3336"
+ empspacing="4" />
+ </sodipodi:namedview>
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(0,-1036.3622)">
+ <path
+ style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-variant-east-asian:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#ffd684;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
+ d="m 15,1037.3622 v 1 13 H 1 v -14 z m -2,2 H 4.414062 L 13,1047.9481 Z m -10,1.4141 v 8.5859 h 8.585938 z"
+ id="path4276"
+ inkscape:connector-curvature="0" />
+ </g>
+</svg>
diff --git a/editor/icons/source/icon_reference_rect.svg b/editor/icons/source/icon_reference_rect.svg
index cee814360d..ace9a48a23 100644
--- a/editor/icons/source/icon_reference_rect.svg
+++ b/editor/icons/source/icon_reference_rect.svg
@@ -14,7 +14,7 @@
viewBox="0 0 16 16"
id="svg2"
version="1.1"
- inkscape:version="0.91 r13725"
+ inkscape:version="0.92.1 r"
inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_center_container.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90"
@@ -29,8 +29,8 @@
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="32"
- inkscape:cx="4.94489"
- inkscape:cy="9.0515348"
+ inkscape:cx="8.97614"
+ inkscape:cy="8.6140348"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
@@ -42,8 +42,8 @@
inkscape:snap-bbox-midpoints="true"
inkscape:snap-object-midpoints="true"
inkscape:snap-center="true"
- inkscape:window-width="1920"
- inkscape:window-height="1016"
+ inkscape:window-width="1600"
+ inkscape:window-height="836"
inkscape:window-x="0"
inkscape:window-y="27"
inkscape:window-maximized="1">
@@ -59,7 +59,7 @@
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:title></dc:title>
+ <dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
@@ -69,32 +69,62 @@
id="layer1"
transform="translate(0,-1036.3622)">
<rect
- style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- id="rect4154"
- width="1"
- height="14"
+ style="fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:0;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.99607843"
+ id="rect817"
+ width="2"
+ height="2"
x="1"
y="1037.3622" />
<rect
- y="1050.3622"
- x="1"
- height="0.9999826"
- width="14"
- id="rect4156"
- style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+ y="1037.3622"
+ x="13"
+ height="2"
+ width="2"
+ id="rect819"
+ style="fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:0;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.99607843" />
<rect
- style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- id="rect4158"
- width="14"
- height="0.9999826"
- x="1"
+ style="fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:0;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.99607843"
+ id="rect821"
+ width="8"
+ height="2"
+ x="4"
y="1037.3622" />
<rect
- y="1037.3622"
- x="14"
- height="14"
- width="1"
- id="rect4160"
- style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+ y="1049.3622"
+ x="4"
+ height="2"
+ width="8"
+ id="rect823"
+ style="fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:0;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.99607843" />
+ <rect
+ style="fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:0;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.99607843"
+ id="rect825"
+ width="2"
+ height="2"
+ x="13"
+ y="1049.3622" />
+ <rect
+ y="1049.3622"
+ x="1"
+ height="2"
+ width="2"
+ id="rect827"
+ style="fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:0;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.99607843" />
+ <rect
+ style="fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:0;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.99607843"
+ id="rect829"
+ width="8"
+ height="2"
+ x="1040.3622"
+ y="-3"
+ transform="rotate(90)" />
+ <rect
+ transform="rotate(90)"
+ y="-15"
+ x="1040.3622"
+ height="2"
+ width="8"
+ id="rect831"
+ style="fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:0;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.99607843" />
</g>
</svg>
diff --git a/editor/icons/source/icon_remote_transform.svg b/editor/icons/source/icon_remote_transform.svg
index fbbfacf629..814384297e 100644
--- a/editor/icons/source/icon_remote_transform.svg
+++ b/editor/icons/source/icon_remote_transform.svg
@@ -14,7 +14,7 @@
viewBox="0 0 16 16"
id="svg2"
version="1.1"
- inkscape:version="0.91 r13725"
+ inkscape:version="0.92.1 r"
inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_node_2d.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90"
@@ -29,8 +29,8 @@
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="16"
- inkscape:cx="7.0691739"
- inkscape:cy="9.3738931"
+ inkscape:cx="10.542126"
+ inkscape:cy="9.6951879"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
@@ -42,10 +42,10 @@
inkscape:snap-bbox-midpoints="true"
inkscape:snap-object-midpoints="true"
inkscape:snap-center="true"
- inkscape:window-width="1680"
- inkscape:window-height="1050"
- inkscape:window-x="1366"
- inkscape:window-y="0"
+ inkscape:window-width="1600"
+ inkscape:window-height="836"
+ inkscape:window-x="0"
+ inkscape:window-y="27"
inkscape:window-maximized="1"
inkscape:object-paths="true"
inkscape:snap-intersection-paths="true"
@@ -64,7 +64,7 @@
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:title></dc:title>
+ <dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
@@ -74,51 +74,53 @@
id="layer1"
transform="translate(0,-1036.3622)">
<path
- style="opacity:1;fill:#fc9c9c;fill-opacity:0.99607843;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- id="path4155"
+ style="fill:#fc9c9c;fill-opacity:1;stroke:none;stroke-width:2.66666675;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ id="path834"
sodipodi:type="arc"
- sodipodi:cx="744.13245"
- sodipodi:cy="734.23291"
+ sodipodi:cx="8"
+ sodipodi:cy="1047.3622"
sodipodi:rx="4"
sodipodi:ry="4"
sodipodi:start="0"
sodipodi:end="3.1415927"
- d="m 748.13245,734.23291 a 4,4 0 0 1 -2,3.4641 4,4 0 0 1 -4,0 4,4 0 0 1 -2,-3.4641 l 4,0 z"
- inkscape:transform-center-y="0.58575321"
- transform="matrix(0.70710678,0.70710678,-0.70710678,0.70710678,0,0)"
- inkscape:transform-center-x="0.58575732" />
- <circle
- style="opacity:1;fill:#fc9c9c;fill-opacity:0.99607843;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- id="path4159"
- cx="7"
- cy="1045.3622"
- r="1" />
- <path
- style="opacity:1;fill:#fc9c9c;fill-opacity:0.99607843;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- d="m 13.242641,1039.1196 a 6.0000172,6.0000172 0 0 0 -8.4852817,0 l 0.7071068,0.7071 a 5.0000172,5.0000172 0 0 1 7.0710679,0 5.0000172,5.0000172 0 0 1 0,7.071 l 0.707107,0.7071 a 6.0000172,6.0000172 0 0 0 0,-8.4852 z"
- id="circle4163"
- inkscape:connector-curvature="0"
- inkscape:transform-center-y="-0.87867618"
- inkscape:transform-center-x="-0.8786559" />
+ d="m 12,1047.3622 a 4,4 0 0 1 -2.0000001,3.4641 4,4 0 0 1 -4,0 A 4,4 0 0 1 4,1047.3622 l 4,0 z" />
+ <rect
+ style="fill:#fc9c9c;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ id="rect836"
+ width="2"
+ height="4"
+ x="7"
+ y="1045.3622"
+ ry="1" />
<path
- style="opacity:1;fill:#fc9c9c;fill-opacity:0.99607843;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- d="m 11.828427,1040.5338 a 4.0000172,4.0000172 0 0 0 -5.6568541,0 l 0.7071068,0.7071 a 3.0000174,3.0000174 0 0 1 4.2426403,0 3.0000174,3.0000174 0 0 1 0,4.2426 l 0.707107,0.7071 a 4.0000172,4.0000172 0 0 0 0,-5.6568 z"
- id="circle4168"
- inkscape:connector-curvature="0"
- inkscape:transform-center-y="-0.58578284"
- inkscape:transform-center-x="-0.58576926" />
+ style="fill:none;fill-opacity:1;stroke:#fc9c9c;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ id="path838"
+ sodipodi:type="arc"
+ sodipodi:cx="8"
+ sodipodi:cy="1045.3622"
+ sodipodi:rx="7.0000172"
+ sodipodi:ry="7.0000172"
+ sodipodi:start="3.6651914"
+ sodipodi:end="5.7595865"
+ d="m 1.9378072,1041.8622 a 7.0000172,7.0000172 0 0 1 6.0621926,-3.5 7.0000172,7.0000172 0 0 1 6.0621932,3.5"
+ sodipodi:open="true" />
<path
- style="opacity:1;fill:#fc9c9c;fill-opacity:0.99607843;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- d="m 10.414214,1041.948 a 2,2 0 0 0 -2.8284276,0 l 0.7071068,0.7071 a 1.0000174,1.0000174 0 0 1 1.4142136,0 1.0000174,1.0000174 0 0 1 0,1.4142 l 0.7071072,0.7071 a 2,2 0 0 0 0,-2.8284 z"
- id="circle4172"
- inkscape:connector-curvature="0"
- inkscape:transform-center-y="-0.29289334"
- inkscape:transform-center-x="-0.29288664" />
+ r="3.645746"
+ cy="1045.3622"
+ cx="8"
+ id="path846"
+ style="fill:#fc9c9c;fill-opacity:1;stroke:#000000;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<path
- style="fill:#fc9c9c;fill-opacity:0.99607843;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
- d="m 1,1051.3622 4,-5 1,0 0,5 z"
- id="path4181"
- inkscape:connector-curvature="0"
- sodipodi:nodetypes="ccccc" />
+ id="circle848"
+ style="fill:none;fill-opacity:1;stroke:#fc9c9c;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ sodipodi:type="arc"
+ sodipodi:cx="8"
+ sodipodi:cy="1045.3622"
+ sodipodi:rx="2.9999826"
+ sodipodi:ry="2.9999826"
+ sodipodi:start="3.403392"
+ sodipodi:end="6.0213859"
+ d="m 5.1022393,1044.5857 a 2.9999826,2.9999826 0 0 1 2.8977606,-2.2235 2.9999826,2.9999826 0 0 1 2.8977611,2.2235"
+ sodipodi:open="true" />
</g>
</svg>
diff --git a/editor/icons/source/icon_remote_transform_2d.svg b/editor/icons/source/icon_remote_transform_2d.svg
index 479cc0eb25..7976937a17 100644
--- a/editor/icons/source/icon_remote_transform_2d.svg
+++ b/editor/icons/source/icon_remote_transform_2d.svg
@@ -14,11 +14,11 @@
viewBox="0 0 16 16"
id="svg2"
version="1.1"
- inkscape:version="0.91 r13725"
+ inkscape:version="0.92.1 r"
inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_node_2d.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90"
- sodipodi:docname="icon_remote_transform.svg">
+ sodipodi:docname="icon_remote_transform_2d.svg">
<defs
id="defs4" />
<sodipodi:namedview
@@ -29,8 +29,8 @@
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="16"
- inkscape:cx="6.9441739"
- inkscape:cy="9.4988931"
+ inkscape:cx="-4.711526"
+ inkscape:cy="5.1371642"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
@@ -42,8 +42,8 @@
inkscape:snap-bbox-midpoints="true"
inkscape:snap-object-midpoints="true"
inkscape:snap-center="true"
- inkscape:window-width="1920"
- inkscape:window-height="1016"
+ inkscape:window-width="1600"
+ inkscape:window-height="836"
inkscape:window-x="0"
inkscape:window-y="27"
inkscape:window-maximized="1"
@@ -64,7 +64,7 @@
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:title></dc:title>
+ <dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
@@ -74,51 +74,47 @@
id="layer1"
transform="translate(0,-1036.3622)">
<path
- style="opacity:1;fill:#a5b7f6;fill-opacity:0.98823529;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- id="path4155"
+ style="fill:#a5b7f7;fill-opacity:0.98823529;stroke:none;stroke-width:2.66666675;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ id="path834"
sodipodi:type="arc"
- sodipodi:cx="744.13245"
- sodipodi:cy="734.23291"
+ sodipodi:cx="8"
+ sodipodi:cy="1047.3622"
sodipodi:rx="4"
sodipodi:ry="4"
sodipodi:start="0"
sodipodi:end="3.1415927"
- d="m 748.13245,734.23291 a 4,4 0 0 1 -2,3.4641 4,4 0 0 1 -4,0 4,4 0 0 1 -2,-3.4641 l 4,0 z"
- inkscape:transform-center-y="0.58575321"
- transform="matrix(0.70710678,0.70710678,-0.70710678,0.70710678,0,0)"
- inkscape:transform-center-x="0.58575732" />
- <circle
- style="opacity:1;fill:#a5b7f6;fill-opacity:0.98823529;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- id="path4159"
- cx="7"
- cy="1045.3622"
- r="1" />
+ d="m 12,1047.3622 a 4,4 0 0 1 -2.0000001,3.4641 4,4 0 0 1 -4,0 A 4,4 0 0 1 4,1047.3622 l 4,0 z" />
+ <rect
+ style="fill:#a5b7f7;fill-opacity:0.98823529;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ id="rect836"
+ width="2"
+ height="4"
+ x="7"
+ y="1045.3622"
+ ry="1" />
<path
- style="opacity:1;fill:#a5b7f6;fill-opacity:0.98823529;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- d="m 13.242641,1039.1196 a 6.0000172,6.0000172 0 0 0 -8.4852817,0 l 0.7071068,0.7071 a 5.0000172,5.0000172 0 0 1 7.0710679,0 5.0000172,5.0000172 0 0 1 0,7.071 l 0.707107,0.7071 a 6.0000172,6.0000172 0 0 0 0,-8.4852 z"
- id="circle4163"
- inkscape:connector-curvature="0"
- inkscape:transform-center-y="-0.87867618"
- inkscape:transform-center-x="-0.8786559" />
- <path
- style="opacity:1;fill:#a5b7f6;fill-opacity:0.98823529;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- d="m 11.828427,1040.5338 a 4.0000172,4.0000172 0 0 0 -5.6568541,0 l 0.7071068,0.7071 a 3.0000174,3.0000174 0 0 1 4.2426403,0 3.0000174,3.0000174 0 0 1 0,4.2426 l 0.707107,0.7071 a 4.0000172,4.0000172 0 0 0 0,-5.6568 z"
- id="circle4168"
- inkscape:connector-curvature="0"
- inkscape:transform-center-y="-0.58578284"
- inkscape:transform-center-x="-0.58576926" />
- <path
- style="opacity:1;fill:#a5b7f6;fill-opacity:0.98823529;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- d="m 10.414214,1041.948 a 2,2 0 0 0 -2.8284276,0 l 0.7071068,0.7071 a 1.0000174,1.0000174 0 0 1 1.4142136,0 1.0000174,1.0000174 0 0 1 0,1.4142 l 0.7071072,0.7071 a 2,2 0 0 0 0,-2.8284 z"
- id="circle4172"
- inkscape:connector-curvature="0"
- inkscape:transform-center-y="-0.29289334"
- inkscape:transform-center-x="-0.29288664" />
+ style="fill:none;fill-opacity:1;stroke:#a5b7f7;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ id="path838"
+ sodipodi:type="arc"
+ sodipodi:cx="8"
+ sodipodi:cy="1045.3622"
+ sodipodi:rx="7.0000172"
+ sodipodi:ry="7.0000172"
+ sodipodi:start="3.6651914"
+ sodipodi:end="5.7595865"
+ d="m 1.9378072,1041.8622 a 7.0000172,7.0000172 0 0 1 6.0621926,-3.5 7.0000172,7.0000172 0 0 1 6.0621932,3.5"
+ sodipodi:open="true" />
<path
- style="fill:#a5b7f6;fill-opacity:0.98823529;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
- d="m 1,1051.3622 4,-5 1,0 0,5 z"
- id="path4181"
- inkscape:connector-curvature="0"
- sodipodi:nodetypes="ccccc" />
+ id="circle848"
+ style="fill:none;fill-opacity:1;stroke:#a5b7f7;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ sodipodi:type="arc"
+ sodipodi:cx="8"
+ sodipodi:cy="1045.3622"
+ sodipodi:rx="2.9999826"
+ sodipodi:ry="2.9999826"
+ sodipodi:start="3.403392"
+ sodipodi:end="6.0213859"
+ d="m 5.1022393,1044.5857 a 2.9999826,2.9999826 0 0 1 2.8977606,-2.2235 2.9999826,2.9999826 0 0 1 2.8977611,2.2235"
+ sodipodi:open="true" />
</g>
</svg>
diff --git a/editor/icons/source/icon_sample.svg b/editor/icons/source/icon_sample.svg
deleted file mode 100644
index 782e07a012..0000000000
--- a/editor/icons/source/icon_sample.svg
+++ /dev/null
@@ -1,128 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!-- Created with Inkscape (http://www.inkscape.org/) -->
-
-<svg
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:cc="http://creativecommons.org/ns#"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:svg="http://www.w3.org/2000/svg"
- xmlns="http://www.w3.org/2000/svg"
- xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
- xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
- width="16"
- height="16"
- viewBox="0 0 16 16"
- id="svg2"
- version="1.1"
- inkscape:version="0.91 r13725"
- inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_dependency_changed_hl.png"
- inkscape:export-xdpi="45"
- inkscape:export-ydpi="45"
- sodipodi:docname="icon_sample.svg">
- <defs
- id="defs4" />
- <sodipodi:namedview
- id="base"
- pagecolor="#ffffff"
- bordercolor="#666666"
- borderopacity="1.0"
- inkscape:pageopacity="0.0"
- inkscape:pageshadow="2"
- inkscape:zoom="30.700696"
- inkscape:cx="10.421269"
- inkscape:cy="6.7982798"
- inkscape:document-units="px"
- inkscape:current-layer="layer1"
- showgrid="true"
- units="px"
- inkscape:snap-bbox="true"
- inkscape:bbox-paths="true"
- inkscape:bbox-nodes="true"
- inkscape:snap-bbox-edge-midpoints="true"
- inkscape:snap-bbox-midpoints="false"
- inkscape:snap-object-midpoints="true"
- inkscape:snap-center="true"
- inkscape:window-width="1920"
- inkscape:window-height="1016"
- inkscape:window-x="0"
- inkscape:window-y="27"
- inkscape:window-maximized="1">
- <inkscape:grid
- type="xygrid"
- id="grid3336" />
- </sodipodi:namedview>
- <metadata
- id="metadata7">
- <rdf:RDF>
- <cc:Work
- rdf:about="">
- <dc:format>image/svg+xml</dc:format>
- <dc:type
- rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:title></dc:title>
- </cc:Work>
- </rdf:RDF>
- </metadata>
- <g
- inkscape:label="Layer 1"
- inkscape:groupmode="layer"
- id="layer1"
- transform="translate(0,-1036.3622)">
- <rect
- style="opacity:1;fill:#ff8484;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.99607843"
- id="rect4156"
- width="1"
- height="1.999948"
- x="-14"
- y="1043.3622"
- transform="scale(-1,1)" />
- <rect
- y="1039.3622"
- x="-12"
- height="10.000017"
- width="1"
- id="rect4158"
- style="opacity:1;fill:#ff8484;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.99607843"
- transform="scale(-1,1)" />
- <rect
- style="opacity:1;fill:#ff8484;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.99607843"
- id="rect4160"
- width="1"
- height="7.9999475"
- x="-10"
- y="1040.3622"
- transform="scale(-1,1)" />
- <rect
- y="1037.3622"
- x="-8"
- height="13.999949"
- width="1"
- id="rect4162"
- style="opacity:1;fill:#ff8484;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.99607843"
- transform="scale(-1,1)" />
- <rect
- style="opacity:1;fill:#ff8484;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.99607843"
- id="rect4164"
- width="1"
- height="12.000017"
- x="-6"
- y="1038.3622"
- transform="scale(-1,1)" />
- <rect
- y="1041.3622"
- x="-4"
- height="6.0000172"
- width="1"
- id="rect4166"
- style="opacity:1;fill:#ff8484;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.99607843"
- transform="scale(-1,1)" />
- <rect
- style="opacity:1;fill:#ff8484;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.99607843"
- id="rect4168"
- width="1"
- height="1.9999824"
- x="-2"
- y="1043.3622"
- transform="scale(-1,1)" />
- </g>
-</svg>
diff --git a/editor/icons/source/icon_slider_grabber_hl.svg b/editor/icons/source/icon_slider_grabber_hl.svg
deleted file mode 100644
index 5d53811c55..0000000000
--- a/editor/icons/source/icon_slider_grabber_hl.svg
+++ /dev/null
@@ -1,80 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!-- Created with Inkscape (http://www.inkscape.org/) -->
-
-<svg
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:cc="http://creativecommons.org/ns#"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:svg="http://www.w3.org/2000/svg"
- xmlns="http://www.w3.org/2000/svg"
- xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
- xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
- width="16"
- height="16"
- viewBox="0 0 16 15.999999"
- id="svg2"
- version="1.1"
- inkscape:version="0.92.1 unknown"
- sodipodi:docname="icon_slider_grabber_hl.svg"
- inkscape:export-filename="/mnt/2TB/Development/godot_dev/editor/icons/2x/icon_slider_grabber_hl.png"
- inkscape:export-xdpi="192"
- inkscape:export-ydpi="192">
- <defs
- id="defs4" />
- <sodipodi:namedview
- id="base"
- pagecolor="#ffffff"
- bordercolor="#666666"
- borderopacity="1.0"
- inkscape:pageopacity="0.0"
- inkscape:pageshadow="2"
- inkscape:zoom="32"
- inkscape:cx="7.6841863"
- inkscape:cy="6.0120089"
- inkscape:document-units="px"
- inkscape:current-layer="layer1"
- showgrid="true"
- units="px"
- inkscape:object-paths="false"
- inkscape:snap-intersection-paths="false"
- inkscape:snap-bbox="true"
- inkscape:bbox-paths="true"
- inkscape:bbox-nodes="true"
- inkscape:snap-bbox-edge-midpoints="true"
- inkscape:window-width="1092"
- inkscape:window-height="880"
- inkscape:window-x="92"
- inkscape:window-y="49"
- inkscape:window-maximized="0"
- inkscape:snap-smooth-nodes="true"
- inkscape:object-nodes="true">
- <inkscape:grid
- type="xygrid"
- id="grid4136"
- empspacing="4" />
- </sodipodi:namedview>
- <metadata
- id="metadata7">
- <rdf:RDF>
- <cc:Work
- rdf:about="">
- <dc:format>image/svg+xml</dc:format>
- <dc:type
- rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:title></dc:title>
- </cc:Work>
- </rdf:RDF>
- </metadata>
- <g
- inkscape:label="Layer 1"
- inkscape:groupmode="layer"
- id="layer1"
- transform="translate(0,-1036.3623)">
- <circle
- r="6.9999943"
- cy="1044.3623"
- cx="8.0000057"
- id="circle4262"
- style="fill:#f9f9f9;fill-opacity:1;stroke:none;stroke-width:20;stroke-linecap:square;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
- </g>
-</svg>
diff --git a/editor/icons/source/icon_slider_joint.svg b/editor/icons/source/icon_slider_joint.svg
index 021a295186..25bccca831 100644
--- a/editor/icons/source/icon_slider_joint.svg
+++ b/editor/icons/source/icon_slider_joint.svg
@@ -14,7 +14,7 @@
viewBox="0 0 16 16"
id="svg2"
version="1.1"
- inkscape:version="0.91 r13725"
+ inkscape:version="0.92.1 r"
inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_collision_shape_2d.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90"
@@ -29,8 +29,8 @@
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="22.627417"
- inkscape:cx="3.8333359"
- inkscape:cy="8.8668138"
+ inkscape:cx="8.5719521"
+ inkscape:cy="9.4331459"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
@@ -42,8 +42,8 @@
inkscape:snap-bbox-midpoints="true"
inkscape:snap-object-midpoints="true"
inkscape:snap-center="true"
- inkscape:window-width="1920"
- inkscape:window-height="1016"
+ inkscape:window-width="1600"
+ inkscape:window-height="836"
inkscape:window-x="0"
inkscape:window-y="27"
inkscape:window-maximized="1">
@@ -59,7 +59,7 @@
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:title></dc:title>
+ <dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
@@ -69,9 +69,36 @@
id="layer1"
transform="translate(0,-1036.3622)">
<path
- style="opacity:1;fill:#fc9c9c;fill-opacity:0.99607843;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- d="m 15,1037.3622 -5,0 0,6 -5,0 0,2 5,0 0,6 5,0 0,-14 z m -7,0 -5,0 -2,0 0,4 0,10 2,0 5,0 0,-4 -5,0 0,-6 5,0 0,-4 z"
- id="rect4161"
+ inkscape:connector-curvature="0"
+ id="path840"
+ d="m 3,1051.3622 h 5 l -1,-4 z"
+ style="fill:#fc9c9c;fill-opacity:0.99607843;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ sodipodi:nodetypes="cccc" />
+ <path
+ style="fill:#fb9b9b;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;fill-opacity:1"
+ d="m 6,1048.3622 9,-9 v 3 l -8,8 z"
+ id="path842"
+ inkscape:connector-curvature="0" />
+ <path
+ inkscape:connector-curvature="0"
+ id="path844"
+ d="m 10,1040.3622 -9,9 v -3 l 8,-8 z"
+ style="fill:#fb9b9b;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
+ <path
+ sodipodi:nodetypes="cccc"
+ style="fill:#fc9c9c;fill-opacity:0.99607843;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 13,1037.3622 H 8 l 1,4 z"
+ id="path846"
inkscape:connector-curvature="0" />
+ <path
+ style="fill:none;stroke:#fb9b9b;stroke-width:2;stroke-linecap:round;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none"
+ d="M 10,1038.3622 H 5"
+ id="path850"
+ inkscape:connector-curvature="0" />
+ <path
+ inkscape:connector-curvature="0"
+ id="path852"
+ d="M 11,1050.3622 H 6"
+ style="fill:none;stroke:#fb9b9b;stroke-width:2;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
</g>
</svg>
diff --git a/editor/icons/source/icon_spatial_shader.svg b/editor/icons/source/icon_spatial_shader.svg
deleted file mode 100644
index 329354b716..0000000000
--- a/editor/icons/source/icon_spatial_shader.svg
+++ /dev/null
@@ -1,165 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!-- Created with Inkscape (http://www.inkscape.org/) -->
-
-<svg
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:cc="http://creativecommons.org/ns#"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:svg="http://www.w3.org/2000/svg"
- xmlns="http://www.w3.org/2000/svg"
- xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
- xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
- width="16"
- height="16"
- viewBox="0 0 16 16"
- id="svg2"
- version="1.1"
- inkscape:version="0.91 r13725"
- inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_collision_shape.png"
- inkscape:export-xdpi="90"
- inkscape:export-ydpi="90"
- sodipodi:docname="icon_spatial_shader.svg">
- <defs
- id="defs4">
- <clipPath
- id="clipPath4253"
- clipPathUnits="userSpaceOnUse">
- <path
- inkscape:connector-curvature="0"
- id="path4255"
- d="m 16.458984,1024.37 a 12.000027,12.000027 0 0 0 -3.564453,0.4004 12.000027,12.000027 0 0 0 -8.4863279,14.6973 12.000027,12.000027 0 0 0 14.6972659,8.4863 12.000027,12.000027 0 0 0 8.486328,-14.6973 12.000027,12.000027 0 0 0 -11.132813,-8.8867 z M 16.25,1029.8212 a 6.5451717,6.5451717 0 0 1 6.072266,4.8476 6.5451717,6.5451717 0 0 1 -4.628907,8.0157 6.5451717,6.5451717 0 0 1 -8.0156246,-4.6289 6.5451717,6.5451717 0 0 1 4.6289066,-8.0157 6.5451717,6.5451717 0 0 1 1.943359,-0.2187 z"
- style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:4;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
- </clipPath>
- <clipPath
- id="clipPath4199"
- clipPathUnits="userSpaceOnUse">
- <path
- style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- d="m 16.5,1025.8622 a 11.8125,10.499999 0 0 0 -11.8125001,10.5 11.8125,10.499999 0 0 0 11.8125001,10.5 11.8125,10.499999 0 0 0 11.8125,-10.5 11.8125,10.499999 0 0 0 -11.8125,-10.5 z m -3.375,3 a 3.375,2.9999997 0 0 1 3.375,3 3.375,2.9999997 0 0 1 -3.375,3 3.375,2.9999997 0 0 1 -3.3750001,-3 3.375,2.9999997 0 0 1 3.3750001,-3 z"
- id="path4201"
- inkscape:connector-curvature="0" />
- </clipPath>
- <clipPath
- clipPathUnits="userSpaceOnUse"
- id="clipPath4280">
- <g
- id="g4282"
- inkscape:label="Layer 1"
- transform="translate(0,1.1802001e-5)"
- style="stroke:#fc9c9c;stroke-opacity:0.99607843">
- <path
- style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000000;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;block-progression:tb;writing-mode:lr-tb;baseline-shift:baseline;text-anchor:start;white-space:normal;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#fc9c9c;fill-opacity:0.99607843;fill-rule:evenodd;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
- d="M 7.9628906,1.0019531 A 1.0001,1.0001 0 0 0 7.5527344,1.1054688 l -6,3 A 1.0001,1.0001 0 0 0 1,5 l 0,6 a 1.0001,1.0001 0 0 0 0.5527344,0.894531 l 6,3 a 1.0001,1.0001 0 0 0 0.8945312,0 l 6.0000004,-3 A 1.0001,1.0001 0 0 0 15,11 L 15,5 A 1.0001,1.0001 0 0 0 14.447266,4.1054688 l -6.0000004,-3 A 1.0001,1.0001 0 0 0 7.9628906,1.0019531 Z M 8,3.1191406 11.763672,5 8,6.8828125 4.2363281,5 8,3.1191406 Z m -5,3.5 4,2 0,3.7636714 -4,-2 0,-3.7636714 z m 10,0 0,3.7636714 -4,2 0,-3.7636714 4,-2 z"
- transform="translate(0,1036.3622)"
- id="path4284"
- inkscape:connector-curvature="0" />
- </g>
- </clipPath>
- </defs>
- <sodipodi:namedview
- id="base"
- pagecolor="#ffffff"
- bordercolor="#666666"
- borderopacity="1.0"
- inkscape:pageopacity="0.0"
- inkscape:pageshadow="2"
- inkscape:zoom="22.627417"
- inkscape:cx="7.8442401"
- inkscape:cy="13.929239"
- inkscape:document-units="px"
- inkscape:current-layer="layer1"
- showgrid="true"
- units="px"
- inkscape:snap-bbox="true"
- inkscape:bbox-paths="true"
- inkscape:bbox-nodes="true"
- inkscape:snap-bbox-edge-midpoints="true"
- inkscape:snap-bbox-midpoints="true"
- inkscape:snap-object-midpoints="true"
- inkscape:snap-center="true"
- inkscape:window-width="1920"
- inkscape:window-height="1016"
- inkscape:window-x="0"
- inkscape:window-y="27"
- inkscape:window-maximized="1"
- inkscape:object-paths="false"
- inkscape:snap-intersection-paths="false"
- inkscape:object-nodes="false"
- inkscape:snap-smooth-nodes="false"
- inkscape:snap-midpoints="true">
- <inkscape:grid
- type="xygrid"
- id="grid3336" />
- </sodipodi:namedview>
- <metadata
- id="metadata7">
- <rdf:RDF>
- <cc:Work
- rdf:about="">
- <dc:format>image/svg+xml</dc:format>
- <dc:type
- rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:title></dc:title>
- </cc:Work>
- </rdf:RDF>
- </metadata>
- <g
- inkscape:label="Layer 1"
- inkscape:groupmode="layer"
- id="layer1"
- transform="translate(0,-1036.3622)">
- <g
- id="g4271"
- clip-path="url(#clipPath4280)">
- <rect
- y="1037.3622"
- x="0"
- height="2.0000031"
- width="16"
- id="rect4159"
- style="fill:#ff7070;fill-opacity:1;stroke:none;stroke-width:4;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
- <rect
- style="fill:#ffeb70;fill-opacity:1;stroke:none;stroke-width:4;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
- id="rect4161"
- width="16"
- height="2.0000029"
- x="0"
- y="1039.3622" />
- <rect
- style="fill:#9dff70;fill-opacity:1;stroke:none;stroke-width:4;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
- id="rect4163"
- width="16"
- height="1.9999999"
- x="0"
- y="1041.3622" />
- <rect
- y="1043.3622"
- x="0"
- height="2.0000024"
- width="16"
- id="rect4165"
- style="fill:#70ffb9;fill-opacity:1;stroke:none;stroke-width:4;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
- <rect
- y="1045.3622"
- x="0"
- height="2.0000021"
- width="16"
- id="rect4167"
- style="fill:#70deff;fill-opacity:1;stroke:none;stroke-width:4;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
- <rect
- style="fill:#ff70ac;fill-opacity:1;stroke:none;stroke-width:4;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
- id="rect4169"
- width="16"
- height="1.9999987"
- x="0"
- y="1049.3622" />
- <rect
- style="fill:#9f70ff;fill-opacity:1;stroke:none;stroke-width:4;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
- id="rect4146"
- width="16"
- height="2.0000021"
- x="0"
- y="1047.3622" />
- </g>
- </g>
-</svg>
diff --git a/editor/icons/source/icon_sphere_mesh.svg b/editor/icons/source/icon_sphere_mesh.svg
new file mode 100644
index 0000000000..1264ca3984
--- /dev/null
+++ b/editor/icons/source/icon_sphere_mesh.svg
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="16"
+ height="16"
+ viewBox="0 0 16 16"
+ id="svg2"
+ version="1.1"
+ inkscape:version="0.92+devel unknown"
+ inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_node_2d.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90"
+ sodipodi:docname="icon_sphere_mesh.svg">
+ <defs
+ id="defs4" />
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="22.627416"
+ inkscape:cx="10.188774"
+ inkscape:cy="7.9201751"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="true"
+ units="px"
+ inkscape:snap-bbox="true"
+ inkscape:bbox-paths="true"
+ inkscape:bbox-nodes="true"
+ inkscape:snap-bbox-edge-midpoints="true"
+ inkscape:snap-bbox-midpoints="true"
+ inkscape:snap-object-midpoints="true"
+ inkscape:snap-center="true"
+ inkscape:window-width="1920"
+ inkscape:window-height="1016"
+ inkscape:window-x="0"
+ inkscape:window-y="27"
+ inkscape:window-maximized="1"
+ inkscape:document-rotation="0">
+ <inkscape:grid
+ type="xygrid"
+ id="grid3336"
+ empspacing="4" />
+ </sodipodi:namedview>
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(0,-1036.3622)">
+ <path
+ style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-variant-east-asian:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#ffd684;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;filter-blend-mode:normal;filter-gaussianBlur-deviation:0;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate;opacity:1"
+ d="M 8 1 C 4.1458514 1 1 4.1459 1 8 C 1 11.8542 4.1458514 15 8 15 C 11.854149 15 15 11.8542 15 8 C 15 4.1459 11.854149 1 8 1 z M 7 3.0976562 L 7 7.96875 C 5.7068959 7.8974081 4.3938983 7.6705607 3.0566406 7.2773438 C 3.3574503 5.1795086 4.9418857 3.5108322 7 3.0976562 z M 9 3.0976562 C 11.05489 3.5101849 12.637036 5.1743816 12.941406 7.2675781 C 11.636828 7.6343492 10.325593 7.8701693 9 7.9550781 L 9 3.0976562 z M 12.785156 9.3789062 C 12.276517 11.157679 10.835259 12.531968 9 12.900391 L 9 9.9492188 C 10.27916 9.876918 11.541917 9.6821761 12.785156 9.3789062 z M 3.2207031 9.3964844 C 4.4939533 9.7154019 5.7543858 9.8986297 7 9.9589844 L 7 12.900391 C 5.170884 12.533201 3.7340013 11.166534 3.2207031 9.3964844 z "
+ transform="translate(0,1036.3622)"
+ id="path4309" />
+ </g>
+</svg>
diff --git a/editor/icons/source/icon_texture.svg b/editor/icons/source/icon_texture.svg
deleted file mode 100644
index 39e88e592b..0000000000
--- a/editor/icons/source/icon_texture.svg
+++ /dev/null
@@ -1,137 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!-- Created with Inkscape (http://www.inkscape.org/) -->
-
-<svg
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:cc="http://creativecommons.org/ns#"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:svg="http://www.w3.org/2000/svg"
- xmlns="http://www.w3.org/2000/svg"
- xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
- xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
- width="16"
- height="16"
- viewBox="0 0 16 16"
- id="svg2"
- version="1.1"
- inkscape:version="0.91 r13725"
- inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_key.png"
- inkscape:export-xdpi="90"
- inkscape:export-ydpi="90"
- sodipodi:docname="icon_image_texture.svg">
- <defs
- id="defs4" />
- <sodipodi:namedview
- id="base"
- pagecolor="#ffffff"
- bordercolor="#666666"
- borderopacity="1.0"
- inkscape:pageopacity="0.0"
- inkscape:pageshadow="2"
- inkscape:zoom="32"
- inkscape:cx="9.9365814"
- inkscape:cy="6.4466253"
- inkscape:document-units="px"
- inkscape:current-layer="layer1"
- showgrid="true"
- units="px"
- inkscape:snap-bbox="true"
- inkscape:bbox-paths="true"
- inkscape:bbox-nodes="true"
- inkscape:snap-bbox-edge-midpoints="true"
- inkscape:snap-bbox-midpoints="false"
- inkscape:snap-object-midpoints="true"
- inkscape:snap-center="true"
- inkscape:window-width="1920"
- inkscape:window-height="1016"
- inkscape:window-x="0"
- inkscape:window-y="27"
- inkscape:window-maximized="1"
- inkscape:object-paths="false"
- inkscape:snap-intersection-paths="false"
- inkscape:object-nodes="false"
- inkscape:snap-smooth-nodes="false">
- <inkscape:grid
- type="xygrid"
- id="grid3336" />
- </sodipodi:namedview>
- <metadata
- id="metadata7">
- <rdf:RDF>
- <cc:Work
- rdf:about="">
- <dc:format>image/svg+xml</dc:format>
- <dc:type
- rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:title></dc:title>
- </cc:Work>
- </rdf:RDF>
- </metadata>
- <g
- inkscape:label="Layer 1"
- inkscape:groupmode="layer"
- id="layer1"
- transform="translate(0,-1036.3622)">
- <path
- style="opacity:1;fill:#e0e0e0;fill-opacity:0.99607843;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.99607843"
- d="M 2 1 A 1 1 0 0 0 1 2 L 1 14 A 1 1 0 0 0 2 15 L 14 15 A 1 1 0 0 0 15 14 L 15 2 A 1 1 0 0 0 14 1 L 2 1 z M 3 3 L 13 3 L 13 11 L 3 11 L 3 3 z "
- transform="translate(0,1036.3622)"
- id="rect4156" />
- <rect
- y="1043.3622"
- x="6"
- height="1"
- width="2"
- id="rect4197"
- style="opacity:1;fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.99607843" />
- <rect
- style="opacity:1;fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.99607843"
- id="rect4199"
- width="2"
- height="2.0000174"
- x="6"
- y="1044.3622" />
- <rect
- y="1045.3622"
- x="4"
- height="1"
- width="2"
- id="rect4201"
- style="opacity:1;fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.99607843" />
- <rect
- style="opacity:1;fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.99607843"
- id="rect4203"
- width="2"
- height="2.0000174"
- x="8"
- y="1044.3622" />
- <rect
- y="1044.3622"
- x="10"
- height="2.0000174"
- width="2"
- id="rect4205"
- style="opacity:1;fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.99607843" />
- <rect
- style="opacity:1;fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.99607843"
- id="rect4207"
- width="3"
- height="2.0000174"
- x="8"
- y="1042.3622" />
- <rect
- y="1041.3622"
- x="9"
- height="1"
- width="1"
- id="rect4217"
- style="opacity:1;fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.99607843" />
- <rect
- style="opacity:1;fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.99607843"
- id="rect4219"
- width="1"
- height="1"
- x="5"
- y="1044.3622" />
- </g>
-</svg>
diff --git a/editor/icons/source/icon_texture_rect.svg b/editor/icons/source/icon_texture_rect.svg
index 88d9b4081f..e02882812c 100644
--- a/editor/icons/source/icon_texture_rect.svg
+++ b/editor/icons/source/icon_texture_rect.svg
@@ -14,7 +14,7 @@
viewBox="0 0 16 16"
id="svg2"
version="1.1"
- inkscape:version="0.91 r13725"
+ inkscape:version="0.92.1 r"
inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_center_container.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90"
@@ -29,7 +29,7 @@
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="32"
- inkscape:cx="14.395168"
+ inkscape:cx="8.051418"
inkscape:cy="9.9171316"
inkscape:document-units="px"
inkscape:current-layer="layer1"
@@ -42,8 +42,8 @@
inkscape:snap-bbox-midpoints="true"
inkscape:snap-object-midpoints="true"
inkscape:snap-center="true"
- inkscape:window-width="1920"
- inkscape:window-height="1016"
+ inkscape:window-width="1600"
+ inkscape:window-height="836"
inkscape:window-x="0"
inkscape:window-y="27"
inkscape:window-maximized="1">
@@ -59,7 +59,7 @@
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:title></dc:title>
+ <dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
@@ -69,33 +69,12 @@
id="layer1"
transform="translate(0,-1036.3622)">
<rect
- style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- id="rect4154"
- width="1"
- height="14"
- x="1"
- y="1037.3622" />
- <rect
- y="1050.3622"
- x="1"
- height="0.9999826"
- width="14"
- id="rect4156"
- style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
- <rect
- style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- id="rect4158"
- width="14"
- height="0.9999826"
- x="1"
- y="1037.3622" />
- <rect
- y="1037.3622"
- x="14"
- height="14"
- width="1"
- id="rect4160"
- style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+ style="fill:none;fill-opacity:1;stroke:#a5efac;stroke-width:2;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ id="rect818"
+ width="12"
+ height="12"
+ x="2"
+ y="1038.3622" />
<path
inkscape:connector-curvature="0"
id="rect4197"
diff --git a/editor/icons/source/icon_timer.svg b/editor/icons/source/icon_timer.svg
index 0615ab865a..f156414686 100644
--- a/editor/icons/source/icon_timer.svg
+++ b/editor/icons/source/icon_timer.svg
@@ -14,7 +14,7 @@
viewBox="0 0 16 16"
id="svg2"
version="1.1"
- inkscape:version="0.91 r13725"
+ inkscape:version="0.92.1 r"
inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_sprite.png"
inkscape:export-xdpi="45"
inkscape:export-ydpi="45"
@@ -28,9 +28,9 @@
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
- inkscape:zoom="32"
- inkscape:cx="4.6045193"
- inkscape:cy="8.1915618"
+ inkscape:zoom="16"
+ inkscape:cx="4.3214346"
+ inkscape:cy="13.122944"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
@@ -42,8 +42,8 @@
inkscape:snap-bbox-midpoints="true"
inkscape:snap-object-midpoints="true"
inkscape:snap-center="true"
- inkscape:window-width="1920"
- inkscape:window-height="1016"
+ inkscape:window-width="1600"
+ inkscape:window-height="836"
inkscape:window-x="0"
inkscape:window-y="27"
inkscape:window-maximized="1"
@@ -62,7 +62,7 @@
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:title></dc:title>
+ <dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
@@ -72,37 +72,32 @@
id="layer1"
transform="translate(0,-1036.3622)">
<rect
- style="opacity:1;fill:#fefeff;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.99607843"
- id="rect4175"
- width="1"
- height="1"
- x="20"
- y="1042.3622" />
+ style="fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:1.85164022;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ id="rect818"
+ width="12"
+ height="2"
+ x="2"
+ y="1037.3622"
+ ry="1" />
<rect
- y="1042.3622"
- x="29"
- height="1"
- width="1"
- id="rect4177"
- style="opacity:1;fill:#fefeff;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.99607843" />
+ ry="1"
+ y="1049.3622"
+ x="2"
+ height="2"
+ width="12"
+ id="rect820"
+ style="fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:1.85164022;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<path
- style="opacity:1;fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.99607843"
- d="M 8 1 A 7.0000172 7.0000172 0 0 0 1 8 A 7.0000172 7.0000172 0 0 0 8 15 A 7.0000172 7.0000172 0 0 0 15 8 A 7.0000172 7.0000172 0 0 0 8 1 z M 8 3 A 5.0000172 5.0000172 0 0 1 13 8 A 5.0000172 5.0000172 0 0 1 8 13 A 5.0000172 5.0000172 0 0 1 3 8 A 5.0000172 5.0000172 0 0 1 8 3 z "
- transform="translate(0,1036.3622)"
- id="path4156" />
- <rect
- style="opacity:1;fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.99607843"
- id="rect4161"
- width="2"
- height="3.9999826"
- x="7"
- y="1041.3622" />
- <rect
- y="1043.3622"
- x="7"
- height="1.9999826"
- width="4"
- id="rect4163"
- style="opacity:1;fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.99607843" />
+ style="fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="m 3,1050.3622 h 10 l -3,-6 H 6 Z"
+ id="path838"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="ccccc" />
+ <path
+ style="fill:none;stroke:#e0e0e0;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="m 3,1038.3622 h 10 c 0,2 -3,4 -4,6 1,2 4,4 4,6 H 3 c 0,-2 3,-4 4,-6 -1,-2 -4,-4 -4,-6 z"
+ id="path840"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="ccccccc" />
</g>
</svg>
diff --git a/editor/icons/source/icon_tool_button.svg b/editor/icons/source/icon_tool_button.svg
index 1c5176c8c9..6fb580bc7f 100644
--- a/editor/icons/source/icon_tool_button.svg
+++ b/editor/icons/source/icon_tool_button.svg
@@ -14,7 +14,7 @@
viewBox="0 0 16 16"
id="svg2"
version="1.1"
- inkscape:version="0.91 r13725"
+ inkscape:version="0.92.1 r"
inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_button.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90"
@@ -29,8 +29,8 @@
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="32"
- inkscape:cx="8.173168"
- inkscape:cy="9.7479984"
+ inkscape:cx="7.704418"
+ inkscape:cy="7.4979984"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
@@ -42,8 +42,8 @@
inkscape:snap-bbox-midpoints="true"
inkscape:snap-object-midpoints="true"
inkscape:snap-center="true"
- inkscape:window-width="1920"
- inkscape:window-height="1016"
+ inkscape:window-width="1600"
+ inkscape:window-height="836"
inkscape:window-x="0"
inkscape:window-y="27"
inkscape:window-maximized="1">
@@ -60,7 +60,7 @@
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:title></dc:title>
+ <dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
@@ -69,26 +69,44 @@
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-1036.3622)">
- <path
- style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- d="M 1 3 L 1 11 L 15 11 L 15 3 L 1 3 z M 11 4 A 3 3 0 0 1 13.826172 6 L 11 6 A 1 1 0 0 0 10 7 A 1 1 0 0 0 11 8 L 13.824219 8 A 3 3 0 0 1 11 10 A 3 3 0 0 1 8.1757812 8 L 3 8 A 1 1 0 0 1 2 7 A 1 1 0 0 1 3 6 L 8.1738281 6 A 3 3 0 0 1 11 4 z "
- transform="translate(0,1036.3622)"
- id="rect4139" />
<rect
- transform="scale(1,-1)"
- style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- id="rect4160"
- width="14"
- height="2.0000522"
- x="1"
- y="-1049.3622" />
+ style="fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ id="rect829"
+ width="6"
+ height="4"
+ x="2"
+ y="1047.3622"
+ ry="1.5" />
<rect
- y="-1049.3622"
+ style="fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:1.71867573;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ id="rect825"
+ width="8"
+ height="2.0000174"
x="1"
- height="2.0000522"
- width="14"
- id="rect4142"
- style="opacity:1;fill:#000000;fill-opacity:0.07843138;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- transform="scale(1,-1)" />
+ y="1049.3622"
+ ry="0" />
+ <path
+ style="fill:none;stroke:#a5efac;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="m 2,1042.3622 3,2 3,-2"
+ id="path831"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:none;stroke:#a5efac;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="m 5,1039.3622 v 5"
+ id="path833"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cc" />
+ <g
+ id="layer1-7"
+ inkscape:label="Layer 1"
+ transform="translate(9,-1)"
+ style="fill:#a5efac;fill-opacity:1">
+ <path
+ id="path828"
+ d="m 2,1038.536 c -1.1978593,0.4235 -1.9990448,1.5557 -2,2.8262 9.552e-4,1.2705 0.8021407,2.4027 2,2.8262 v 6.1738 1 c 0,0.554 0.446,1 1,1 0.554,0 1,-0.446 1,-1 v -4 -3.1758 c 1.197184,-0.4232 1.998218,-1.5544 2,-2.8242 -0.00178,-1.2698 -0.802816,-2.401 -2,-2.8242 v 2.8242 c 0,0.5523 -0.447715,1 -1,1 -0.552285,0 -1,-0.4477 -1,-1 z"
+ style="fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="ccccsssccccsssc" />
+ </g>
</g>
</svg>
diff --git a/editor/icons/source/icon_tools.svg b/editor/icons/source/icon_tools.svg
index f2b8cd9343..030d38f6cf 100644
--- a/editor/icons/source/icon_tools.svg
+++ b/editor/icons/source/icon_tools.svg
@@ -14,11 +14,11 @@
viewBox="0 0 16 16"
id="svg2"
version="1.1"
- inkscape:version="0.91 r13725"
+ inkscape:version="0.92.1 r"
inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_g_d_script.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90"
- sodipodi:docname="icon_g_d_script.svg">
+ sodipodi:docname="icon_tools.svg">
<defs
id="defs4" />
<sodipodi:namedview
@@ -28,9 +28,9 @@
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
- inkscape:zoom="32"
- inkscape:cx="6.7306265"
- inkscape:cy="9.0071681"
+ inkscape:zoom="22.627417"
+ inkscape:cx="17.67723"
+ inkscape:cy="10.600994"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
@@ -42,8 +42,8 @@
inkscape:snap-bbox-midpoints="true"
inkscape:snap-object-midpoints="true"
inkscape:snap-center="true"
- inkscape:window-width="1920"
- inkscape:window-height="1016"
+ inkscape:window-width="1600"
+ inkscape:window-height="836"
inkscape:window-x="0"
inkscape:window-y="27"
inkscape:window-maximized="1">
@@ -59,7 +59,7 @@
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:title></dc:title>
+ <dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
@@ -69,9 +69,9 @@
id="layer1"
transform="translate(0,-1036.3622)">
<path
- style="opacity:1;fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:3;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- d="M 7 1 L 6.4355469 3.2578125 A 5.0000172 5.0000172 0 0 0 5.7460938 3.5371094 L 3.7578125 2.34375 L 2.34375 3.7578125 L 3.5390625 5.7519531 A 5.0000172 5.0000172 0 0 0 3.2539062 6.4375 L 1 7 L 1 9 L 3.2578125 9.5644531 A 5.0000172 5.0000172 0 0 0 3.5371094 10.251953 L 2.34375 12.242188 L 3.7578125 13.65625 L 5.7519531 12.460938 A 5.0000172 5.0000172 0 0 0 6.4375 12.746094 L 7 15 L 9 15 L 9.5644531 12.742188 A 5.0000172 5.0000172 0 0 0 10.251953 12.462891 L 12.242188 13.65625 L 13.65625 12.242188 L 12.460938 10.248047 A 5.0000172 5.0000172 0 0 0 12.746094 9.5625 L 15 9 L 15 7 L 12.742188 6.4355469 A 5.0000172 5.0000172 0 0 0 12.462891 5.7480469 L 13.65625 3.7578125 L 12.242188 2.34375 L 10.248047 3.5390625 A 5.0000172 5.0000172 0 0 0 9.5625 3.2539062 L 9 1 L 7 1 z M 8 6 A 2.0000174 2.0000174 0 0 1 10 8 A 2.0000174 2.0000174 0 0 1 8 10 A 2.0000174 2.0000174 0 0 1 6 8 A 2.0000174 2.0000174 0 0 1 8 6 z "
+ style="fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="M 4 1 L 3 3 L 4 5 L 4 9 L 2 9 L 2 12 L 2 12.5 C 2 13.885 3.115 15 4.5 15 C 5.885 15 7 13.885 7 12.5 L 7 11.5 L 7 9 L 5 9 L 5 5 L 6 3 L 5 1 L 4 1 z M 10 1.1738281 A 3 3 0 0 0 8 4 A 3 3 0 0 0 10 6.8261719 L 10 13 L 10 14 C 10 14.554 10.446 15 11 15 C 11.554 15 12 14.554 12 14 L 12 10 L 12 6.8242188 A 3 3 0 0 0 14 4 A 3 3 0 0 0 12 1.1757812 L 12 4 A 1 1 0 0 1 11 5 A 1 1 0 0 1 10 4 L 10 1.1738281 z "
transform="translate(0,1036.3622)"
- id="path4176" />
+ id="path828" />
</g>
</svg>
diff --git a/editor/icons/source/icon_tree.svg b/editor/icons/source/icon_tree.svg
index b31fd38097..0c2b20f458 100644
--- a/editor/icons/source/icon_tree.svg
+++ b/editor/icons/source/icon_tree.svg
@@ -14,7 +14,7 @@
viewBox="0 0 16 16"
id="svg2"
version="1.1"
- inkscape:version="0.91 r13725"
+ inkscape:version="0.92.1 r"
inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_sprite.png"
inkscape:export-xdpi="45"
inkscape:export-ydpi="45"
@@ -28,9 +28,9 @@
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
- inkscape:zoom="45.254834"
- inkscape:cx="10.885344"
- inkscape:cy="6.8775392"
+ inkscape:zoom="22.627417"
+ inkscape:cx="7.8708755"
+ inkscape:cy="9.6521385"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
@@ -42,8 +42,8 @@
inkscape:snap-bbox-midpoints="true"
inkscape:snap-object-midpoints="true"
inkscape:snap-center="true"
- inkscape:window-width="1920"
- inkscape:window-height="1016"
+ inkscape:window-width="1600"
+ inkscape:window-height="836"
inkscape:window-x="0"
inkscape:window-y="27"
inkscape:window-maximized="1"
@@ -62,7 +62,7 @@
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:title></dc:title>
+ <dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
@@ -85,45 +85,48 @@
width="1"
id="rect4177"
style="opacity:1;fill:#fefeff;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.99607843" />
- <path
- style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.99607843"
- d="M 3 1 A 2 2 0 0 0 1.5859375 1.5859375 A 2 2 0 0 0 1 3 L 1 13 A 2 2 0 0 0 1.5859375 14.414062 A 2 2 0 0 0 3 15 L 13 15 A 2 2 0 0 0 15 13 L 15 3 A 2 2 0 0 0 13 1 L 3 1 z M 3 2 L 13 2 A 1.0000174 1.0000174 0 0 1 14 3 L 14 13 A 1.0000174 1.0000174 0 0 1 13 14 L 3 14 A 1.0000174 1.0000174 0 0 1 2 13 L 2 3 A 1.0000174 1.0000174 0 0 1 3 2 z "
- transform="translate(0,1036.3622)"
- id="rect4179" />
<rect
- style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.99607843"
- id="rect4173"
- width="1"
- height="5.0000172"
- x="4"
- y="1040.3622" />
+ style="fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ id="rect821"
+ width="14"
+ height="2"
+ x="1"
+ y="1037.3622" />
<rect
y="1041.3622"
- x="4"
- height="1.0000174"
- width="8"
- id="rect4176"
- style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.99607843" />
+ x="6"
+ height="2"
+ width="9"
+ id="rect823"
+ style="fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:1.60356748;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<rect
- style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.99607843"
- id="rect4178"
- width="7"
- height="1.0000174"
- x="5"
- y="1044.3622" />
- <rect
- y="1045.3622"
+ style="fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:1.51185787;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ id="rect825"
+ width="8"
+ height="2"
x="7"
- height="3.0000174"
- width="1"
- id="rect4180"
- style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.99607843" />
+ y="1045.3622" />
<rect
- style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.99607843"
- id="rect4191"
- width="5"
- height="1"
+ y="1049.3622"
x="7"
- y="1047.3622" />
+ height="2"
+ width="8"
+ id="rect827"
+ style="fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:1.51185787;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+ <path
+ style="fill:none;stroke:#a5efac;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none"
+ d="m 2,1038.3622 v 4 h 4"
+ id="path829"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:none;stroke:#a5efac;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="m 6,1042.3622 v 4 h 3"
+ id="path831"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:none;stroke:#a5efac;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none"
+ d="m 2,1040.3622 v 10 h 7"
+ id="path833"
+ inkscape:connector-curvature="0" />
</g>
</svg>
diff --git a/editor/icons/source/icon_v_button_array.svg b/editor/icons/source/icon_v_button_array.svg
index aded4b401b..08fc7d7614 100644
--- a/editor/icons/source/icon_v_button_array.svg
+++ b/editor/icons/source/icon_v_button_array.svg
@@ -14,7 +14,7 @@
viewBox="0 0 16 16"
id="svg2"
version="1.1"
- inkscape:version="0.91 r13725"
+ inkscape:version="0.92.1 r"
inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_button.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90"
@@ -28,9 +28,9 @@
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
- inkscape:zoom="32"
- inkscape:cx="5.9547041"
- inkscape:cy="8.9802416"
+ inkscape:zoom="22.627417"
+ inkscape:cx="8.7528394"
+ inkscape:cy="11.065221"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
@@ -42,8 +42,8 @@
inkscape:snap-bbox-midpoints="true"
inkscape:snap-object-midpoints="true"
inkscape:snap-center="true"
- inkscape:window-width="1920"
- inkscape:window-height="1016"
+ inkscape:window-width="1600"
+ inkscape:window-height="836"
inkscape:window-x="0"
inkscape:window-y="27"
inkscape:window-maximized="1"
@@ -63,7 +63,7 @@
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:title></dc:title>
+ <dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
@@ -72,29 +72,20 @@
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-1036.3622)">
- <rect
- style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- id="rect4156"
- width="14"
- height="6.0000172"
- x="1"
- y="1037.3622" />
- <rect
- y="1042.3622"
- x="1"
- height="0.99996543"
- width="14"
- id="rect4161"
- style="opacity:1;fill:#98dc9f;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+ <g
+ id="layer1-7"
+ inkscape:label="Layer 1"
+ transform="translate(11.5,-2.9999826)"
+ style="fill:#a5efac;fill-opacity:1" />
<path
- style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- d="M 1 9 L 1 15 L 3 13 L 5 15 L 7 13 L 9 15 L 11 13 L 13 15 L 15 13 L 15 9 L 1 9 z "
+ style="fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="M 7 1 L 7 3.1328125 L 5.5546875 2.1679688 L 4.4453125 3.8320312 L 7.4453125 5.8320312 C 7.7812145 6.0559312 8.2187855 6.0559313 8.5546875 5.8320312 L 11.554688 3.8320312 L 10.445312 2.1679688 L 9 3.1328125 L 9 1 L 7 1 z M 6.5 7 C 5.669 7 5 7.669 5 8.5 L 5 9 L 4 9 L 4 11 L 6 11 L 6 9 L 10 9 L 10 11 L 12 11 L 12 9 L 11 9 L 11 8.5 C 11 7.669 10.331 7 9.5 7 L 6.5 7 z "
transform="translate(0,1036.3622)"
- id="rect4157" />
+ id="rect829-9" />
<path
- style="opacity:1;fill:#98dc9f;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- d="M 1 14 L 1 15 L 2 14 L 1 14 z M 4 14 L 5 15 L 6 14 L 4 14 z M 8 14 L 9 15 L 10 14 L 8 14 z M 12 14 L 13 15 L 14 14 L 12 14 z "
- transform="translate(0,1036.3622)"
- id="rect4159" />
+ style="fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="m 7,1046.3622 v 2 H 5 v 2 h 2 v 2 h 2 v -2 h 2 v -2 H 9 v -2 z"
+ id="rect836"
+ inkscape:connector-curvature="0" />
</g>
</svg>
diff --git a/editor/icons/source/icon_v_scroll_bar.svg b/editor/icons/source/icon_v_scroll_bar.svg
index 659dc39b0b..8ad6baa5b3 100644
--- a/editor/icons/source/icon_v_scroll_bar.svg
+++ b/editor/icons/source/icon_v_scroll_bar.svg
@@ -14,7 +14,7 @@
viewBox="0 0 16 16"
id="svg2"
version="1.1"
- inkscape:version="0.91 r13725"
+ inkscape:version="0.92.1 r"
inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_center_container.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90"
@@ -29,7 +29,7 @@
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="32"
- inkscape:cx="10.543346"
+ inkscape:cx="4.199596"
inkscape:cy="9.3134214"
inkscape:document-units="px"
inkscape:current-layer="layer1"
@@ -42,8 +42,8 @@
inkscape:snap-bbox-midpoints="true"
inkscape:snap-object-midpoints="true"
inkscape:snap-center="true"
- inkscape:window-width="1920"
- inkscape:window-height="1016"
+ inkscape:window-width="1600"
+ inkscape:window-height="836"
inkscape:window-x="0"
inkscape:window-y="27"
inkscape:window-maximized="1"
@@ -63,7 +63,7 @@
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:title></dc:title>
+ <dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
@@ -73,26 +73,9 @@
id="layer1"
transform="translate(0,-1036.3622)">
<path
- style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- d="m 13,1039.3622 c 0,-1.1046 -0.89543,-2 -2,-2 l -6,0 c -1.104569,0 -2,0.8954 -2,2 l 0,10 c 0,1.1046 0.895431,2 2,2 l 6,0 c 1.10457,0 2,-0.8954 2,-2 z m -2,0 0,10 -6,0 0,-10 z"
- id="rect4140"
- inkscape:connector-curvature="0"
- sodipodi:nodetypes="sssssssssccccc" />
- <rect
- style="opacity:1;fill:none;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.99607843"
- id="rect4181"
- width="4"
- height="4"
- x="1042.3622"
- y="-8"
- transform="matrix(0,1,-1,0,0,0)" />
- <rect
- style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.99607843"
- id="rect4187"
- width="4"
- height="4"
- x="1040.3622"
- y="-10"
- transform="matrix(0,1,-1,0,0,0)" />
+ style="fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="M 5 1 C 3.8919904 1 3 1.8919904 3 3 L 3 13 C 3 14.10801 3.8919904 15 5 15 L 11 15 C 12.10801 15 13 14.10801 13 13 L 13 3 C 13 1.8919904 12.10801 1 11 1 L 5 1 z M 7.9882812 2 A 1.0001 1.0001 0 0 1 8.5546875 2.1679688 L 11.554688 4.1679688 A 1.0001 1.0001 0 1 1 10.445312 5.8320312 L 8 4.203125 L 5.5546875 5.8320312 A 1.0001 1.0001 0 1 1 4.4453125 4.1679688 L 7.4453125 2.1679688 A 1.0001 1.0001 0 0 1 7.9882812 2 z M 4.9902344 9.9921875 A 1.0001 1.0001 0 0 1 5.5546875 10.167969 L 8 11.798828 L 10.445312 10.167969 A 1.0001 1.0001 0 1 1 11.554688 11.832031 L 8.5546875 13.832031 A 1.0001 1.0001 0 0 1 7.4453125 13.832031 L 4.4453125 11.832031 A 1.0001 1.0001 0 0 1 4.9902344 9.9921875 z "
+ transform="translate(0,1036.3622)"
+ id="rect825" />
</g>
</svg>
diff --git a/editor/icons/source/icon_v_slider.svg b/editor/icons/source/icon_v_slider.svg
index 74b59cfce5..e13c008d3a 100644
--- a/editor/icons/source/icon_v_slider.svg
+++ b/editor/icons/source/icon_v_slider.svg
@@ -14,7 +14,7 @@
viewBox="0 0 16 16"
id="svg2"
version="1.1"
- inkscape:version="0.91 r13725"
+ inkscape:version="0.92.1 r"
inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_center_container.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90"
@@ -29,8 +29,8 @@
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="32"
- inkscape:cx="9.3533577"
- inkscape:cy="8.3875011"
+ inkscape:cx="2.2553429"
+ inkscape:cy="8.5533887"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
@@ -42,8 +42,8 @@
inkscape:snap-bbox-midpoints="true"
inkscape:snap-object-midpoints="true"
inkscape:snap-center="true"
- inkscape:window-width="1920"
- inkscape:window-height="1016"
+ inkscape:window-width="1600"
+ inkscape:window-height="836"
inkscape:window-x="0"
inkscape:window-y="27"
inkscape:window-maximized="1"
@@ -63,7 +63,7 @@
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:title></dc:title>
+ <dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
@@ -73,15 +73,39 @@
id="layer1"
transform="translate(0,-1036.3622)">
<path
- style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- d="m 9,1038.3622 a 1,1 0 0 0 -1,-1 1,1 0 0 0 -1,1 l 0,3.1738 a 3,3 0 0 1 1,-0.1738 3,3 0 0 1 1,0.1758 l 0,-3.1758 z m 0,8.8262 a 3,3 0 0 1 -1,0.1738 3,3 0 0 1 -1,-0.1758 l 0,3.1758 a 1,1 0 0 0 1,1 1,1 0 0 0 1,-1 l 0,-3.1738 z"
- id="rect4157"
+ style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#a5efac;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
+ d="m 5.99995,1050.3623 a 1.0001,1.0001 0 1 1 -2,0 v -2.1308 a 4,4 0 0 0 1,0.1308 4,4 0 0 0 1,-0.1328 z m 0,-9.8691 a 4,4 0 0 0 -1,-0.1309 4,4 0 0 0 -1,0.1329 v -2.1329 a 1.0001,1.0001 0 1 1 2,0 z"
+ id="path817"
inkscape:connector-curvature="0" />
<circle
- style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.99607843"
- id="path4167"
- cx="8"
- cy="1044.3622"
- r="2" />
+ style="fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:4;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ id="path824"
+ cx="-1039.3623"
+ cy="-4.9999676"
+ r="2"
+ transform="matrix(0,-1,-1,0,0,0)" />
+ <path
+ style="fill:none;stroke:#a5efac;stroke-width:2;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="m 11.99995,1038.3623 h -2"
+ id="path835"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cc" />
+ <path
+ style="fill:none;stroke:#a5efac;stroke-width:2;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="m 10.99995,1044.3623 v 0"
+ id="path837"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cc" />
+ <path
+ style="fill:none;stroke:#a5efac;stroke-width:2;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="m 11.99995,1050.3623 h -2"
+ id="path839"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cc" />
+ <path
+ inkscape:connector-curvature="0"
+ style="fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="m 5.99995,1049.3623 h -2 v -6.1308 a 4,4 0 0 0 1,0.1308 4,4 0 0 0 1,-0.1328 z"
+ id="rect841" />
</g>
</svg>
diff --git a/editor/icons/source/icon_variant.svg b/editor/icons/source/icon_variant.svg
new file mode 100644
index 0000000000..d966190ab0
--- /dev/null
+++ b/editor/icons/source/icon_variant.svg
@@ -0,0 +1,146 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="16"
+ height="16"
+ viewBox="0 0 16 16"
+ id="svg2"
+ version="1.1"
+ inkscape:version="0.92+devel unknown"
+ inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_add_track.png"
+ inkscape:export-xdpi="45"
+ inkscape:export-ydpi="45"
+ sodipodi:docname="icon_variant.svg">
+ <defs
+ id="defs4" />
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="22.627418"
+ inkscape:cx="12.635414"
+ inkscape:cy="11.860443"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="true"
+ units="px"
+ inkscape:snap-bbox="true"
+ inkscape:bbox-paths="true"
+ inkscape:bbox-nodes="true"
+ inkscape:snap-bbox-edge-midpoints="true"
+ inkscape:snap-bbox-midpoints="false"
+ inkscape:snap-object-midpoints="true"
+ inkscape:snap-center="true"
+ inkscape:window-width="1920"
+ inkscape:window-height="1016"
+ inkscape:window-x="0"
+ inkscape:window-y="27"
+ inkscape:window-maximized="1"
+ inkscape:snap-midpoints="true"
+ inkscape:snap-smooth-nodes="true"
+ inkscape:object-nodes="true"
+ inkscape:document-rotation="0">
+ <inkscape:grid
+ type="xygrid"
+ id="grid3336" />
+ </sodipodi:namedview>
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(0,-1036.3622)">
+ <g
+ transform="translate(0,-3)"
+ id="layer1-5"
+ inkscape:label="Layer 1"
+ style="fill:#e0e0e0;fill-opacity:1">
+ <rect
+ style="fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ id="rect4320"
+ width="2"
+ height="5.9999666"
+ x="3"
+ y="1044.3622" />
+ <rect
+ style="fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ id="rect4324"
+ width="2"
+ height="5.9999843"
+ x="6"
+ y="1044.3622" />
+ <rect
+ y="1044.3622"
+ x="3"
+ height="2.0000174"
+ width="1"
+ id="rect4326"
+ style="fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+ <path
+ style="fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="m 3,1044.3622 a 3,3 0 0 0 -3,3 h 2 a 1.0000174,1.0000174 0 0 1 1,-1 z"
+ id="path4328"
+ inkscape:connector-curvature="0" />
+ <path
+ id="path4330"
+ d="m 14,1050.3622 a 3,3 0 0 1 -3,-3 h 2 a 1.0000174,1.0000174 0 0 0 1,1 z"
+ style="fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ inkscape:connector-curvature="0" />
+ <rect
+ transform="scale(1,-1)"
+ y="-1052.3622"
+ x="14"
+ height="7.9999843"
+ width="2"
+ id="rect4334"
+ style="fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+ <rect
+ transform="scale(1,-1)"
+ y="-1047.3622"
+ x="11"
+ height="2.9999826"
+ width="2"
+ id="rect4338"
+ style="fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+ <path
+ inkscape:connector-curvature="0"
+ id="path4340"
+ d="m 3,1050.3622 a 3,3 0 0 1 -3,-3 h 2 a 1.0000174,1.0000174 0 0 0 1,1 z"
+ style="fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+ <path
+ inkscape:connector-curvature="0"
+ id="path4342"
+ d="m 8,1044.3622 a 3,3 0 0 1 3,3 H 9 a 1.0000174,1.0000174 0 0 0 -1,-1 z"
+ style="fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+ <rect
+ y="1047.3622"
+ x="9"
+ height="3.0000174"
+ width="2"
+ id="rect4344"
+ style="fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+ </g>
+ </g>
+</svg>
diff --git a/editor/icons/source/icon_video_player.svg b/editor/icons/source/icon_video_player.svg
index bfb499518b..a049791930 100644
--- a/editor/icons/source/icon_video_player.svg
+++ b/editor/icons/source/icon_video_player.svg
@@ -14,7 +14,7 @@
viewBox="0 0 16 16"
id="svg2"
version="1.1"
- inkscape:version="0.91 r13725"
+ inkscape:version="0.92.1 r"
inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_sprite.png"
inkscape:export-xdpi="45"
inkscape:export-ydpi="45"
@@ -28,9 +28,9 @@
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
- inkscape:zoom="16"
- inkscape:cx="4.9323208"
- inkscape:cy="11.020342"
+ inkscape:zoom="22.627417"
+ inkscape:cx="6.7289895"
+ inkscape:cy="10.226546"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
@@ -42,8 +42,8 @@
inkscape:snap-bbox-midpoints="true"
inkscape:snap-object-midpoints="true"
inkscape:snap-center="true"
- inkscape:window-width="1920"
- inkscape:window-height="1016"
+ inkscape:window-width="1600"
+ inkscape:window-height="836"
inkscape:window-x="0"
inkscape:window-y="27"
inkscape:window-maximized="1"
@@ -62,7 +62,7 @@
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:title></dc:title>
+ <dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
@@ -72,29 +72,26 @@
id="layer1"
transform="translate(0,-1036.3622)">
<rect
- style="opacity:1;fill:#fefeff;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.99607843"
- id="rect4175"
- width="1"
- height="1"
- x="20"
- y="1042.3622" />
- <rect
- y="1042.3622"
- x="29"
- height="1"
- width="1"
- id="rect4177"
- style="opacity:1;fill:#fefeff;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.99607843" />
- <path
- style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.99607843"
- d="M 3 1 A 2 2 0 0 0 1.5859375 1.5859375 A 2 2 0 0 0 1 3 L 1 13 A 2 2 0 0 0 1.5859375 14.414062 A 2 2 0 0 0 3 15 L 13 15 A 2 2 0 0 0 15 13 L 15 3 A 2 2 0 0 0 13 1 L 3 1 z M 3 2 L 13 2 A 1.0000174 1.0000174 0 0 1 14 3 L 14 13 A 1.0000174 1.0000174 0 0 1 13 14 L 3 14 A 1.0000174 1.0000174 0 0 1 2 13 L 2 3 A 1.0000174 1.0000174 0 0 1 3 2 z "
- transform="translate(0,1036.3622)"
- id="rect4179" />
+ style="fill:none;fill-opacity:1;stroke:#a5efac;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ id="rect819"
+ width="12"
+ height="12"
+ x="2"
+ y="1038.3622"
+ ry="1.0000174" />
<path
style="fill:#a5efac;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
- d="m 6,1047.3622 0,-6 5,3 z"
+ d="m 6,1045.3622 v -4 l 4,2 z"
id="path4180"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cccc" />
+ <rect
+ style="fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ id="rect821"
+ width="10"
+ height="2"
+ x="3"
+ y="1047.3622"
+ ry="0" />
</g>
</svg>
diff --git a/editor/icons/source/icon_visual_script.svg b/editor/icons/source/icon_visual_script.svg
index be4b47ca54..d82cb36cb5 100644
--- a/editor/icons/source/icon_visual_script.svg
+++ b/editor/icons/source/icon_visual_script.svg
@@ -14,7 +14,7 @@
viewBox="0 0 16 16"
id="svg2"
version="1.1"
- inkscape:version="0.91 r13725"
+ inkscape:version="0.92.1 r"
inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_canvas_item_shader_graph.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90"
@@ -28,9 +28,9 @@
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
- inkscape:zoom="15.999999"
- inkscape:cx="2.7930637"
- inkscape:cy="10.792256"
+ inkscape:zoom="22.627416"
+ inkscape:cx="9.8155367"
+ inkscape:cy="10.356948"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
@@ -42,8 +42,8 @@
inkscape:snap-bbox-midpoints="true"
inkscape:snap-object-midpoints="true"
inkscape:snap-center="true"
- inkscape:window-width="1920"
- inkscape:window-height="1016"
+ inkscape:window-width="1600"
+ inkscape:window-height="836"
inkscape:window-x="0"
inkscape:window-y="27"
inkscape:window-maximized="1"
@@ -61,7 +61,7 @@
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:title></dc:title>
+ <dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
@@ -70,11 +70,6 @@
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-1036.3622)">
- <path
- style="opacity:1;fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- d="M 3 1 A 2 2 0 0 0 1 3 A 2 2 0 0 0 2 4.7304688 L 2 11.271484 A 2 2 0 0 0 1 13 A 2 2 0 0 0 3 15 A 2 2 0 0 0 5 13 A 2 2 0 0 0 4 11.269531 L 4 5.4140625 L 6.2929688 7.7070312 L 7.7070312 6.2929688 L 5.4140625 4 L 11.271484 4 A 2 2 0 0 0 13 5 A 2 2 0 0 0 15 3 A 2 2 0 0 0 13 1 A 2 2 0 0 0 11.269531 2 L 4.7285156 2 A 2 2 0 0 0 3 1 z "
- transform="translate(0,1036.3622)"
- id="path4198" />
<ellipse
r="2"
style="opacity:1;fill:#6e6e6e;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
@@ -82,10 +77,9 @@
cx="3"
cy="1039.3622" />
<path
- style="fill:none;fill-rule:evenodd;stroke:#e0e0e0;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;fill-opacity:1"
- d="m 11,1050.3622 3,-3 -3,-3"
- id="path3378"
- inkscape:connector-curvature="0"
- sodipodi:nodetypes="ccc" />
+ style="opacity:1;fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:3;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ d="M 7 1 L 6.4355469 3.2578125 A 5.0000172 5.0000172 0 0 0 5.7460938 3.5371094 L 3.7578125 2.34375 L 2.34375 3.7578125 L 3.5390625 5.7519531 A 5.0000172 5.0000172 0 0 0 3.2539062 6.4375 L 1 7 L 1 9 L 6.2714844 9 A 2.0000174 2.0000174 0 0 1 6 8 A 2.0000174 2.0000174 0 0 1 8 6 A 2.0000174 2.0000174 0 0 1 10 8 A 2.0000174 2.0000174 0 0 1 9.7304688 9 L 15 9 L 15 7 L 12.742188 6.4355469 A 5.0000172 5.0000172 0 0 0 12.462891 5.7480469 L 13.65625 3.7578125 L 12.242188 2.34375 L 10.248047 3.5390625 A 5.0000172 5.0000172 0 0 0 9.5625 3.2539062 L 9 1 L 7 1 z M 3 10 L 3 16 L 5 16 A 3 3 0 0 0 8 13 L 8 10 L 6 10 L 6 13 A 1.0000174 1.0000174 0 0 1 5 14 L 5 10 L 3 10 z M 11 10 A 2 2 0 0 0 9.2675781 11 A 2 2 0 0 0 9.2675781 13 A 2 2 0 0 0 11 14 L 9 14 L 9 16 L 11 16 A 2 2 0 0 0 12.732422 15 A 2 2 0 0 0 12.732422 13 A 2 2 0 0 0 11 12 L 13 12 L 13 10 L 11 10 z "
+ transform="translate(0,1036.3622)"
+ id="path4176" />
</g>
</svg>
diff --git a/editor/icons/source/icon_world_environment.svg b/editor/icons/source/icon_world_environment.svg
index 912e348c81..33e7f86137 100644
--- a/editor/icons/source/icon_world_environment.svg
+++ b/editor/icons/source/icon_world_environment.svg
@@ -14,7 +14,7 @@
viewBox="0 0 16 16"
id="svg2"
version="1.1"
- inkscape:version="0.91 r13725"
+ inkscape:version="0.92.1 r"
inkscape:export-filename="/home/djrm/icon_node_2d.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90"
@@ -28,9 +28,9 @@
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
- inkscape:zoom="31.999999"
- inkscape:cx="2.4346197"
- inkscape:cy="8.8876091"
+ inkscape:zoom="22.627416"
+ inkscape:cx="13.590088"
+ inkscape:cy="8.7617352"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
@@ -42,8 +42,8 @@
inkscape:snap-bbox-midpoints="true"
inkscape:snap-object-midpoints="true"
inkscape:snap-center="true"
- inkscape:window-width="1920"
- inkscape:window-height="1016"
+ inkscape:window-width="1600"
+ inkscape:window-height="836"
inkscape:window-x="0"
inkscape:window-y="27"
inkscape:window-maximized="1"
@@ -64,7 +64,7 @@
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:title></dc:title>
+ <dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
@@ -73,36 +73,29 @@
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-1036.3622)">
+ <circle
+ style="fill:none;fill-opacity:1;stroke:#fc9c9c;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.99607843"
+ id="path814"
+ cx="8"
+ cy="1044.3622"
+ r="6" />
<path
- style="opacity:1;fill:#fc9c9c;fill-opacity:0.99607843;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.99607843"
- d="M 8 1 A 7 7 0 0 0 1 8 A 7 7 0 0 0 8 15 A 7 7 0 0 0 15 8 A 7 7 0 0 0 8 1 z M 8 2 A 6 6 0 0 1 14 8 A 6 6 0 0 1 8 14 A 6 6 0 0 1 2 8 A 6 6 0 0 1 8 2 z "
- transform="translate(0,1036.3622)"
- id="path4158" />
- <rect
- style="opacity:1;fill:#fc9c9c;fill-opacity:0.99607843;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.99607843"
- id="rect4163"
- width="12"
- height="1"
- x="2"
- y="1041.3622" />
- <rect
- y="1046.3622"
- x="2"
- height="1"
- width="12"
- id="rect4165"
- style="opacity:1;fill:#fc9c9c;fill-opacity:0.99607843;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.99607843" />
+ style="fill:none;stroke:#fc9c9c;stroke-width:1.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.99607843"
+ d="m 2,1044.3622 c 4.5932382,1.582 8.398513,1.0627 12,0"
+ id="path816"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cc" />
<path
- style="fill:none;fill-rule:evenodd;stroke:#fc9c9c;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.99607843"
- d="m 8,1038.3622 c 0,0 -3.5,2 -3.5,6 0,4 3.5,6 3.5,6"
- id="path4167"
+ sodipodi:nodetypes="cc"
inkscape:connector-curvature="0"
- sodipodi:nodetypes="czc" />
+ id="path820"
+ d="m 8,1038.3622 c -3,4 -3,8 0,12"
+ style="fill:none;stroke:#fc9c9c;stroke-width:1.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.99607843" />
<path
- sodipodi:nodetypes="czc"
+ style="fill:none;stroke:#fc9c9c;stroke-width:1.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.99607843"
+ d="m 8,1038.3622 c 3,4 3,8 0,12"
+ id="path822"
inkscape:connector-curvature="0"
- id="path4169"
- d="m 8,1038.3622 c 0,0 3.5,2 3.5,6 0,4 -3.5,6 -3.5,6"
- style="fill:none;fill-rule:evenodd;stroke:#fc9c9c;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.99607843" />
+ sodipodi:nodetypes="cc" />
</g>
</svg>
diff --git a/editor/import/editor_import_collada.cpp b/editor/import/editor_import_collada.cpp
index e0a2ea624e..3626c6be59 100644
--- a/editor/import/editor_import_collada.cpp
+++ b/editor/import/editor_import_collada.cpp
@@ -554,10 +554,10 @@ static void _generate_tangents_and_binormals(const PoolVector<int> &p_indices, c
tangent = Vector3();
} else {
tangent = Vector3((t2 * x1 - t1 * x2) * r, (t2 * y1 - t1 * y2) * r,
- (t2 * z1 - t1 * z2) * r)
+ (t2 * z1 - t1 * z2) * r)
.normalized();
binormal = Vector3((s1 * x2 - s2 * x1) * r, (s1 * y2 - s2 * y1) * r,
- (s1 * z2 - s2 * z1) * r)
+ (s1 * z2 - s2 * z1) * r)
.normalized();
}
@@ -867,7 +867,7 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me
int normal_pos = (normal_src->stride ? normal_src->stride : 3) * p.indices[src + normal_ofs];
ERR_FAIL_INDEX_V(normal_pos, normal_src->array.size(), ERR_INVALID_DATA);
vertex.normal = Vector3(normal_src->array[normal_pos + 0], normal_src->array[normal_pos + 1], normal_src->array[normal_pos + 2]);
- vertex.normal = vertex.normal.snapped(0.001);
+ vertex.normal.snap(Vector3(0.001, 0.001, 0.001));
if (tangent_src && binormal_src) {
@@ -908,12 +908,18 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me
#ifndef NO_UP_AXIS_SWAP
if (collada.state.up_axis == Vector3::AXIS_Z) {
+ Vector3 bn = vertex.normal.cross(vertex.tangent.normal) * vertex.tangent.d;
+
SWAP(vertex.vertex.z, vertex.vertex.y);
vertex.vertex.z = -vertex.vertex.z;
SWAP(vertex.normal.z, vertex.normal.y);
vertex.normal.z = -vertex.normal.z;
SWAP(vertex.tangent.normal.z, vertex.tangent.normal.y);
vertex.tangent.normal.z = -vertex.tangent.normal.z;
+ SWAP(bn.z, bn.y);
+ bn.z = -bn.z;
+
+ vertex.tangent.d = vertex.normal.cross(vertex.tangent.normal).dot(bn) > 0 ? 1 : -1;
}
#endif
diff --git a/editor/import/resource_importer_obj.cpp b/editor/import/resource_importer_obj.cpp
index 1c5aa95ff1..8f86e64cf2 100644
--- a/editor/import/resource_importer_obj.cpp
+++ b/editor/import/resource_importer_obj.cpp
@@ -31,82 +31,206 @@
#include "io/resource_saver.h"
#include "os/file_access.h"
+#include "scene/3d/mesh_instance.h"
+#include "scene/3d/spatial.h"
#include "scene/resources/mesh.h"
#include "scene/resources/surface_tool.h"
-String ResourceImporterOBJ::get_importer_name() const {
+uint32_t EditorOBJImporter::get_import_flags() const {
- return "obj_mesh";
+ return IMPORT_SCENE;
}
+void EditorOBJImporter::get_extensions(List<String> *r_extensions) const {
-String ResourceImporterOBJ::get_visible_name() const {
-
- return "OBJ As Mesh";
+ r_extensions->push_back("obj");
}
-void ResourceImporterOBJ::get_recognized_extensions(List<String> *p_extensions) const {
- p_extensions->push_back("obj");
-}
-String ResourceImporterOBJ::get_save_extension() const {
- return "mesh";
-}
+Error EditorOBJImporter::_parse_material_library(const String &p_path, Map<String, Ref<SpatialMaterial> > &material_map, List<String> *r_missing_deps) {
-String ResourceImporterOBJ::get_resource_type() const {
+ FileAccessRef f = FileAccess::open(p_path, FileAccess::READ);
+ ERR_FAIL_COND_V(!f, ERR_CANT_OPEN);
- return "ArrayMesh";
-}
+ Ref<SpatialMaterial> current;
+ String current_name;
+ String base_path = p_path.get_base_dir();
+ while (true) {
-bool ResourceImporterOBJ::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const {
+ String l = f->get_line().strip_edges();
- return true;
-}
+ if (l.begins_with("newmtl ")) {
+ //vertex
-int ResourceImporterOBJ::get_preset_count() const {
- return 0;
-}
-String ResourceImporterOBJ::get_preset_name(int p_idx) const {
+ current_name = l.replace("newmtl", "").strip_edges();
+ current.instance();
+ material_map[current_name] = current;
+ } else if (l.begins_with("Ka ")) {
+ //uv
+ print_line("Warning: Ambient light for material '" + current_name + "' is ignored in PBR");
- return String();
-}
+ } else if (l.begins_with("Kd ")) {
+ //normal
+ ERR_FAIL_COND_V(current.is_null(), ERR_FILE_CORRUPT);
+ Vector<String> v = l.split(" ", false);
+ ERR_FAIL_COND_V(v.size() < 4, ERR_INVALID_DATA);
+ Color c = current->get_albedo();
+ c.r = v[1].to_float();
+ c.g = v[2].to_float();
+ c.b = v[3].to_float();
+ current->set_albedo(c);
+ } else if (l.begins_with("Ks ")) {
+ //normal
+ ERR_FAIL_COND_V(current.is_null(), ERR_FILE_CORRUPT);
+ Vector<String> v = l.split(" ", false);
+ ERR_FAIL_COND_V(v.size() < 4, ERR_INVALID_DATA);
+ float r = v[1].to_float();
+ float g = v[2].to_float();
+ float b = v[3].to_float();
+ float metalness = MAX(r, MAX(g, b));
+ current->set_metallic(metalness);
+ } else if (l.begins_with("Ns ")) {
+ //normal
+ ERR_FAIL_COND_V(current.is_null(), ERR_FILE_CORRUPT);
+ Vector<String> v = l.split(" ", false);
+ ERR_FAIL_COND_V(v.size() != 2, ERR_INVALID_DATA);
+ float s = v[1].to_float();
+ current->set_metallic((1000.0 - s) / 1000.0);
+ } else if (l.begins_with("d ")) {
+ //normal
+ ERR_FAIL_COND_V(current.is_null(), ERR_FILE_CORRUPT);
+ Vector<String> v = l.split(" ", false);
+ ERR_FAIL_COND_V(v.size() != 2, ERR_INVALID_DATA);
+ float d = v[1].to_float();
+ Color c = current->get_albedo();
+ c.a = d;
+ current->set_albedo(c);
+ if (c.a < 0.99) {
+ current->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
+ }
+ } else if (l.begins_with("Tr ")) {
+ //normal
+ ERR_FAIL_COND_V(current.is_null(), ERR_FILE_CORRUPT);
+ Vector<String> v = l.split(" ", false);
+ ERR_FAIL_COND_V(v.size() != 2, ERR_INVALID_DATA);
+ float d = v[1].to_float();
+ Color c = current->get_albedo();
+ c.a = 1.0 - d;
+ current->set_albedo(c);
+ if (c.a < 0.99) {
+ current->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
+ }
+
+ } else if (l.begins_with("map_Ka ")) {
+ //uv
+ print_line("Warning: Ambient light texture for material '" + current_name + "' is ignored in PBR");
+
+ } else if (l.begins_with("map_Kd ")) {
+ //normal
+ ERR_FAIL_COND_V(current.is_null(), ERR_FILE_CORRUPT);
+
+ String p = l.replace("map_Kd", "").replace("\\", "/").strip_edges();
+ String path = base_path.plus_file(p);
+
+ Ref<Texture> texture = ResourceLoader::load(path);
+
+ if (texture.is_valid()) {
+ current->set_texture(SpatialMaterial::TEXTURE_ALBEDO, texture);
+ } else {
+ r_missing_deps->push_back(path);
+ }
+
+ } else if (l.begins_with("map_Ks ")) {
+ //normal
+ ERR_FAIL_COND_V(current.is_null(), ERR_FILE_CORRUPT);
+
+ String p = l.replace("map_Ks", "").replace("\\", "/").strip_edges();
+ String path = base_path.plus_file(p);
+
+ Ref<Texture> texture = ResourceLoader::load(path);
+
+ if (texture.is_valid()) {
+ current->set_texture(SpatialMaterial::TEXTURE_METALLIC, texture);
+ } else {
+ r_missing_deps->push_back(path);
+ }
+
+ } else if (l.begins_with("map_Ns ")) {
+ //normal
+ ERR_FAIL_COND_V(current.is_null(), ERR_FILE_CORRUPT);
+
+ String p = l.replace("map_Ns", "").replace("\\", "/").strip_edges();
+ String path = base_path.plus_file(p);
+
+ Ref<Texture> texture = ResourceLoader::load(path);
+
+ if (texture.is_valid()) {
+ current->set_texture(SpatialMaterial::TEXTURE_ROUGHNESS, texture);
+ } else {
+ r_missing_deps->push_back(path);
+ }
+ } else if (l.begins_with("map_bump ")) {
+ //normal
+ ERR_FAIL_COND_V(current.is_null(), ERR_FILE_CORRUPT);
+
+ String p = l.replace("map_bump", "").replace("\\", "/").strip_edges();
+ String path = base_path.plus_file(p);
+
+ Ref<Texture> texture = ResourceLoader::load(path);
-void ResourceImporterOBJ::get_import_options(List<ImportOption> *r_options, int p_preset) const {
-
- r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "generate/tangents"), true));
- r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "generate/normals"), true));
- //not for nowp
- //r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL,"import/materials")));
- //r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL,"import/textures")));
- r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "force/flip_faces"), false));
- r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "force/smooth_shading"), true));
- r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "force/weld_vertices"), true));
- r_options->push_back(ImportOption(PropertyInfo(Variant::REAL, "force/weld_tolerance", PROPERTY_HINT_RANGE, "0.00001,16,0.00001"), 0.0001));
- //r_options->push_back(PropertyInfo(Variant::INT,"compress/bitrate",PROPERTY_HINT_ENUM,"64,96,128,192"));
+ if (texture.is_valid()) {
+ current->set_feature(SpatialMaterial::FEATURE_NORMAL_MAPPING, true);
+ current->set_texture(SpatialMaterial::TEXTURE_NORMAL, texture);
+ } else {
+ r_missing_deps->push_back(path);
+ }
+ } else if (f->eof_reached()) {
+ break;
+ }
+ }
+
+ return OK;
}
-Error ResourceImporterOBJ::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files) {
+Node *EditorOBJImporter::import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps, Error *r_err) {
- FileAccessRef f = FileAccess::open(p_source_file, FileAccess::READ);
- ERR_FAIL_COND_V(!f, ERR_CANT_OPEN);
+ FileAccessRef f = FileAccess::open(p_path, FileAccess::READ);
+
+ if (r_err) {
+ *r_err = ERR_CANT_OPEN;
+ }
+
+ ERR_FAIL_COND_V(!f, NULL);
+
+ if (r_err) {
+ *r_err = OK;
+ }
+
+ Spatial *scene = memnew(Spatial);
+
+ Ref<ArrayMesh> mesh;
+ mesh.instance();
- Ref<ArrayMesh> mesh = Ref<ArrayMesh>(memnew(ArrayMesh));
Map<String, Ref<Material> > name_map;
- bool generate_normals = p_options["generate/normals"];
- bool generate_tangents = p_options["generate/tangents"];
- bool flip_faces = p_options["force/flip_faces"];
- bool force_smooth = p_options["force/smooth_shading"];
- bool weld_vertices = p_options["force/weld_vertices"];
- float weld_tolerance = p_options["force/weld_tolerance"];
+ bool generate_tangents = p_flags & IMPORT_GENERATE_TANGENT_ARRAYS;
+ bool flip_faces = false;
+ //bool flip_faces = p_options["force/flip_faces"];
+ //bool force_smooth = p_options["force/smooth_shading"];
+ //bool weld_vertices = p_options["force/weld_vertices"];
+ //float weld_tolerance = p_options["force/weld_tolerance"];
+
Vector<Vector3> vertices;
Vector<Vector3> normals;
Vector<Vector2> uvs;
String name;
+ Map<String, Map<String, Ref<SpatialMaterial> > > material_map;
+
Ref<SurfaceTool> surf_tool = memnew(SurfaceTool);
surf_tool->begin(Mesh::PRIMITIVE_TRIANGLES);
- if (force_smooth)
- surf_tool->add_smooth_group(true);
- int has_index_data = false;
+
+ String current_material_library;
+ String current_material;
+ String current_group;
while (true) {
@@ -115,7 +239,7 @@ Error ResourceImporterOBJ::import(const String &p_source_file, const String &p_s
if (l.begins_with("v ")) {
//vertex
Vector<String> v = l.split(" ", false);
- ERR_FAIL_COND_V(v.size() < 4, ERR_INVALID_DATA);
+ ERR_FAIL_COND_V(v.size() < 4, NULL);
Vector3 vtx;
vtx.x = v[1].to_float();
vtx.y = v[2].to_float();
@@ -124,7 +248,7 @@ Error ResourceImporterOBJ::import(const String &p_source_file, const String &p_s
} else if (l.begins_with("vt ")) {
//uv
Vector<String> v = l.split(" ", false);
- ERR_FAIL_COND_V(v.size() < 3, ERR_INVALID_DATA);
+ ERR_FAIL_COND_V(v.size() < 3, NULL);
Vector2 uv;
uv.x = v[1].to_float();
uv.y = 1.0 - v[2].to_float();
@@ -133,7 +257,7 @@ Error ResourceImporterOBJ::import(const String &p_source_file, const String &p_s
} else if (l.begins_with("vn ")) {
//normal
Vector<String> v = l.split(" ", false);
- ERR_FAIL_COND_V(v.size() < 4, ERR_INVALID_DATA);
+ ERR_FAIL_COND_V(v.size() < 4, NULL);
Vector3 nrm;
nrm.x = v[1].to_float();
nrm.y = v[2].to_float();
@@ -142,21 +266,20 @@ Error ResourceImporterOBJ::import(const String &p_source_file, const String &p_s
} else if (l.begins_with("f ")) {
//vertex
- has_index_data = true;
Vector<String> v = l.split(" ", false);
- ERR_FAIL_COND_V(v.size() < 4, ERR_INVALID_DATA);
+ ERR_FAIL_COND_V(v.size() < 4, NULL);
//not very fast, could be sped up
Vector<String> face[3];
face[0] = v[1].split("/");
face[1] = v[2].split("/");
- ERR_FAIL_COND_V(face[0].size() == 0, ERR_PARSE_ERROR);
- ERR_FAIL_COND_V(face[0].size() != face[1].size(), ERR_PARSE_ERROR);
+ ERR_FAIL_COND_V(face[0].size() == 0, NULL);
+ ERR_FAIL_COND_V(face[0].size() != face[1].size(), NULL);
for (int i = 2; i < v.size() - 1; i++) {
face[2] = v[i + 1].split("/");
- ERR_FAIL_COND_V(face[0].size() != face[2].size(), ERR_PARSE_ERROR);
+ ERR_FAIL_COND_V(face[0].size() != face[2].size(), NULL);
for (int j = 0; j < 3; j++) {
int idx = j;
@@ -169,7 +292,7 @@ Error ResourceImporterOBJ::import(const String &p_source_file, const String &p_s
int norm = face[idx][2].to_int() - 1;
if (norm < 0)
norm += normals.size() + 1;
- ERR_FAIL_INDEX_V(norm, normals.size(), ERR_PARSE_ERROR);
+ ERR_FAIL_INDEX_V(norm, normals.size(), NULL);
surf_tool->add_normal(normals[norm]);
}
@@ -177,58 +300,109 @@ Error ResourceImporterOBJ::import(const String &p_source_file, const String &p_s
int uv = face[idx][1].to_int() - 1;
if (uv < 0)
uv += uvs.size() + 1;
- ERR_FAIL_INDEX_V(uv, uvs.size(), ERR_PARSE_ERROR);
+ ERR_FAIL_INDEX_V(uv, uvs.size(), NULL);
surf_tool->add_uv(uvs[uv]);
}
int vtx = face[idx][0].to_int() - 1;
if (vtx < 0)
vtx += vertices.size() + 1;
- ERR_FAIL_INDEX_V(vtx, vertices.size(), ERR_PARSE_ERROR);
+ ERR_FAIL_INDEX_V(vtx, vertices.size(), NULL);
Vector3 vertex = vertices[vtx];
- if (weld_vertices)
- vertex = vertex.snapped(weld_tolerance);
+ //if (weld_vertices)
+ // vertex.snap(Vector3(weld_tolerance, weld_tolerance, weld_tolerance));
surf_tool->add_vertex(vertex);
}
face[1] = face[2];
}
- } else if (l.begins_with("s ") && !force_smooth) { //smoothing
+ } else if (l.begins_with("s ")) { //smoothing
String what = l.substr(2, l.length()).strip_edges();
if (what == "off")
surf_tool->add_smooth_group(false);
else
surf_tool->add_smooth_group(true);
-
- } else if (l.begins_with("o ") || f->eof_reached()) { //new surface or done
-
- if (has_index_data) {
- //new object/surface
- if (generate_normals || force_smooth)
+ } else if (/*l.begins_with("g ") ||*/ l.begins_with("usemtl ") || (l.begins_with("o ") || f->eof_reached())) { //commit group to mesh
+ //groups are too annoying
+ if (surf_tool->get_vertex_array().size()) {
+ //another group going on, commit it
+ if (normals.size() == 0) {
surf_tool->generate_normals();
- if (uvs.size() && (normals.size() || generate_normals) && generate_tangents)
+ }
+
+ if (generate_tangents && uvs.size()) {
surf_tool->generate_tangents();
+ }
surf_tool->index();
+
+ print_line("current material library " + current_material_library + " has " + itos(material_map.has(current_material_library)));
+ print_line("current material " + current_material + " has " + itos(material_map.has(current_material_library) && material_map[current_material_library].has(current_material)));
+
+ if (material_map.has(current_material_library) && material_map[current_material_library].has(current_material)) {
+ surf_tool->set_material(material_map[current_material_library][current_material]);
+ }
+
mesh = surf_tool->commit(mesh);
- if (name == "")
- name = vformat(TTR("Surface %d"), mesh->get_surface_count() - 1);
- mesh->surface_set_name(mesh->get_surface_count() - 1, name);
- name = "";
+
+ if (current_material != String()) {
+ mesh->surface_set_name(mesh->get_surface_count() - 1, current_material.get_basename());
+ } else if (current_group != String()) {
+ mesh->surface_set_name(mesh->get_surface_count() - 1, current_group);
+ }
+
+ print_line("Added surface :" + mesh->surface_get_name(mesh->get_surface_count() - 1));
surf_tool->clear();
surf_tool->begin(Mesh::PRIMITIVE_TRIANGLES);
- if (force_smooth)
- surf_tool->add_smooth_group(true);
+ }
- has_index_data = false;
+ if (l.begins_with("o ") || f->eof_reached()) {
- if (f->eof_reached())
- break;
+ MeshInstance *mi = memnew(MeshInstance);
+ mi->set_name(name);
+ mi->set_mesh(mesh);
+
+ scene->add_child(mi);
+ mi->set_owner(scene);
+
+ mesh.instance();
+ current_group = "";
+ current_material = "";
+ }
+
+ if (f->eof_reached()) {
+ break;
}
- if (l.begins_with("o ")) //name
+ if (l.begins_with("o ")) {
name = l.substr(2, l.length()).strip_edges();
+ }
+
+ if (l.begins_with("usemtl ")) {
+
+ current_material = l.replace("usemtl", "").strip_edges();
+ }
+
+ if (l.begins_with("g ")) {
+
+ current_group = l.substr(2, l.length()).strip_edges();
+ }
+
+ } else if (l.begins_with("mtllib ")) { //parse material
+
+ current_material_library = l.replace("mtllib", "").strip_edges();
+ if (!material_map.has(current_material_library)) {
+ Map<String, Ref<SpatialMaterial> > lib;
+ Error err = _parse_material_library(current_material_library, lib, r_missing_deps);
+ if (err == ERR_CANT_OPEN) {
+ String dir = p_path.get_base_dir();
+ err = _parse_material_library(dir.plus_file(current_material_library), lib, r_missing_deps);
+ }
+ if (err == OK) {
+ material_map[current_material_library] = lib;
+ }
+ }
}
}
@@ -243,10 +417,11 @@ Error ResourceImporterOBJ::import(const String &p_source_file, const String &p_s
}
*/
- Error err = ResourceSaver::save(p_save_path + ".mesh", mesh);
-
- return err;
+ return scene;
}
+Ref<Animation> EditorOBJImporter::import_animation(const String &p_path, uint32_t p_flags) {
-ResourceImporterOBJ::ResourceImporterOBJ() {
+ return Ref<Animation>();
+}
+EditorOBJImporter::EditorOBJImporter() {
}
diff --git a/editor/import/resource_importer_obj.h b/editor/import/resource_importer_obj.h
index b7443c71a6..c8285ce6c9 100644
--- a/editor/import/resource_importer_obj.h
+++ b/editor/import/resource_importer_obj.h
@@ -30,26 +30,21 @@
#ifndef RESOURCEIMPORTEROBJ_H
#define RESOURCEIMPORTEROBJ_H
-#include "io/resource_import.h"
+#include "import/resource_importer_scene.h"
-class ResourceImporterOBJ : public ResourceImporter {
- GDCLASS(ResourceImporterOBJ, ResourceImporter)
-public:
- virtual String get_importer_name() const;
- virtual String get_visible_name() const;
- virtual void get_recognized_extensions(List<String> *p_extensions) const;
- virtual String get_save_extension() const;
- virtual String get_resource_type() const;
+class EditorOBJImporter : public EditorSceneImporter {
- virtual int get_preset_count() const;
- virtual String get_preset_name(int p_idx) const;
+ GDCLASS(EditorOBJImporter, EditorSceneImporter);
- virtual void get_import_options(List<ImportOption> *r_options, int p_preset = 0) const;
- virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const;
+ Error _parse_material_library(const String &p_path, Map<String, Ref<SpatialMaterial> > &material_map, List<String> *r_missing_deps);
- virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = NULL);
+public:
+ virtual uint32_t get_import_flags() const;
+ virtual void get_extensions(List<String> *r_extensions) const;
+ virtual Node *import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps, Error *r_err = NULL);
+ virtual Ref<Animation> import_animation(const String &p_path, uint32_t p_flags);
- ResourceImporterOBJ();
+ EditorOBJImporter();
};
#endif // RESOURCEIMPORTEROBJ_H
diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp
index 2409f6707d..8f7ca7611a 100644
--- a/editor/import/resource_importer_scene.cpp
+++ b/editor/import/resource_importer_scene.cpp
@@ -33,7 +33,7 @@
#include "io/resource_saver.h"
#include "scene/resources/packed_scene.h"
-#include "scene/3d/body_shape.h"
+#include "scene/3d/collision_shape.h"
#include "scene/3d/mesh_instance.h"
#include "scene/3d/navigation.h"
#include "scene/3d/physics_body.h"
@@ -104,14 +104,27 @@ bool ResourceImporterScene::get_option_visibility(const String &p_option, const
}
}
+ if (p_option == "materials/keep_files" && int(p_options["materials/storage"]) == 0) {
+ return false;
+ }
+
return true;
}
int ResourceImporterScene::get_preset_count() const {
- return 0;
+ return 6;
}
String ResourceImporterScene::get_preset_name(int p_idx) const {
+ switch (p_idx) {
+ case PRESET_SINGLE_SCENE: return TTR("Import as Single Scene");
+ case PRESET_SEPARATE_MATERIALS: return TTR("Import with Separate Materials");
+ case PRESET_SEPARATE_MESHES: return TTR("Import with Separate Objects");
+ case PRESET_SEPARATE_MESHES_AND_MATERIALS: return TTR("Import with Separate Objects+Materials");
+ case PRESET_MULTIPLE_SCENES: return TTR("Import as Multiple Scenes");
+ case PRESET_MULTIPLE_SCENES_AND_MATERIALS: return TTR("Import as Multiple Scenes+Materials");
+ }
+
return "";
}
@@ -369,10 +382,8 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array
p_node = col;
StaticBody *sb = col->cast_to<StaticBody>();
- CollisionShape *colshape = memnew(CollisionShape);
- colshape->set_shape(sb->get_shape(0));
+ CollisionShape *colshape = sb->get_child(0)->cast_to<CollisionShape>();
colshape->set_name("shape");
- sb->add_child(colshape);
colshape->set_owner(p_node->get_owner());
} else if (p_node->has_meta("empty_draw_type")) {
String empty_draw_type = String(p_node->get_meta("empty_draw_type"));
@@ -463,8 +474,7 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array
p_node->add_child(col);
StaticBody *sb = col->cast_to<StaticBody>();
- CollisionShape *colshape = memnew(CollisionShape);
- colshape->set_shape(sb->get_shape(0));
+ CollisionShape *colshape = sb->get_child(0)->cast_to<CollisionShape>();
colshape->set_name("shape");
col->add_child(colshape);
colshape->set_owner(p_node->get_owner());
@@ -594,7 +604,7 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array
for (int i = 0; i < 3; i++) {
- Vector3 v = f.vertex[i].snapped(0.01);
+ Vector3 v = f.vertex[i].snapped(Vector3(0.01, 0.01, 0.01));
if (!points.has(v)) {
points.insert(v);
center += v;
@@ -972,7 +982,7 @@ static String _make_extname(const String &p_str) {
return ext_name;
}
-void ResourceImporterScene::_make_external_resources(Node *p_node, const String &p_base_path, bool p_make_materials, bool p_make_meshes, Map<Ref<Material>, Ref<Material> > &p_materials, Map<Ref<ArrayMesh>, Ref<ArrayMesh> > &p_meshes) {
+void ResourceImporterScene::_make_external_resources(Node *p_node, const String &p_base_path, bool p_make_materials, bool p_keep_materials, bool p_make_meshes, Map<Ref<Material>, Ref<Material> > &p_materials, Map<Ref<ArrayMesh>, Ref<ArrayMesh> > &p_meshes) {
List<PropertyInfo> pi;
@@ -987,8 +997,8 @@ void ResourceImporterScene::_make_external_resources(Node *p_node, const String
if (!p_materials.has(mat)) {
- String ext_name = p_base_path + "." + _make_extname(mat->get_name()) + ".material";
- if (FileAccess::exists(ext_name)) {
+ String ext_name = p_base_path.plus_file(_make_extname(mat->get_name()) + ".material");
+ if (p_keep_materials && FileAccess::exists(ext_name)) {
//if exists, use it
Ref<Material> existing = ResourceLoader::load(ext_name);
p_materials[mat] = existing;
@@ -1015,17 +1025,12 @@ void ResourceImporterScene::_make_external_resources(Node *p_node, const String
if (!p_meshes.has(mesh)) {
- String ext_name = p_base_path + "." + _make_extname(mesh->get_name()) + ".mesh";
- if (FileAccess::exists(ext_name)) {
- //if exists, use it
- Ref<ArrayMesh> existing = ResourceLoader::load(ext_name);
- p_meshes[mesh] = existing;
- } else {
+ //meshes are always overwritten, keeping them is not practical
+ String ext_name = p_base_path.plus_file(_make_extname(mesh->get_name()) + ".mesh");
- ResourceSaver::save(ext_name, mesh, ResourceSaver::FLAG_CHANGE_PATH);
- p_meshes[mesh] = mesh;
- mesh_just_added = true;
- }
+ ResourceSaver::save(ext_name, mesh, ResourceSaver::FLAG_CHANGE_PATH);
+ p_meshes[mesh] = mesh;
+ mesh_just_added = true;
}
}
@@ -1070,7 +1075,7 @@ void ResourceImporterScene::_make_external_resources(Node *p_node, const String
for (int i = 0; i < p_node->get_child_count(); i++) {
- _make_external_resources(p_node->get_child(i), p_base_path, p_make_materials, p_make_meshes, p_materials, p_meshes);
+ _make_external_resources(p_node->get_child(i), p_base_path, p_make_materials, p_keep_materials, p_make_meshes, p_materials, p_meshes);
}
}
@@ -1090,12 +1095,19 @@ void ResourceImporterScene::get_import_options(List<ImportOption> *r_options, in
script_ext_hint += "*." + E->get();
}
+ bool materials_out = p_preset == PRESET_SEPARATE_MATERIALS || p_preset == PRESET_SEPARATE_MESHES_AND_MATERIALS || p_preset == PRESET_MULTIPLE_SCENES_AND_MATERIALS;
+ bool meshes_out = p_preset == PRESET_SEPARATE_MESHES || p_preset == PRESET_SEPARATE_MESHES_AND_MATERIALS;
+ bool scenes_out = p_preset == PRESET_MULTIPLE_SCENES || p_preset == PRESET_MULTIPLE_SCENES_AND_MATERIALS;
+
r_options->push_back(ImportOption(PropertyInfo(Variant::STRING, "nodes/custom_script", PROPERTY_HINT_FILE, script_ext_hint), ""));
- r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "materials/location", PROPERTY_HINT_ENUM, "Node,Mesh"), 0));
- r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "materials/storage", PROPERTY_HINT_ENUM, "Bult-In,Files"), 0));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "nodes/storage", PROPERTY_HINT_ENUM, "Single Scene,Instanced Sub-Scenes"), scenes_out ? 1 : 0));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "materials/location", PROPERTY_HINT_ENUM, "Node,Mesh"), meshes_out ? 1 : 0));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "materials/storage", PROPERTY_HINT_ENUM, "Bult-In,Files", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), materials_out ? 1 : 0));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "materials/keep_files"), materials_out ? true : false));
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "geometry/compress"), true));
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "geometry/ensure_tangents"), true));
- r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "geometry/storage", PROPERTY_HINT_ENUM, "Built-In,Files"), 0));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "geometry/storage", PROPERTY_HINT_ENUM, "Built-In,Files"), meshes_out ? true : false));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "external_files/store_in_subdir"), true));
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "animation/import", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), true));
r_options->push_back(ImportOption(PropertyInfo(Variant::REAL, "animation/fps", PROPERTY_HINT_RANGE, "1,120,1"), 15));
r_options->push_back(ImportOption(PropertyInfo(Variant::STRING, "animation/filter_script", PROPERTY_HINT_MULTILINE_TEXT), ""));
@@ -1113,6 +1125,18 @@ void ResourceImporterScene::get_import_options(List<ImportOption> *r_options, in
}
}
+void ResourceImporterScene::_replace_owner(Node *p_node, Node *p_scene, Node *p_new_owner) {
+
+ if (p_node != p_new_owner && p_node->get_owner() == p_scene) {
+ p_node->set_owner(p_new_owner);
+ }
+
+ for (int i = 0; i < p_node->get_child_count(); i++) {
+ Node *n = p_node->get_child(i);
+ _replace_owner(n, p_scene, p_new_owner);
+ }
+}
+
Error ResourceImporterScene::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files) {
String src_path = p_source_file;
@@ -1227,11 +1251,30 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p
bool external_materials = p_options["materials/storage"];
bool external_meshes = p_options["geometry/storage"];
+ bool external_scenes = int(p_options["nodes/storage"]) == 1;
+
+ String base_path = p_source_file.get_base_dir();
+
+ if (external_materials || external_meshes || external_scenes) {
+
+ if (bool(p_options["external_files/store_in_subdir"])) {
+ String subdir_name = p_source_file.get_file().get_basename();
+ DirAccess *da = DirAccess::open(base_path);
+ print_line("at path " + da->get_current_dir() + " making " + subdir_name);
+ Error err = da->make_dir(subdir_name);
+ memdelete(da);
+ ERR_FAIL_COND_V(err != OK && err != ERR_ALREADY_EXISTS, err);
+ base_path = base_path.plus_file(subdir_name);
+ }
+ }
if (external_materials || external_meshes) {
Map<Ref<Material>, Ref<Material> > mat_map;
Map<Ref<ArrayMesh>, Ref<ArrayMesh> > mesh_map;
- _make_external_resources(scene, p_source_file.get_basename(), external_materials, external_meshes, mat_map, mesh_map);
+
+ bool keep_materials = bool(p_options["materials/keep_files"]);
+
+ _make_external_resources(scene, base_path, external_materials, keep_materials, external_meshes, mat_map, mesh_map);
}
progress.step(TTR("Running Custom Script.."), 2);
@@ -1266,10 +1309,33 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p
progress.step(TTR("Saving.."), 104);
+ if (external_scenes) {
+ //save sub-scenes as instances!
+ for (int i = 0; i < scene->get_child_count(); i++) {
+ Node *child = scene->get_child(i);
+ if (child->get_owner() != scene)
+ continue; //not a real child probably created by scene type (ig, a scrollbar)
+ _replace_owner(child, scene, child);
+
+ String cn = String(child->get_name()).strip_edges().replace(".", "_").replace(":", "_");
+ if (cn == String()) {
+ cn = "ChildNode" + itos(i);
+ }
+ String path = base_path.plus_file(cn + ".scn");
+ child->set_filename(path);
+
+ Ref<PackedScene> packer = memnew(PackedScene);
+ packer->pack(child);
+ err = ResourceSaver::save(path, packer); //do not take over, let the changed files reload themselves
+ ERR_FAIL_COND_V(err != OK, err);
+ }
+ }
+
Ref<PackedScene> packer = memnew(PackedScene);
packer->pack(scene);
print_line("SAVING TO: " + p_save_path + ".scn");
err = ResourceSaver::save(p_save_path + ".scn", packer); //do not take over, let the changed files reload themselves
+ ERR_FAIL_COND_V(err != OK, err);
memdelete(scene);
diff --git a/editor/import/resource_importer_scene.h b/editor/import/resource_importer_scene.h
index ede3028b29..f404582d7e 100644
--- a/editor/import/resource_importer_scene.h
+++ b/editor/import/resource_importer_scene.h
@@ -82,6 +82,17 @@ class ResourceImporterScene : public ResourceImporter {
static ResourceImporterScene *singleton;
+ enum Presets {
+ PRESET_SINGLE_SCENE,
+ PRESET_SEPARATE_MATERIALS,
+ PRESET_SEPARATE_MESHES,
+ PRESET_SEPARATE_MESHES_AND_MATERIALS,
+ PRESET_MULTIPLE_SCENES,
+ PRESET_MULTIPLE_SCENES_AND_MATERIALS,
+ };
+
+ void _replace_owner(Node *p_node, Node *p_scene, Node *p_new_owner);
+
public:
static ResourceImporterScene *get_singleton() { return singleton; }
@@ -101,7 +112,7 @@ public:
virtual void get_import_options(List<ImportOption> *r_options, int p_preset = 0) const;
virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const;
- void _make_external_resources(Node *p_node, const String &p_base_path, bool p_make_materials, bool p_make_meshes, Map<Ref<Material>, Ref<Material> > &p_materials, Map<Ref<ArrayMesh>, Ref<ArrayMesh> > &p_meshes);
+ void _make_external_resources(Node *p_node, const String &p_base_path, bool p_make_materials, bool p_keep_materials, bool p_make_meshes, Map<Ref<Material>, Ref<Material> > &p_materials, Map<Ref<ArrayMesh>, Ref<ArrayMesh> > &p_meshes);
Node *_fix_node(Node *p_node, Node *p_root, Map<Ref<ArrayMesh>, Ref<Shape> > &collision_map);
diff --git a/editor/import/resource_importer_texture.cpp b/editor/import/resource_importer_texture.cpp
index 3834e52fab..98020ed9b8 100644
--- a/editor/import/resource_importer_texture.cpp
+++ b/editor/import/resource_importer_texture.cpp
@@ -416,26 +416,26 @@ Error ResourceImporterTexture::import(const String &p_source_file, const String
bool force_normal = normal == 1;
if (compress_mode == COMPRESS_VIDEO_RAM) {
- //must import in all formats
+ //must import in all formats, in order of priority (so platform choses the best supported one. IE, etc2 over etc).
//Android, GLES 2.x
- if (GlobalConfig::get_singleton()->get("rendering/vram_formats/use_s3tc")) {
+ if (ProjectSettings::get_singleton()->get("rendering/vram_compression/import_s3tc")) {
_save_stex(image, p_save_path + ".s3tc.stex", compress_mode, lossy, Image::COMPRESS_S3TC, mipmaps, tex_flags, stream, detect_3d, detect_srgb, force_rgbe, detect_normal, force_normal);
r_platform_variants->push_back("s3tc");
}
- if (GlobalConfig::get_singleton()->get("rendering/vram_formats/use_etc")) {
- _save_stex(image, p_save_path + ".etc.stex", compress_mode, lossy, Image::COMPRESS_ETC, mipmaps, tex_flags, stream, detect_3d, detect_srgb, force_rgbe, detect_normal, force_normal);
- r_platform_variants->push_back("etc");
- }
-
- if (GlobalConfig::get_singleton()->get("rendering/vram_formats/use_etc2")) {
+ if (ProjectSettings::get_singleton()->get("rendering/vram_compression/import_etc2")) {
_save_stex(image, p_save_path + ".etc2.stex", compress_mode, lossy, Image::COMPRESS_ETC2, mipmaps, tex_flags, stream, detect_3d, detect_srgb, force_rgbe, detect_normal, force_normal);
r_platform_variants->push_back("etc2");
}
- if (GlobalConfig::get_singleton()->get("rendering/vram_formats/use_pvrtc")) {
+ if (ProjectSettings::get_singleton()->get("rendering/vram_compression/import_etc")) {
+ _save_stex(image, p_save_path + ".etc.stex", compress_mode, lossy, Image::COMPRESS_ETC, mipmaps, tex_flags, stream, detect_3d, detect_srgb, force_rgbe, detect_normal, force_normal);
+ r_platform_variants->push_back("etc");
+ }
+
+ if (ProjectSettings::get_singleton()->get("rendering/vram_compression/import_pvrtc")) {
_save_stex(image, p_save_path + ".pvrtc.stex", compress_mode, lossy, Image::COMPRESS_PVRTC4, mipmaps, tex_flags, stream, detect_3d, detect_srgb, force_rgbe, detect_normal, force_normal);
r_platform_variants->push_back("pvrtc");
diff --git a/editor/import/resource_importer_wav.cpp b/editor/import/resource_importer_wav.cpp
index 7841baa02e..18c4bed5dd 100644
--- a/editor/import/resource_importer_wav.cpp
+++ b/editor/import/resource_importer_wav.cpp
@@ -153,6 +153,8 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s
uint16_t compression_code = file->get_16();
+ //Issue: #7755 : Not a bug - usage of other formats (format codes) are unsupported in current importer version.
+ //Consider revision for engine version 3.0
if (compression_code != 1) {
ERR_PRINT("Format not supported for WAVE file (not PCM). Save WAVE files as uncompressed PCM instead.");
break;
@@ -249,6 +251,15 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s
if (chunkID[0] == 's' && chunkID[1] == 'm' && chunkID[2] == 'p' && chunkID[3] == 'l') {
//loop point info!
+ /**
+ * Consider exploring next document:
+ * http://www-mmsp.ece.mcgill.ca/Documents/AudioFormats/WAVE/Docs/RIFFNEW.pdf
+ * Especially on page:
+ * 16 - 17
+ * Timestamp:
+ * 22:38 06.07.2017 GMT
+ **/
+
for (int i = 0; i < 10; i++)
file->get_32(); // i wish to know why should i do this... no doc!
diff --git a/editor/import_dock.cpp b/editor/import_dock.cpp
index 6c7a633477..a4f744aa84 100644
--- a/editor/import_dock.cpp
+++ b/editor/import_dock.cpp
@@ -134,6 +134,14 @@ void ImportDock::set_edit_path(const String &p_path) {
}
}
+ preset->get_popup()->add_separator();
+ preset->get_popup()->add_item(vformat(TTR("Set as Default for '%s'"), params->importer->get_visible_name()), ITEM_SET_AS_DEFAULT);
+ if (ProjectSettings::get_singleton()->has("importer_defaults/" + params->importer->get_importer_name())) {
+ preset->get_popup()->add_item(TTR("Load Default"), ITEM_LOAD_DEFAULT);
+ preset->get_popup()->add_separator();
+ preset->get_popup()->add_item(vformat(TTR("Clear Default for '%s'"), params->importer->get_visible_name()), ITEM_CLEAR_DEFAULT);
+ }
+
params->paths.clear();
params->paths.push_back(p_path);
import->set_disabled(false);
@@ -256,17 +264,56 @@ void ImportDock::set_edit_multiple_paths(const Vector<String> &p_paths) {
void ImportDock::_preset_selected(int p_idx) {
- print_line("preset selected? " + p_idx);
- List<ResourceImporter::ImportOption> options;
+ switch (p_idx) {
+ case ITEM_SET_AS_DEFAULT: {
+ List<ResourceImporter::ImportOption> options;
- params->importer->get_import_options(&options, p_idx);
+ params->importer->get_import_options(&options, p_idx);
- for (List<ResourceImporter::ImportOption>::Element *E = options.front(); E; E = E->next()) {
+ Dictionary d;
+ for (List<ResourceImporter::ImportOption>::Element *E = options.front(); E; E = E->next()) {
- params->values[E->get().option.name] = E->get().default_value;
- }
+ d[E->get().option.name] = E->get().default_value;
+ }
- params->update();
+ ProjectSettings::get_singleton()->set("importer_defaults/" + params->importer->get_importer_name(), d);
+ ProjectSettings::get_singleton()->save();
+
+ } break;
+ case ITEM_LOAD_DEFAULT: {
+
+ ERR_FAIL_COND(!ProjectSettings::get_singleton()->has("importer_defaults/" + params->importer->get_importer_name()));
+
+ Dictionary d = ProjectSettings::get_singleton()->get("importer_defaults/" + params->importer->get_importer_name());
+ List<Variant> v;
+ d.get_key_list(&v);
+
+ for (List<Variant>::Element *E = v.front(); E; E = E->next()) {
+ params->values[E->get()] = d[E->get()];
+ }
+ params->update();
+
+ } break;
+ case ITEM_CLEAR_DEFAULT: {
+
+ ProjectSettings::get_singleton()->set("importer_defaults/" + params->importer->get_importer_name(), Variant());
+ ProjectSettings::get_singleton()->save();
+
+ } break;
+ default: {
+
+ List<ResourceImporter::ImportOption> options;
+
+ params->importer->get_import_options(&options, p_idx);
+
+ for (List<ResourceImporter::ImportOption>::Element *E = options.front(); E; E = E->next()) {
+
+ params->values[E->get().option.name] = E->get().default_value;
+ }
+
+ params->update();
+ } break;
+ }
}
void ImportDock::clear() {
@@ -309,6 +356,13 @@ void ImportDock::_bind_methods() {
ClassDB::bind_method(D_METHOD("_preset_selected"), &ImportDock::_preset_selected);
}
+void ImportDock::initialize_import_options() const {
+
+ ERR_FAIL_COND(!import_opts || !params);
+
+ import_opts->edit(params);
+}
+
ImportDock::ImportDock() {
imported = memnew(LineEdit);
@@ -328,7 +382,6 @@ ImportDock::ImportDock() {
add_child(import_opts);
import_opts->set_v_size_flags(SIZE_EXPAND_FILL);
import_opts->hide_top_label();
- import_opts->set_hide_script(true);
hb = memnew(HBoxContainer);
add_child(hb);
@@ -340,7 +393,6 @@ ImportDock::ImportDock() {
hb->add_spacer();
params = memnew(ImportDockParameters);
- import_opts->edit(params);
}
ImportDock::~ImportDock() {
diff --git a/editor/import_dock.h b/editor/import_dock.h
index fc99fcc586..4844fc07ea 100644
--- a/editor/import_dock.h
+++ b/editor/import_dock.h
@@ -57,12 +57,19 @@ class ImportDock : public VBoxContainer {
void _reimport();
+ enum {
+ ITEM_SET_AS_DEFAULT = 100,
+ ITEM_LOAD_DEFAULT,
+ ITEM_CLEAR_DEFAULT,
+ };
+
protected:
static void _bind_methods();
public:
void set_edit_path(const String &p_path);
void set_edit_multiple_paths(const Vector<String> &p_paths);
+ void initialize_import_options() const;
void clear();
ImportDock();
diff --git a/editor/io_plugins/editor_export_scene.cpp b/editor/io_plugins/editor_export_scene.cpp
index bdf9dc6844..6392b4a715 100644
--- a/editor/io_plugins/editor_export_scene.cpp
+++ b/editor/io_plugins/editor_export_scene.cpp
@@ -30,11 +30,11 @@
#include "editor_export_scene.h"
#if 0
#include "editor/editor_settings.h"
-#include "global_config.h"
#include "io/resource_loader.h"
#include "io/resource_saver.h"
#include "os/dir_access.h"
#include "os/file_access.h"
+#include "project_settings.h"
#include "scene/resources/packed_scene.h"
Vector<uint8_t> EditorSceneExportPlugin::custom_export(String& p_path,const Ref<EditorExportPlatform> &p_platform) {
@@ -63,7 +63,7 @@ Vector<uint8_t> EditorSceneExportPlugin::custom_export(String& p_path,const Ref<
uint64_t sd=0;
String smd5;
- String gp = GlobalConfig::get_singleton()->globalize_path(p_path);
+ String gp = ProjectSettings::get_singleton()->globalize_path(p_path);
String md5=gp.md5_text();
String tmp_path = EditorSettings::get_singleton()->get_settings_path().plus_file("tmp/");
diff --git a/editor/io_plugins/editor_scene_import_plugin.cpp b/editor/io_plugins/editor_scene_import_plugin.cpp
index fed02b0e72..aa96f731ce 100644
--- a/editor/io_plugins/editor_scene_import_plugin.cpp
+++ b/editor/io_plugins/editor_scene_import_plugin.cpp
@@ -31,10 +31,10 @@
#if 0
#include "editor/create_dialog.h"
#include "editor/editor_node.h"
-#include "global_config.h"
#include "io/resource_saver.h"
#include "os/file_access.h"
#include "os/os.h"
+#include "project_settings.h"
#include "scene/3d/body_shape.h"
#include "scene/3d/mesh_instance.h"
#include "scene/3d/navigation.h"
@@ -672,9 +672,9 @@ void EditorSceneImportDialog::_choose_save_file(const String& p_path) {
void EditorSceneImportDialog::_choose_script(const String& p_path) {
- String p = GlobalConfig::get_singleton()->localize_path(p_path);
+ String p = ProjectSettings::get_singleton()->localize_path(p_path);
if (!p.is_resource_file())
- p=GlobalConfig::get_singleton()->get_resource_path().path_to(p_path.get_base_dir())+p_path.get_file();
+ p=ProjectSettings::get_singleton()->get_resource_path().path_to(p_path.get_base_dir())+p_path.get_file();
script_path->set_text(p);
}
@@ -727,7 +727,7 @@ void EditorSceneImportDialog::_import(bool p_and_open) {
if (texture_action->get_selected()==0)
dst_path=save_path->get_text();//.get_base_dir();
else
- dst_path=GlobalConfig::get_singleton()->get("import/shared_textures");
+ dst_path=ProjectSettings::get_singleton()->get("import/shared_textures");
uint32_t flags=0;
@@ -1277,7 +1277,7 @@ EditorSceneImportDialog::EditorSceneImportDialog(EditorNode *p_editor, EditorSce
set_hide_on_ok(false);
GLOBAL_DEF("import/shared_textures","res://");
- GlobalConfig::get_singleton()->set_custom_property_info("import/shared_textures",PropertyInfo(Variant::STRING,"import/shared_textures",PROPERTY_HINT_DIR));
+ ProjectSettings::get_singleton()->set_custom_property_info("import/shared_textures",PropertyInfo(Variant::STRING,"import/shared_textures",PROPERTY_HINT_DIR));
import_hb->add_constant_override("separation",30);
@@ -2812,7 +2812,7 @@ Error EditorSceneImportPlugin::import2(Node *scene, const String& p_dest_path, c
String path = texture->get_path();
String fname= path.get_file();
- String target_path = GlobalConfig::get_singleton()->localize_path(target_res_path.plus_file(fname));
+ String target_path = ProjectSettings::get_singleton()->localize_path(target_res_path.plus_file(fname));
progress.step(TTR("Import Image:")+" "+fname,3+(idx)*100/imagemap.size());
idx++;
diff --git a/editor/io_plugins/editor_texture_import_plugin.cpp b/editor/io_plugins/editor_texture_import_plugin.cpp
index d48675fa30..095bc02fa0 100644
--- a/editor/io_plugins/editor_texture_import_plugin.cpp
+++ b/editor/io_plugins/editor_texture_import_plugin.cpp
@@ -33,10 +33,10 @@
#include "editor/editor_node.h"
#include "editor/editor_settings.h"
#include "editor_atlas.h"
-#include "global_config.h"
#include "io/image_loader.h"
#include "io/marshalls.h"
#include "io/resource_saver.h"
+#include "project_settings.h"
#include "scene/gui/button_group.h"
#include "scene/gui/check_button.h"
#include "scene/gui/margin_container.h"
@@ -1653,7 +1653,7 @@ Vector<uint8_t> EditorTextureImportPlugin::custom_export(const String& p_path, c
uint8_t f4[4];
encode_uint32(flags,&f4[0]);
MD5Init(&ctx);
- String gp = GlobalConfig::get_singleton()->globalize_path(p_path);
+ String gp = ProjectSettings::get_singleton()->globalize_path(p_path);
CharString cs = gp.utf8();
MD5Update(&ctx,(unsigned char*)cs.get_data(),cs.length());
MD5Update(&ctx,f4,4);
diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp
index 28c5b89741..c4e79bf263 100644
--- a/editor/plugins/animation_player_editor_plugin.cpp
+++ b/editor/plugins/animation_player_editor_plugin.cpp
@@ -31,10 +31,10 @@
#include "editor/animation_editor.h"
#include "editor/editor_settings.h"
-#include "global_config.h"
#include "io/resource_loader.h"
#include "io/resource_saver.h"
#include "os/keyboard.h"
+#include "project_settings.h"
void AnimationPlayerEditor::_node_removed(Node *p_node) {
@@ -254,6 +254,10 @@ void AnimationPlayerEditor::_play_bw_from_pressed() {
}
void AnimationPlayerEditor::_stop_pressed() {
+ if (!player) {
+ return;
+ }
+
player->stop(false);
play->set_pressed(false);
stop->set_pressed(true);
@@ -368,7 +372,7 @@ void AnimationPlayerEditor::_animation_save_in_path(const Ref<Resource> &p_resou
flg |= ResourceSaver::FLAG_RELATIVE_PATHS;
*/
- String path = GlobalConfig::get_singleton()->localize_path(p_path);
+ String path = ProjectSettings::get_singleton()->localize_path(p_path);
Error err = ResourceSaver::save(path, p_resource, flg | ResourceSaver::FLAG_REPLACE_SUBRESOURCE_PATHS);
if (err != OK) {
diff --git a/editor/plugins/animation_tree_editor_plugin.cpp b/editor/plugins/animation_tree_editor_plugin.cpp
index d67832e10b..156a74144c 100644
--- a/editor/plugins/animation_tree_editor_plugin.cpp
+++ b/editor/plugins/animation_tree_editor_plugin.cpp
@@ -29,8 +29,8 @@
/*************************************************************************/
#include "animation_tree_editor_plugin.h"
-#include "core/global_config.h"
#include "core/io/resource_loader.h"
+#include "core/project_settings.h"
#include "os/input.h"
#include "os/keyboard.h"
#include "scene/gui/menu_button.h"
@@ -371,6 +371,7 @@ void AnimationTreeEditor::_popup_edit_dialog() {
edit_label[0]->show();
edit_scroll[0]->set_min(0);
edit_scroll[0]->set_max(1);
+ edit_scroll[0]->set_step(0.01);
edit_scroll[0]->set_value(anim_tree->mix_node_get_amount(edited_node));
edit_scroll[0]->set_begin(Point2(15, 25));
edit_scroll[0]->show();
@@ -383,6 +384,7 @@ void AnimationTreeEditor::_popup_edit_dialog() {
edit_label[0]->show();
edit_scroll[0]->set_min(0);
edit_scroll[0]->set_max(1);
+ edit_scroll[0]->set_step(0.01);
edit_scroll[0]->set_value(anim_tree->blend2_node_get_amount(edited_node));
edit_scroll[0]->set_begin(Point2(15, 25));
edit_scroll[0]->show();
@@ -398,6 +400,7 @@ void AnimationTreeEditor::_popup_edit_dialog() {
edit_label[0]->show();
edit_scroll[0]->set_min(-1);
edit_scroll[0]->set_max(1);
+ edit_scroll[0]->set_step(0.01);
edit_scroll[0]->set_value(anim_tree->blend3_node_get_amount(edited_node));
edit_scroll[0]->set_begin(Point2(15, 25));
edit_scroll[0]->show();
@@ -411,6 +414,7 @@ void AnimationTreeEditor::_popup_edit_dialog() {
edit_label[0]->show();
edit_scroll[0]->set_min(0);
edit_scroll[0]->set_max(1);
+ edit_scroll[0]->set_step(0.01);
edit_scroll[0]->set_value(anim_tree->blend4_node_get_amount(edited_node).x);
edit_scroll[0]->set_begin(Point2(15, 25));
edit_scroll[0]->show();
@@ -419,6 +423,7 @@ void AnimationTreeEditor::_popup_edit_dialog() {
edit_label[1]->show();
edit_scroll[1]->set_min(0);
edit_scroll[1]->set_max(1);
+ edit_scroll[1]->set_step(0.01);
edit_scroll[1]->set_value(anim_tree->blend4_node_get_amount(edited_node).y);
edit_scroll[1]->set_begin(Point2(15, 75));
edit_scroll[1]->show();
@@ -1408,7 +1413,7 @@ AnimationTreeEditor::AnimationTreeEditor() {
file_dialog = memnew(EditorFileDialog);
file_dialog->set_enable_multiple_selection(true);
- file_dialog->set_current_dir(GlobalConfig::get_singleton()->get_resource_path());
+ file_dialog->set_current_dir(ProjectSettings::get_singleton()->get_resource_path());
add_child(file_dialog);
file_dialog->connect("file_selected", this, "_file_dialog_selected");
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index 7c6b233bd4..a809a68c23 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -35,10 +35,10 @@
#include "editor/plugins/animation_player_editor_plugin.h"
#include "editor/plugins/script_editor_plugin.h"
#include "editor/script_editor_debugger.h"
-#include "global_config.h"
#include "os/input.h"
#include "os/keyboard.h"
#include "print_string.h"
+#include "project_settings.h"
#include "scene/2d/light_2d.h"
#include "scene/2d/particles_2d.h"
#include "scene/2d/polygon_2d.h"
@@ -176,7 +176,6 @@ void CanvasItemEditor::_edit_set_pivot(const Vector2 &mouse_pos) {
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
Node2D *n2d = E->get()->cast_to<Node2D>();
-
if (n2d && n2d->edit_has_pivot()) {
Vector2 offset = n2d->edit_get_pivot();
@@ -199,6 +198,25 @@ void CanvasItemEditor::_edit_set_pivot(const Vector2 &mouse_pos) {
undo_redo->add_undo_method(n2dc, "set_global_position", n2dc->get_global_position());
}
}
+
+ Control *cnt = E->get()->cast_to<Control>();
+ if (cnt) {
+
+ Vector2 old_pivot = cnt->get_pivot_offset();
+ Vector2 new_pivot = cnt->get_global_transform_with_canvas().affine_inverse().xform(mouse_pos);
+ Vector2 old_pos = cnt->get_position();
+
+ Vector2 top_pos = cnt->get_transform().get_origin(); //remember where top pos was
+ cnt->set_pivot_offset(new_pivot);
+ Vector2 new_top_pos = cnt->get_transform().get_origin(); //check where it is now
+
+ Vector2 new_pos = old_pos - (new_top_pos - top_pos); //offset it back
+
+ undo_redo->add_do_method(cnt, "set_pivot_offset", new_pivot);
+ undo_redo->add_do_method(cnt, "set_position", new_pos);
+ undo_redo->add_undo_method(cnt, "set_pivot_offset", old_pivot);
+ undo_redo->add_undo_method(cnt, "set_position", old_pos);
+ }
}
undo_redo->commit_action();
@@ -222,7 +240,6 @@ void CanvasItemEditor::_unhandled_key_input(const Ref<InputEvent> &p_ev) {
} else if (!Input::get_singleton()->is_mouse_button_pressed(0)) {
List<Node *> &selection = editor_selection->get_selected_node_list();
-
Vector2 mouse_pos = viewport->get_local_mouse_pos();
if (selection.size() && viewport->get_rect().has_point(mouse_pos)) {
//just in case, make it work if over viewport
@@ -239,7 +256,6 @@ void CanvasItemEditor::_tool_select(int p_index) {
ToolButton *tb[TOOL_MAX] = { select_button, list_select_button, move_button, rotate_button, pivot_button, pan_button };
for (int i = 0; i < TOOL_MAX; i++) {
-
tb[i]->set_pressed(i == p_index);
}
@@ -430,44 +446,7 @@ bool CanvasItemEditor::_is_part_of_subscene(CanvasItem *p_item) {
return item_owner && item_owner != scene_node && p_item != scene_node && item_owner->get_filename() != "";
}
-// slow but modern computers should have no problem
-CanvasItem *CanvasItemEditor::_select_canvas_item_at_pos(const Point2 &p_pos, Node *p_node, const Transform2D &p_parent_xform, const Transform2D &p_canvas_xform) {
-
- if (!p_node)
- return NULL;
- if (p_node->cast_to<Viewport>())
- return NULL;
-
- CanvasItem *c = p_node->cast_to<CanvasItem>();
-
- for (int i = p_node->get_child_count() - 1; i >= 0; i--) {
-
- CanvasItem *r = NULL;
-
- if (c && !c->is_set_as_toplevel())
- r = _select_canvas_item_at_pos(p_pos, p_node->get_child(i), p_parent_xform * c->get_transform(), p_canvas_xform);
- else {
- CanvasLayer *cl = p_node->cast_to<CanvasLayer>();
- r = _select_canvas_item_at_pos(p_pos, p_node->get_child(i), transform, cl ? cl->get_transform() : p_canvas_xform); //use base transform
- }
-
- if (r)
- return r;
- }
-
- if (c && c->is_visible_in_tree() && !c->has_meta("_edit_lock_") && !_is_part_of_subscene(c) && !c->cast_to<CanvasLayer>()) {
-
- Rect2 rect = c->get_item_rect();
- Point2 local_pos = (p_parent_xform * p_canvas_xform * c->get_transform()).affine_inverse().xform(p_pos);
-
- if (rect.has_point(local_pos))
- return c;
- }
-
- return NULL;
-}
-
-void CanvasItemEditor::_find_canvas_items_at_pos(const Point2 &p_pos, Node *p_node, const Transform2D &p_parent_xform, const Transform2D &p_canvas_xform, Vector<_SelectResult> &r_items) {
+void CanvasItemEditor::_find_canvas_items_at_pos(const Point2 &p_pos, Node *p_node, const Transform2D &p_parent_xform, const Transform2D &p_canvas_xform, Vector<_SelectResult> &r_items, unsigned int limit) {
if (!p_node)
return;
if (p_node->cast_to<Viewport>())
@@ -483,6 +462,9 @@ void CanvasItemEditor::_find_canvas_items_at_pos(const Point2 &p_pos, Node *p_no
CanvasLayer *cl = p_node->cast_to<CanvasLayer>();
_find_canvas_items_at_pos(p_pos, p_node->get_child(i), transform, cl ? cl->get_transform() : p_canvas_xform, r_items); //use base transform
}
+
+ if (limit != 0 && r_items.size() >= limit)
+ return;
}
if (c && c->is_visible_in_tree() && !c->has_meta("_edit_lock_") && !c->cast_to<CanvasLayer>()) {
@@ -546,72 +528,50 @@ void CanvasItemEditor::_find_canvas_items_at_rect(const Rect2 &p_rect, Node *p_n
}
}
-bool CanvasItemEditor::_select(CanvasItem *item, Point2 p_click_pos, bool p_append, bool p_drag) {
-
- if (p_append) {
- //additive selection
-
- if (!item) {
-
- if (p_drag) {
- drag_from = transform.affine_inverse().xform(p_click_pos);
-
- box_selecting = true;
- box_selecting_to = drag_from;
- }
+void CanvasItemEditor::_select_click_on_empty_area(Point2 p_click_pos, bool p_append, bool p_box_selection) {
+ if (!p_append) {
+ editor_selection->clear();
+ viewport->update();
+ };
- return false; //nothing to add
- }
+ if (p_box_selection) {
+ // Start a box selection
+ drag_from = transform.affine_inverse().xform(p_click_pos);
+ box_selecting = true;
+ box_selecting_to = drag_from;
+ }
+}
+bool CanvasItemEditor::_select_click_on_item(CanvasItem *item, Point2 p_click_pos, bool p_append, bool p_drag) {
+ bool still_selected = true;
+ if (p_append) {
if (editor_selection->is_selected(item)) {
- //already in here, erase it
+ // Already in the selection, remove it from the selected nodes
editor_selection->remove_node(item);
- //_remove_canvas_item(c);
-
- viewport->update();
- return false;
+ still_selected = false;
+ } else {
+ // Add the item to the selection
+ _append_canvas_item(item);
}
- _append_canvas_item(item);
- viewport->update();
-
- return true;
-
} else {
- //regular selection
-
- if (!item) {
- //clear because nothing clicked
- editor_selection->clear();
-
- if (p_drag) {
- drag_from = transform.affine_inverse().xform(p_click_pos);
-
- box_selecting = true;
- box_selecting_to = drag_from;
- }
-
- viewport->update();
- return false;
- }
-
if (!editor_selection->is_selected(item)) {
- //select a new one and clear previous selection
+ // Select a new one and clear previous selection
editor_selection->clear();
editor_selection->add_node(item);
- //reselect
+ // Reselect
if (get_tree()->is_editor_hint()) {
editor->call("edit_node", item);
}
}
+ }
- if (p_drag) {
- _prepare_drag(p_click_pos);
- }
-
- viewport->update();
-
- return true;
+ if (still_selected && p_drag) {
+ // Drag the node(s) if requested
+ _prepare_drag(p_click_pos);
}
+
+ viewport->update();
+ return still_selected;
}
void CanvasItemEditor::_key_move(const Vector2 &p_dir, bool p_snap, KeyMoveMODE p_move_mode) {
@@ -747,7 +707,7 @@ CanvasItem *CanvasItemEditor::get_single_item() {
return single_item;
}
-CanvasItemEditor::DragType CanvasItemEditor::_find_drag_type(const Transform2D &p_xform, const Rect2 &p_local_rect, const Point2 &p_click, Vector2 &r_point) {
+CanvasItemEditor::DragType CanvasItemEditor::_find_drag_type(const Point2 &p_click, Vector2 &r_point) {
CanvasItem *canvas_item = get_single_item();
@@ -786,8 +746,6 @@ CanvasItemEditor::DragType CanvasItemEditor::_find_drag_type(const Transform2D &
float radius = (select_handle->get_size().width / 2) * 1.5;
- //try draggers
-
for (int i = 0; i < 4; i++) {
int prev = (i + 3) % 4;
@@ -812,14 +770,6 @@ CanvasItemEditor::DragType CanvasItemEditor::_find_drag_type(const Transform2D &
return dragger[i * 2 + 1];
}
- /*
- if (rect.has_point(xform.affine_inverse().xform(p_click))) {
- r_point=_find_topleftmost_point();
- return DRAG_ALL;
- }*/
-
- //try draggers
-
return DRAG_NONE;
}
@@ -842,6 +792,8 @@ void CanvasItemEditor::_prepare_drag(const Point2 &p_click_pos) {
se->undo_state = canvas_item->edit_get_state();
if (canvas_item->cast_to<Node2D>())
se->undo_pivot = canvas_item->cast_to<Node2D>()->edit_get_pivot();
+ if (canvas_item->cast_to<Control>())
+ se->undo_pivot = canvas_item->cast_to<Control>()->get_pivot_offset();
}
if (selection.size() == 1 && selection[0]->cast_to<Node2D>()) {
@@ -945,7 +897,7 @@ void CanvasItemEditor::_selection_result_pressed(int p_result) {
CanvasItem *item = selection_results[p_result].item;
if (item)
- _select(item, Point2(), additive_selection, false);
+ _select_click_on_item(item, Point2(), additive_selection, false);
}
void CanvasItemEditor::_selection_menu_hide() {
@@ -985,7 +937,8 @@ void CanvasItemEditor::_list_select(const Ref<InputEventMouseButton> &b) {
selection_results.clear();
additive_selection = b->get_shift();
- if (!_select(item, click, additive_selection, false))
+
+ if (!_select_click_on_item(item, click, additive_selection, false))
return;
} else if (!selection_results.empty()) {
@@ -1027,7 +980,6 @@ void CanvasItemEditor::_list_select(const Ref<InputEventMouseButton> &b) {
void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) {
{
-
EditorNode *en = editor;
EditorPluginList *over_plugin_list = en->get_editor_plugins_over();
@@ -1041,11 +993,11 @@ void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) {
}
Ref<InputEventMouseButton> b = p_event;
-
if (b.is_valid()) {
+ // Button event
if (b->get_button_index() == BUTTON_WHEEL_DOWN) {
-
+ // Scroll or pan down
if (bool(EditorSettings::get_singleton()->get("editors/2d/scroll_to_pan"))) {
v_scroll->set_value(v_scroll->get_value() + int(EditorSettings::get_singleton()->get("editors/2d/pan_speed")) / zoom * b->get_factor());
@@ -1071,7 +1023,7 @@ void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) {
}
if (b->get_button_index() == BUTTON_WHEEL_UP) {
-
+ // Scroll or pan up
if (bool(EditorSettings::get_singleton()->get("editors/2d/scroll_to_pan"))) {
v_scroll->set_value(v_scroll->get_value() - int(EditorSettings::get_singleton()->get("editors/2d/pan_speed")) / zoom * b->get_factor());
@@ -1095,7 +1047,7 @@ void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) {
}
if (b->get_button_index() == BUTTON_WHEEL_LEFT) {
-
+ // Pan left
if (bool(EditorSettings::get_singleton()->get("editors/2d/scroll_to_pan"))) {
h_scroll->set_value(h_scroll->get_value() - int(EditorSettings::get_singleton()->get("editors/2d/pan_speed")) / zoom * b->get_factor());
@@ -1103,7 +1055,7 @@ void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) {
}
if (b->get_button_index() == BUTTON_WHEEL_RIGHT) {
-
+ // Pan right
if (bool(EditorSettings::get_singleton()->get("editors/2d/scroll_to_pan"))) {
h_scroll->set_value(h_scroll->get_value() + int(EditorSettings::get_singleton()->get("editors/2d/pan_speed")) / zoom * b->get_factor());
@@ -1113,29 +1065,24 @@ void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) {
if (b->get_button_index() == BUTTON_RIGHT) {
if (b->is_pressed() && (tool == TOOL_SELECT && b->get_alt())) {
-
+ // Open the selection list
_list_select(b);
return;
}
if (get_item_count() > 0 && drag != DRAG_NONE) {
- //cancel drag
-
+ // Cancel a drag
if (bone_ik_list.size()) {
-
for (List<BoneIK>::Element *E = bone_ik_list.back(); E; E = E->prev()) {
-
E->get().node->edit_set_state(E->get().orig_state);
}
bone_ik_list.clear();
} else {
-
List<Node *> &selection = editor_selection->get_selected_node_list();
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
-
CanvasItem *canvas_item = E->get()->cast_to<CanvasItem>();
if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
@@ -1149,6 +1096,8 @@ void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) {
canvas_item->edit_set_state(se->undo_state);
if (canvas_item->cast_to<Node2D>())
canvas_item->cast_to<Node2D>()->edit_set_pivot(se->undo_pivot);
+ if (canvas_item->cast_to<Control>())
+ canvas_item->cast_to<Control>()->set_pivot_offset(se->undo_pivot);
}
}
@@ -1157,33 +1106,23 @@ void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) {
can_move_pivot = false;
} else if (box_selecting) {
+ // Cancel box selection
box_selecting = false;
viewport->update();
- } else if (b->is_pressed()) {
-#if 0
- ref_item = NULL;
- Node* scene = get_scene()->get_root_node()->cast_to<EditorNode>()->get_edited_scene();
- if ( scene ) ref_item =_select_canvas_item_at_pos( Point2( b.x, b.y ), scene, transform );
-#endif
- //popup->set_position(Point2(b.x,b.y));
- //popup->popup();
}
return;
}
- /*
- if (!canvas_items.size())
- return;
- */
if (b->get_button_index() == BUTTON_LEFT && tool == TOOL_LIST_SELECT) {
if (b->is_pressed())
+ // Open the selection list
_list_select(b);
return;
}
if (b->get_button_index() == BUTTON_LEFT && tool == TOOL_EDIT_PIVOT) {
if (b->is_pressed()) {
-
+ // Set the pivot point
Point2 mouse_pos = b->get_position();
mouse_pos = transform.affine_inverse().xform(mouse_pos);
mouse_pos = snap_point(mouse_pos);
@@ -1193,16 +1132,18 @@ void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) {
}
if (tool == TOOL_PAN || b->get_button_index() != BUTTON_LEFT || Input::get_singleton()->is_key_pressed(KEY_SPACE))
+ // Pan the view
return;
+ // -- From now we consider that the button is BUTTON_LEFT --
+
if (!b->is_pressed()) {
if (drag != DRAG_NONE) {
-
+ // Stop dragging
if (undo_redo) {
if (bone_ik_list.size()) {
-
undo_redo->create_action(TTR("Edit IK Chain"));
for (List<BoneIK>::Element *E = bone_ik_list.back(); E; E = E->prev()) {
@@ -1218,7 +1159,6 @@ void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) {
undo_redo->commit_action();
} else {
-
undo_redo->create_action(TTR("Edit CanvasItem"));
List<Node *> &selection = editor_selection->get_selected_node_list();
@@ -1238,12 +1178,18 @@ void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) {
Variant state = canvas_item->edit_get_state();
undo_redo->add_do_method(canvas_item, "edit_set_state", state);
undo_redo->add_undo_method(canvas_item, "edit_set_state", se->undo_state);
- if (canvas_item->cast_to<Node2D>()) {
+ {
Node2D *pvt = canvas_item->cast_to<Node2D>();
- if (pvt->edit_has_pivot()) {
+ if (pvt && pvt->edit_has_pivot()) {
undo_redo->add_do_method(canvas_item, "edit_set_pivot", pvt->edit_get_pivot());
undo_redo->add_undo_method(canvas_item, "edit_set_pivot", se->undo_pivot);
}
+
+ Control *cnt = canvas_item->cast_to<Control>();
+ if (cnt) {
+ undo_redo->add_do_method(canvas_item, "set_pivot_offset", cnt->get_pivot_offset());
+ undo_redo->add_undo_method(canvas_item, "set_pivot_offset", se->undo_pivot);
+ }
}
}
undo_redo->commit_action();
@@ -1256,11 +1202,7 @@ void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) {
}
if (box_selecting) {
-#if 0
- if ( ! b->get_shift() ) _clear_canvas_items();
- if ( box_selection_end() ) return;
-#endif
-
+ // Stop box selection
Node *scene = editor->get_edited_scene();
if (scene) {
@@ -1287,6 +1229,8 @@ void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) {
return;
}
+ // -- From now we consider that the button is BUTTON_LEFT and that it is pressed --
+
Map<ObjectID, BoneList>::Element *Cbone = NULL; //closest
{
@@ -1361,93 +1305,79 @@ void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) {
}
}
- CanvasItem *single_item = get_single_item();
-
- if (single_item) {
- //try single canvas_item edit
-
- CanvasItem *canvas_item = single_item;
+ // Single selected item
+ CanvasItem *canvas_item = get_single_item();
+ if (canvas_item) {
CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item);
ERR_FAIL_COND(!se);
Point2 click = b->get_position();
+ // Rotation
if ((b->get_control() && tool == TOOL_SELECT) || tool == TOOL_ROTATE) {
-
drag = DRAG_ROTATE;
drag_from = transform.affine_inverse().xform(click);
se->undo_state = canvas_item->edit_get_state();
if (canvas_item->cast_to<Node2D>())
se->undo_pivot = canvas_item->cast_to<Node2D>()->edit_get_pivot();
if (canvas_item->cast_to<Control>())
- se->undo_pivot = Vector2();
+ se->undo_pivot = canvas_item->cast_to<Control>()->get_pivot_offset();
return;
}
- Transform2D xform = transform * canvas_item->get_global_transform_with_canvas();
- Rect2 rect = canvas_item->get_item_rect();
- //float handle_radius = handle_len * 1.4144; //magic number, guess what it means!
-
if (tool == TOOL_SELECT) {
- drag = _find_drag_type(xform, rect, click, drag_point_from);
-
+ // Open a sub-scene on double-click
if (b->is_doubleclick()) {
-
if (canvas_item->get_filename() != "" && canvas_item != editor->get_edited_scene()) {
-
editor->open_request(canvas_item->get_filename());
return;
}
}
- if (drag != DRAG_NONE && (!Cbone || drag != DRAG_ALL)) {
+ // Drag
+ drag = _find_drag_type(click, drag_point_from);
+ if (drag != DRAG_NONE) {
drag_from = transform.affine_inverse().xform(click);
se->undo_state = canvas_item->edit_get_state();
if (canvas_item->cast_to<Node2D>())
se->undo_pivot = canvas_item->cast_to<Node2D>()->edit_get_pivot();
-
+ if (canvas_item->cast_to<Control>())
+ se->undo_pivot = canvas_item->cast_to<Control>()->get_pivot_offset();
return;
}
- } else {
-
- drag = DRAG_NONE;
}
}
- //multi canvas_item edit
-
+ // Multiple selected items
Point2 click = b->get_position();
if ((b->get_alt() || tool == TOOL_MOVE) && get_item_count()) {
+ // Drag the nodes
_prepare_drag(click);
viewport->update();
return;
}
- Node *scene = editor->get_edited_scene();
- if (!scene)
- return;
-
- /*
- if (current_window) {
- //no window.... ?
- click-=current_window->get_scroll();
- }*/
CanvasItem *c = NULL;
-
if (Cbone) {
-
Object *obj = ObjectDB::get_instance(Cbone->get().bone);
if (obj)
c = obj->cast_to<CanvasItem>();
if (c)
c = c->get_parent_item();
}
+
+ Node *scene = editor->get_edited_scene();
+ if (!scene)
+ return;
+ // Find the item to select
if (!c) {
- c = _select_canvas_item_at_pos(click, scene, transform, Transform2D());
+ Vector<_SelectResult> selection;
+ _find_canvas_items_at_pos(click, scene, transform, Transform2D(), selection, 1);
+ if (!selection.empty())
+ c = selection[0].item;
CanvasItem *cn = c;
-
while (cn) {
if (cn->has_meta("_edit_group_")) {
c = cn;
@@ -1457,28 +1387,29 @@ void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) {
}
Node *n = c;
-
while ((n && n != scene && n->get_owner() != scene) || (n && !n->is_class("CanvasItem"))) {
n = n->get_parent();
};
c = n->cast_to<CanvasItem>();
-#if 0
- if ( b->is_pressed() ) box_selection_start( click );
-#endif
+ // Select the item
additive_selection = b->get_shift();
- if (!_select(c, click, additive_selection))
+ if (!c) {
+ _select_click_on_empty_area(click, additive_selection, true);
+ } else if (!_select_click_on_item(c, click, additive_selection, true)) {
return;
+ }
}
Ref<InputEventMouseMotion> m = p_event;
if (m.is_valid()) {
+ // Mouse motion event
if (!viewport->has_focus() && (!get_focus_owner() || !get_focus_owner()->is_text_field()))
viewport->call_deferred("grab_focus");
if (box_selecting) {
-
+ // Update box selection
box_selecting_to = transform.affine_inverse().xform(m->get_position());
viewport->update();
return;
@@ -1522,6 +1453,8 @@ void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) {
canvas_item->edit_set_state(se->undo_state); //reset state and reapply
if (canvas_item->cast_to<Node2D>())
canvas_item->cast_to<Node2D>()->edit_set_pivot(se->undo_pivot);
+ if (canvas_item->cast_to<Control>())
+ canvas_item->cast_to<Control>()->set_pivot_offset(se->undo_pivot);
}
Vector2 dfrom = drag_from;
@@ -1585,8 +1518,21 @@ void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) {
Vector2 minsize = canvas_item->edit_get_minimum_size();
if (uniform) {
+ // Keep the height/width ratio of the item
float aspect = local_rect.size.aspect();
switch (drag) {
+ case DRAG_LEFT: {
+ drag_vector.y = -drag_vector.x / aspect;
+ } break;
+ case DRAG_RIGHT: {
+ drag_vector.y = drag_vector.x / aspect;
+ } break;
+ case DRAG_TOP: {
+ drag_vector.x = -drag_vector.y * aspect;
+ } break;
+ case DRAG_BOTTOM: {
+ drag_vector.x = drag_vector.y * aspect;
+ } break;
case DRAG_BOTTOM_LEFT:
case DRAG_TOP_RIGHT: {
if (aspect > 1.0) { // width > height, take x as reference
@@ -1603,7 +1549,17 @@ void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) {
drag_vector.x = drag_vector.y * aspect;
}
} break;
- default: {}
+ }
+ } else {
+ switch (drag) {
+ case DRAG_RIGHT:
+ case DRAG_LEFT: {
+ drag_vector.y = 0;
+ } break;
+ case DRAG_TOP:
+ case DRAG_BOTTOM: {
+ drag_vector.x = 0;
+ } break;
}
}
@@ -1612,44 +1568,25 @@ void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) {
begin += drag_vector;
end += drag_vector;
} break;
- case DRAG_RIGHT: {
-
- incend(begin.x, end.x, drag_vector.x, minsize.x, symmetric);
-
- } break;
- case DRAG_BOTTOM: {
-
- incend(begin.y, end.y, drag_vector.y, minsize.y, symmetric);
-
- } break;
+ case DRAG_RIGHT:
+ case DRAG_BOTTOM:
case DRAG_BOTTOM_RIGHT: {
-
incend(begin.x, end.x, drag_vector.x, minsize.x, symmetric);
incend(begin.y, end.y, drag_vector.y, minsize.y, symmetric);
} break;
- case DRAG_TOP_LEFT: {
+ case DRAG_TOP_LEFT: {
incbeg(begin.x, end.x, drag_vector.x, minsize.x, symmetric);
incbeg(begin.y, end.y, drag_vector.y, minsize.y, symmetric);
} break;
- case DRAG_TOP: {
- incbeg(begin.y, end.y, drag_vector.y, minsize.y, symmetric);
-
- } break;
- case DRAG_LEFT: {
-
- incbeg(begin.x, end.x, drag_vector.x, minsize.x, symmetric);
-
- } break;
+ case DRAG_TOP:
case DRAG_TOP_RIGHT: {
-
incbeg(begin.y, end.y, drag_vector.y, minsize.y, symmetric);
incend(begin.x, end.x, drag_vector.x, minsize.x, symmetric);
-
} break;
+ case DRAG_LEFT:
case DRAG_BOTTOM_LEFT: {
-
incbeg(begin.x, end.x, drag_vector.x, minsize.x, symmetric);
incend(begin.y, end.y, drag_vector.y, minsize.y, symmetric);
} break;
@@ -1659,6 +1596,9 @@ void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) {
Node2D *n2d = canvas_item->cast_to<Node2D>();
n2d->edit_set_pivot(se->undo_pivot + drag_vector);
}
+ if (canvas_item->cast_to<Control>()) {
+ canvas_item->cast_to<Control>()->set_pivot_offset(se->undo_pivot + drag_vector);
+ }
continue;
} break;
case DRAG_NODE_2D: {
@@ -1795,11 +1735,9 @@ void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) {
}
Ref<InputEventKey> k = p_event;
-
if (k.is_valid()) {
-
if (k->is_pressed() && drag == DRAG_NONE) {
-
+ // Move the object with the arrow keys
KeyMoveMODE move_mode = MOVE_VIEW_BASE;
if (k->get_alt()) move_mode = MOVE_LOCAL_BASE;
if (k->get_control() || k->get_metakey()) move_mode = MOVE_LOCAL_WITH_ROT;
@@ -1832,13 +1770,23 @@ void CanvasItemEditor::_viewport_draw() {
RID ci = viewport->get_canvas_item();
if (snap_show_grid) {
+ //Draw the grid
Size2 s = viewport->get_size();
int last_cell;
Transform2D xform = transform.affine_inverse();
+ Vector2 grid_offset;
+ if (snap_relative && snap_grid && get_item_count() > 0) {
+ Vector2 topleft = _find_topleftmost_point();
+ grid_offset.x = fmod(topleft.x, snap_step.x);
+ grid_offset.y = fmod(topleft.y, snap_step.y);
+ } else {
+ grid_offset = snap_offset;
+ }
+
if (snap_step.x != 0) {
for (int i = 0; i < s.width; i++) {
- int cell = Math::fast_ftoi(Math::floor((xform.xform(Vector2(i, 0)).x - snap_offset.x) / snap_step.x));
+ int cell = Math::fast_ftoi(Math::floor((xform.xform(Vector2(i, 0)).x - grid_offset.x) / snap_step.x));
if (i == 0)
last_cell = cell;
if (last_cell != cell)
@@ -1849,7 +1797,7 @@ void CanvasItemEditor::_viewport_draw() {
if (snap_step.y != 0) {
for (int i = 0; i < s.height; i++) {
- int cell = Math::fast_ftoi(Math::floor((xform.xform(Vector2(0, i)).y - snap_offset.y) / snap_step.y));
+ int cell = Math::fast_ftoi(Math::floor((xform.xform(Vector2(0, i)).y - grid_offset.y) / snap_step.y));
if (i == 0)
last_cell = cell;
if (last_cell != cell)
@@ -1861,11 +1809,6 @@ void CanvasItemEditor::_viewport_draw() {
if (viewport->has_focus()) {
Size2 size = viewport->get_size();
- if (v_scroll->is_visible_in_tree())
- size.width -= v_scroll->get_size().width;
- if (h_scroll->is_visible_in_tree())
- size.height -= h_scroll->get_size().height;
-
get_stylebox("Focus", "EditorStyles")->draw(ci, Rect2(Point2(), size));
}
@@ -1920,6 +1863,14 @@ void CanvasItemEditor::_viewport_draw() {
pivot_found = true;
}
}
+ if (canvas_item->cast_to<Control>()) {
+ Vector2 pivot_ofs = canvas_item->cast_to<Control>()->get_pivot_offset();
+ if (pivot_ofs != Vector2()) {
+ viewport->draw_texture(pivot, xform.xform(pivot_ofs) + (-pivot->get_size() / 2).floor());
+ }
+ can_move_pivot = true;
+ pivot_found = true;
+ }
if (tool == TOOL_SELECT) {
@@ -1968,7 +1919,7 @@ void CanvasItemEditor::_viewport_draw() {
VisualServer::get_singleton()->canvas_item_add_line(ci, transform.xform(display_rotate_from), transform.xform(display_rotate_to), rotate_color);
}
- Size2 screen_size = Size2(GlobalConfig::get_singleton()->get("display/window/width"), GlobalConfig::get_singleton()->get("display/window/height"));
+ Size2 screen_size = Size2(ProjectSettings::get_singleton()->get("display/window/size/width"), ProjectSettings::get_singleton()->get("display/window/size/height"));
Vector2 screen_endpoints[4] = {
transform.xform(Vector2(0, 0)),
@@ -2108,10 +2059,16 @@ void CanvasItemEditor::_notification(int p_what) {
Transform2D xform = canvas_item->get_transform();
- if (r != se->prev_rect || xform != se->prev_xform) {
+ Vector2 pivot;
+ if (canvas_item->cast_to<Control>()) {
+ pivot = canvas_item->cast_to<Control>()->get_pivot_offset();
+ }
+
+ if (r != se->prev_rect || xform != se->prev_xform || pivot != se->prev_pivot) {
viewport->update();
se->prev_rect = r;
se->prev_xform = xform;
+ se->prev_pivot = pivot;
}
}
@@ -2189,6 +2146,7 @@ void CanvasItemEditor::_notification(int p_what) {
p->add_icon_item(get_icon("ControlHcenterWide", "EditorIcons"), "HCenter Wide ", ANCHOR_ALIGN_HCENTER_WIDE);
p->add_separator();
p->add_icon_item(get_icon("ControlAlignWide", "EditorIcons"), "Full Rect", ANCHOR_ALIGN_WIDE);
+ p->add_icon_item(get_icon("ControlAlignWide", "EditorIcons"), "Full Rect and Fit Parent", ANCHOR_ALIGN_WIDE_FIT);
AnimationPlayerEditor::singleton->get_key_editor()->connect("visibility_changed", this, "_keying_changed");
_keying_changed();
@@ -2277,7 +2235,7 @@ void CanvasItemEditor::_update_scrollbars() {
h_scroll->set_begin(Point2(0, size.height - hmin.height));
h_scroll->set_end(Point2(size.width - vmin.width, size.height));
- Size2 screen_rect = Size2(GlobalConfig::get_singleton()->get("display/window/width"), GlobalConfig::get_singleton()->get("display/window/height"));
+ Size2 screen_rect = Size2(ProjectSettings::get_singleton()->get("display/window/size/width"), ProjectSettings::get_singleton()->get("display/window/size/height"));
Rect2 local_rect = Rect2(Point2(), viewport->get_size() - Size2(vmin.width, hmin.height));
@@ -2394,6 +2352,35 @@ void CanvasItemEditor::_set_anchor(Control::AnchorType p_left, Control::AnchorTy
undo_redo->commit_action();
}
+void CanvasItemEditor::_set_full_rect() {
+ List<Node *> &selection = editor_selection->get_selected_node_list();
+
+ undo_redo->create_action(TTR("Change Anchors"));
+ for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
+
+ Control *c = E->get()->cast_to<Control>();
+
+ undo_redo->add_do_method(c, "set_anchor", MARGIN_LEFT, ANCHOR_BEGIN);
+ undo_redo->add_do_method(c, "set_anchor", MARGIN_TOP, ANCHOR_BEGIN);
+ undo_redo->add_do_method(c, "set_anchor", MARGIN_RIGHT, ANCHOR_END);
+ undo_redo->add_do_method(c, "set_anchor", MARGIN_BOTTOM, ANCHOR_END);
+ undo_redo->add_do_method(c, "set_margin", MARGIN_LEFT, 0);
+ undo_redo->add_do_method(c, "set_margin", MARGIN_TOP, 0);
+ undo_redo->add_do_method(c, "set_margin", MARGIN_RIGHT, 0);
+ undo_redo->add_do_method(c, "set_margin", MARGIN_BOTTOM, 0);
+ undo_redo->add_undo_method(c, "set_anchor", MARGIN_LEFT, c->get_anchor(MARGIN_LEFT));
+ undo_redo->add_undo_method(c, "set_anchor", MARGIN_TOP, c->get_anchor(MARGIN_TOP));
+ undo_redo->add_undo_method(c, "set_anchor", MARGIN_RIGHT, c->get_anchor(MARGIN_RIGHT));
+ undo_redo->add_undo_method(c, "set_anchor", MARGIN_BOTTOM, c->get_anchor(MARGIN_BOTTOM));
+ undo_redo->add_undo_method(c, "set_margin", MARGIN_LEFT, c->get_margin(MARGIN_LEFT));
+ undo_redo->add_undo_method(c, "set_margin", MARGIN_TOP, c->get_margin(MARGIN_TOP));
+ undo_redo->add_undo_method(c, "set_margin", MARGIN_RIGHT, c->get_margin(MARGIN_RIGHT));
+ undo_redo->add_undo_method(c, "set_margin", MARGIN_BOTTOM, c->get_margin(MARGIN_BOTTOM));
+ }
+
+ undo_redo->commit_action();
+}
+
void CanvasItemEditor::_popup_callback(int p_op) {
last_option = MenuOption(p_op);
@@ -2403,6 +2390,7 @@ void CanvasItemEditor::_popup_callback(int p_op) {
snap_grid = !snap_grid;
int idx = edit_menu->get_popup()->get_item_index(SNAP_USE);
edit_menu->get_popup()->set_item_checked(idx, snap_grid);
+ viewport->update();
} break;
case SNAP_SHOW_GRID: {
snap_show_grid = !snap_show_grid;
@@ -2419,6 +2407,7 @@ void CanvasItemEditor::_popup_callback(int p_op) {
snap_relative = !snap_relative;
int idx = edit_menu->get_popup()->get_item_index(SNAP_RELATIVE);
edit_menu->get_popup()->set_item_checked(idx, snap_relative);
+ viewport->update();
} break;
case SNAP_USE_PIXEL: {
snap_pixel = !snap_pixel;
@@ -2551,29 +2540,6 @@ void CanvasItemEditor::_popup_callback(int p_op) {
} break;
- case EXPAND_TO_PARENT: {
-
- List<Node *> &selection = editor_selection->get_selected_node_list();
-
- for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
-
- CanvasItem *canvas_item = E->get()->cast_to<CanvasItem>();
- if (!canvas_item || !canvas_item->is_visible_in_tree())
- continue;
-
- if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
- continue;
-
- Control *c = canvas_item->cast_to<Control>();
- if (!c)
- continue;
- c->set_area_as_parent_rect();
- }
-
- viewport->update();
-
- } break;
-
case ALIGN_VERTICAL: {
#if 0
if ( ref_item && canvas_items.size() > 1 ) {
@@ -2666,6 +2632,9 @@ void CanvasItemEditor::_popup_callback(int p_op) {
case ANCHOR_ALIGN_WIDE: {
_set_anchor(ANCHOR_BEGIN, ANCHOR_BEGIN, ANCHOR_END, ANCHOR_END);
} break;
+ case ANCHOR_ALIGN_WIDE_FIT: {
+ _set_full_rect();
+ } break;
case ANIM_INSERT_KEY:
case ANIM_INSERT_KEY_EXISTING: {
@@ -3281,8 +3250,6 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
p->add_separator();
p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/use_pixel_snap", TTR("Use Pixel Snap")), SNAP_USE_PIXEL);
p->add_separator();
- p->add_shortcut(ED_SHORTCUT("canvas_item_editor/expand_to_parent", TTR("Expand to Parent"), KEY_MASK_CMD | KEY_P), EXPAND_TO_PARENT);
- p->add_separator();
p->add_submenu_item(TTR("Skeleton.."), "skeleton");
skeleton_menu = memnew(PopupMenu);
p->add_child(skeleton_menu);
@@ -3333,6 +3300,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
key_loc_button = memnew(Button("loc"));
key_loc_button->set_toggle_mode(true);
+ key_loc_button->set_flat(true);
key_loc_button->set_pressed(true);
key_loc_button->set_focus_mode(FOCUS_NONE);
key_loc_button->add_color_override("font_color", Color(1, 0.6, 0.6));
@@ -3341,6 +3309,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
animation_hb->add_child(key_loc_button);
key_rot_button = memnew(Button("rot"));
key_rot_button->set_toggle_mode(true);
+ key_rot_button->set_flat(true);
key_rot_button->set_pressed(true);
key_rot_button->set_focus_mode(FOCUS_NONE);
key_rot_button->add_color_override("font_color", Color(1, 0.6, 0.6));
@@ -3349,12 +3318,14 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
animation_hb->add_child(key_rot_button);
key_scale_button = memnew(Button("scl"));
key_scale_button->set_toggle_mode(true);
+ key_scale_button->set_flat(true);
key_scale_button->set_focus_mode(FOCUS_NONE);
key_scale_button->add_color_override("font_color", Color(1, 0.6, 0.6));
key_scale_button->add_color_override("font_color_pressed", Color(0.6, 1, 0.6));
key_scale_button->connect("pressed", this, "_popup_callback", varray(ANIM_INSERT_SCALE));
animation_hb->add_child(key_scale_button);
key_insert_button = memnew(Button);
+ key_insert_button->set_flat(true);
key_insert_button->set_focus_mode(FOCUS_NONE);
key_insert_button->connect("pressed", this, "_popup_callback", varray(ANIM_INSERT_KEY));
key_insert_button->set_tooltip(TTR("Insert Keys"));
@@ -3640,7 +3611,7 @@ bool CanvasItemEditorViewport::_create_instance(Node *parent, String &path, cons
}
}
- instanced_scene->set_filename(GlobalConfig::get_singleton()->localize_path(path));
+ instanced_scene->set_filename(ProjectSettings::get_singleton()->localize_path(path));
editor_data->get_undo_redo().add_do_method(parent, "add_child", instanced_scene);
editor_data->get_undo_redo().add_do_method(instanced_scene, "set_owner", editor->get_edited_scene());
diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h
index 22fa5b5db8..4383be251c 100644
--- a/editor/plugins/canvas_item_editor_plugin.h
+++ b/editor/plugins/canvas_item_editor_plugin.h
@@ -56,6 +56,7 @@ public:
Transform2D prev_xform;
float prev_rot;
Rect2 prev_rect;
+ Vector2 prev_pivot;
CanvasItemEditorSelectedItem() { prev_rot = 0; }
};
@@ -110,10 +111,10 @@ class CanvasItemEditor : public VBoxContainer {
ANCHOR_ALIGN_VCENTER_WIDE,
ANCHOR_ALIGN_HCENTER_WIDE,
ANCHOR_ALIGN_WIDE,
+ ANCHOR_ALIGN_WIDE_FIT,
SPACE_HORIZONTAL,
SPACE_VERTICAL,
- EXPAND_TO_PARENT,
ANIM_INSERT_KEY,
ANIM_INSERT_KEY_EXISTING,
ANIM_INSERT_POS,
@@ -302,11 +303,11 @@ class CanvasItemEditor : public VBoxContainer {
int handle_len;
bool _is_part_of_subscene(CanvasItem *p_item);
- CanvasItem *_select_canvas_item_at_pos(const Point2 &p_pos, Node *p_node, const Transform2D &p_parent_xform, const Transform2D &p_canvas_xform);
- void _find_canvas_items_at_pos(const Point2 &p_pos, Node *p_node, const Transform2D &p_parent_xform, const Transform2D &p_canvas_xform, Vector<_SelectResult> &r_items);
+ void _find_canvas_items_at_pos(const Point2 &p_pos, Node *p_node, const Transform2D &p_parent_xform, const Transform2D &p_canvas_xform, Vector<_SelectResult> &r_items, unsigned int limit = 0);
void _find_canvas_items_at_rect(const Rect2 &p_rect, Node *p_node, const Transform2D &p_parent_xform, const Transform2D &p_canvas_xform, List<CanvasItem *> *r_items);
- bool _select(CanvasItem *item, Point2 p_click_pos, bool p_append, bool p_drag = true);
+ void _select_click_on_empty_area(Point2 p_click_pos, bool p_append, bool p_box_selection);
+ bool _select_click_on_item(CanvasItem *item, Point2 p_click_pos, bool p_append, bool p_drag);
ConfirmationDialog *snap_dialog;
@@ -324,7 +325,7 @@ class CanvasItemEditor : public VBoxContainer {
void _key_move(const Vector2 &p_dir, bool p_snap, KeyMoveMODE p_move_mode);
void _list_select(const Ref<InputEventMouseButton> &b);
- DragType _find_drag_type(const Transform2D &p_xform, const Rect2 &p_local_rect, const Point2 &p_click, Vector2 &r_point);
+ DragType _find_drag_type(const Point2 &p_click, Vector2 &r_point);
void _prepare_drag(const Point2 &p_click_pos);
void _popup_callback(int p_op);
@@ -360,6 +361,7 @@ class CanvasItemEditor : public VBoxContainer {
void _focus_selection(int p_op);
void _set_anchor(Control::AnchorType p_left, Control::AnchorType p_top, Control::AnchorType p_right, Control::AnchorType p_bottom);
+ void _set_full_rect();
HSplitContainer *palette_split;
VSplitContainer *bottom_split;
diff --git a/editor/plugins/collision_polygon_2d_editor_plugin.cpp b/editor/plugins/collision_polygon_2d_editor_plugin.cpp
index 43abea0131..346c00df64 100644
--- a/editor/plugins/collision_polygon_2d_editor_plugin.cpp
+++ b/editor/plugins/collision_polygon_2d_editor_plugin.cpp
@@ -99,7 +99,7 @@ bool CollisionPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event)
if (!node)
return false;
- Ref<InputEventMouseButton> mb;
+ Ref<InputEventMouseButton> mb = p_event;
if (mb.is_valid()) {
Transform2D xform = canvas_item_editor->get_canvas_transform() * node->get_global_transform();
@@ -112,7 +112,7 @@ bool CollisionPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event)
Vector<Vector2> poly = node->get_polygon();
//first check if a point is to be added (segment split)
- real_t grab_treshold = EDITOR_DEF("editors/poly_editor/point_grab_radius", 8);
+ real_t grab_threshold = EDITOR_DEF("editors/poly_editor/point_grab_radius", 8);
switch (mode) {
@@ -131,7 +131,7 @@ bool CollisionPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event)
return true;
} else {
- if (wip.size() > 1 && xform.xform(wip[0]).distance_to(gpoint) < grab_treshold) {
+ if (wip.size() > 1 && xform.xform(wip[0]).distance_to(gpoint) < grab_threshold) {
//wip closed
_wip_close();
@@ -185,7 +185,7 @@ bool CollisionPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event)
continue; //not valid to reuse point
real_t d = cp.distance_to(gpoint);
- if (d < closest_dist && d < grab_treshold) {
+ if (d < closest_dist && d < grab_threshold) {
closest_dist = d;
closest_pos = cp;
closest_idx = i;
@@ -214,7 +214,7 @@ bool CollisionPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event)
Vector2 cp = xform.xform(poly[i]);
real_t d = cp.distance_to(gpoint);
- if (d < closest_dist && d < grab_treshold) {
+ if (d < closest_dist && d < grab_threshold) {
closest_dist = d;
closest_pos = cp;
closest_idx = i;
@@ -259,7 +259,7 @@ bool CollisionPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event)
Vector2 cp = xform.xform(poly[i]);
real_t d = cp.distance_to(gpoint);
- if (d < closest_dist && d < grab_treshold) {
+ if (d < closest_dist && d < grab_threshold) {
closest_dist = d;
closest_pos = cp;
closest_idx = i;
diff --git a/editor/plugins/collision_polygon_editor_plugin.cpp b/editor/plugins/collision_polygon_editor_plugin.cpp
index c89e6f59a4..5b364ed2c1 100644
--- a/editor/plugins/collision_polygon_editor_plugin.cpp
+++ b/editor/plugins/collision_polygon_editor_plugin.cpp
@@ -35,339 +35,304 @@
#include "scene/3d/camera.h"
#include "spatial_editor_plugin.h"
-#if 0
-
void CollisionPolygonEditor::_notification(int p_what) {
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_READY: {
- button_create->set_icon( get_icon("Edit","EditorIcons"));
- button_edit->set_icon( get_icon("MovePoint","EditorIcons"));
+ button_create->set_icon(get_icon("Edit", "EditorIcons"));
+ button_edit->set_icon(get_icon("MovePoint", "EditorIcons"));
button_edit->set_pressed(true);
- get_tree()->connect("node_removed",this,"_node_removed");
-
+ get_tree()->connect("node_removed", this, "_node_removed");
} break;
case NOTIFICATION_PROCESS: {
if (node->get_depth() != prev_depth) {
_polygon_draw();
- prev_depth=node->get_depth();
+ prev_depth = node->get_depth();
}
} break;
}
-
}
void CollisionPolygonEditor::_node_removed(Node *p_node) {
- if(p_node==node) {
- node=NULL;
- if (imgeom->get_parent()==p_node)
+ if (p_node == node) {
+ node = NULL;
+ if (imgeom->get_parent() == p_node)
p_node->remove_child(imgeom);
hide();
set_process(false);
}
-
}
-
void CollisionPolygonEditor::_menu_option(int p_option) {
- switch(p_option) {
+ switch (p_option) {
case MODE_CREATE: {
- mode=MODE_CREATE;
+ mode = MODE_CREATE;
button_create->set_pressed(true);
button_edit->set_pressed(false);
} break;
case MODE_EDIT: {
- mode=MODE_EDIT;
+ mode = MODE_EDIT;
button_create->set_pressed(false);
button_edit->set_pressed(true);
} break;
-
}
}
void CollisionPolygonEditor::_wip_close() {
undo_redo->create_action(TTR("Create Poly3D"));
- undo_redo->add_undo_method(node,"set_polygon",node->get_polygon());
- undo_redo->add_do_method(node,"set_polygon",wip);
- undo_redo->add_do_method(this,"_polygon_draw");
- undo_redo->add_undo_method(this,"_polygon_draw");
+ undo_redo->add_undo_method(node, "set_polygon", node->get_polygon());
+ undo_redo->add_do_method(node, "set_polygon", wip);
+ undo_redo->add_do_method(this, "_polygon_draw");
+ undo_redo->add_undo_method(this, "_polygon_draw");
wip.clear();
- wip_active=false;
- mode=MODE_EDIT;
+ wip_active = false;
+ mode = MODE_EDIT;
button_edit->set_pressed(true);
button_create->set_pressed(false);
- edited_point=-1;
+ edited_point = -1;
undo_redo->commit_action();
-
}
-bool CollisionPolygonEditor::forward_spatial_gui_input(Camera* p_camera,const InputEvent& p_event) {
+bool CollisionPolygonEditor::forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event) {
if (!node)
return false;
Transform gt = node->get_global_transform();
Transform gi = gt.affine_inverse();
- float depth = node->get_depth()*0.5;
+ float depth = node->get_depth() * 0.5;
Vector3 n = gt.basis.get_axis(2).normalized();
- Plane p(gt.origin+n*depth,n);
-
-
- switch(p_event.type) {
+ Plane p(gt.origin + n * depth, n);
- case InputEvent::MOUSE_BUTTON: {
+ Ref<InputEventMouseButton> mb = p_event;
- const InputEventMouseButton &mb=p_event.mouse_button;
+ if (mb.is_valid()) {
+ Vector2 gpoint = mb->get_position();
+ Vector3 ray_from = p_camera->project_ray_origin(gpoint);
+ Vector3 ray_dir = p_camera->project_ray_normal(gpoint);
+ Vector3 spoint;
- Vector2 gpoint=Point2(mb->get_pos().x,mb->get_pos().y);
- Vector3 ray_from = p_camera->project_ray_origin(gpoint);
- Vector3 ray_dir = p_camera->project_ray_normal(gpoint);
-
- Vector3 spoint;
-
- if (!p.intersects_ray(ray_from,ray_dir,&spoint))
- break;
+ if (!p.intersects_ray(ray_from, ray_dir, &spoint))
+ return false;
- spoint = gi.xform(spoint);
+ spoint = gi.xform(spoint);
- Vector2 cpoint(spoint.x,spoint.y);
+ Vector2 cpoint(spoint.x, spoint.y);
- cpoint=CanvasItemEditor::get_singleton()->snap_point(cpoint);
+ cpoint = CanvasItemEditor::get_singleton()->snap_point(cpoint);
- Vector<Vector2> poly = node->get_polygon();
+ Vector<Vector2> poly = node->get_polygon();
- //first check if a point is to be added (segment split)
- real_t grab_treshold=EDITOR_DEF("editors/poly_editor/point_grab_radius",8);
+ //first check if a point is to be added (segment split)
+ real_t grab_treshold = EDITOR_DEF("editors/poly_editor/point_grab_radius", 8);
- switch(mode) {
+ switch (mode) {
+ case MODE_CREATE: {
- case MODE_CREATE: {
+ if (mb->get_button_index() == BUTTON_LEFT && mb->is_pressed()) {
- if (mb->get_button_index()==BUTTON_LEFT && mb->is_pressed()) {
+ if (!wip_active) {
+ wip.clear();
+ wip.push_back(cpoint);
+ wip_active = true;
+ edited_point_pos = cpoint;
+ _polygon_draw();
+ edited_point = 1;
+ return true;
+ } else {
- if (!wip_active) {
+ if (wip.size() > 1 && p_camera->unproject_position(gt.xform(Vector3(wip[0].x, wip[0].y, depth))).distance_to(gpoint) < grab_treshold) {
+ //wip closed
+ _wip_close();
- wip.clear();
- wip.push_back( cpoint );
- wip_active=true;
- edited_point_pos=cpoint;
- _polygon_draw();
- edited_point=1;
return true;
} else {
-
- if (wip.size()>1 && p_camera->unproject_position(gt.xform(Vector3(wip[0].x,wip[0].y,depth))).distance_to(gpoint)<grab_treshold) {
- //wip closed
- _wip_close();
-
- return true;
- } else {
-
- wip.push_back( cpoint );
- edited_point=wip.size();
- _polygon_draw();
- return true;
-
- //add wip point
- }
+ wip.push_back(cpoint);
+ edited_point = wip.size();
+ _polygon_draw();
+ return true;
}
- } else if (mb->get_button_index()==BUTTON_RIGHT && mb->is_pressed() && wip_active) {
- _wip_close();
}
+ } else if (mb->get_button_index() == BUTTON_RIGHT && mb->is_pressed() && wip_active) {
+ _wip_close();
+ }
+ } break;
+ case MODE_EDIT: {
- } break;
+ if (mb->get_button_index() == BUTTON_LEFT) {
+ if (mb->is_pressed()) {
- case MODE_EDIT: {
+ if (mb->get_control()) {
- if (mb->get_button_index()==BUTTON_LEFT) {
- if (mb->is_pressed()) {
+ if (poly.size() < 3) {
- if (mb->get_control()) {
-
-
- if (poly.size() < 3) {
-
- undo_redo->create_action(TTR("Edit Poly"));
- undo_redo->add_undo_method(node,"set_polygon",poly);
- poly.push_back(cpoint);
- undo_redo->add_do_method(node,"set_polygon",poly);
- undo_redo->add_do_method(this,"_polygon_draw");
- undo_redo->add_undo_method(this,"_polygon_draw");
- undo_redo->commit_action();
- return true;
- }
-
- //search edges
- int closest_idx=-1;
- Vector2 closest_pos;
- real_t closest_dist=1e10;
- for(int i=0;i<poly.size();i++) {
-
- Vector2 points[2] ={
- p_camera->unproject_position(gt.xform(Vector3(poly[i].x,poly[i].y,depth))),
- p_camera->unproject_position(gt.xform(Vector3(poly[(i+1)%poly.size()].x,poly[(i+1)%poly.size()].y,depth)))
- };
-
- Vector2 cp = Geometry::get_closest_point_to_segment_2d(gpoint,points);
- if (cp.distance_squared_to(points[0])<CMP_EPSILON2 || cp.distance_squared_to(points[1])<CMP_EPSILON2)
- continue; //not valid to reuse point
-
- real_t d = cp.distance_to(gpoint);
- if (d<closest_dist && d<grab_treshold) {
- closest_dist=d;
- closest_pos=cp;
- closest_idx=i;
- }
-
-
- }
-
- if (closest_idx>=0) {
-
- pre_move_edit=poly;
- poly.insert(closest_idx+1,cpoint);
- edited_point=closest_idx+1;
- edited_point_pos=cpoint;
- node->set_polygon(poly);
- _polygon_draw();
- return true;
- }
- } else {
-
- //look for points to move
-
- int closest_idx=-1;
- Vector2 closest_pos;
- real_t closest_dist=1e10;
- for(int i=0;i<poly.size();i++) {
-
- Vector2 cp = p_camera->unproject_position(gt.xform(Vector3(poly[i].x,poly[i].y,depth)));
-
- real_t d = cp.distance_to(gpoint);
- if (d<closest_dist && d<grab_treshold) {
- closest_dist=d;
- closest_pos=cp;
- closest_idx=i;
- }
+ undo_redo->create_action(TTR("Edit Poly"));
+ undo_redo->add_undo_method(node, "set_polygon", poly);
+ poly.push_back(cpoint);
+ undo_redo->add_do_method(node, "set_polygon", poly);
+ undo_redo->add_do_method(this, "_polygon_draw");
+ undo_redo->add_undo_method(this, "_polygon_draw");
+ undo_redo->commit_action();
+ return true;
+ }
+ //search edges
+ int closest_idx = -1;
+ Vector2 closest_pos;
+ real_t closest_dist = 1e10;
+ for (int i = 0; i < poly.size(); i++) {
+
+ Vector2 points[2] = {
+ p_camera->unproject_position(gt.xform(Vector3(poly[i].x, poly[i].y, depth))),
+ p_camera->unproject_position(gt.xform(Vector3(poly[(i + 1) % poly.size()].x, poly[(i + 1) % poly.size()].y, depth)))
+ };
+
+ Vector2 cp = Geometry::get_closest_point_to_segment_2d(gpoint, points);
+ if (cp.distance_squared_to(points[0]) < CMP_EPSILON2 || cp.distance_squared_to(points[1]) < CMP_EPSILON2)
+ continue; //not valid to reuse point
+
+ real_t d = cp.distance_to(gpoint);
+ if (d < closest_dist && d < grab_treshold) {
+ closest_dist = d;
+ closest_pos = cp;
+ closest_idx = i;
}
+ }
- if (closest_idx>=0) {
+ if (closest_idx >= 0) {
- pre_move_edit=poly;
- edited_point=closest_idx;
- edited_point_pos=poly[closest_idx];
- _polygon_draw();
- return true;
- }
+ pre_move_edit = poly;
+ poly.insert(closest_idx + 1, cpoint);
+ edited_point = closest_idx + 1;
+ edited_point_pos = cpoint;
+ node->set_polygon(poly);
+ _polygon_draw();
+ return true;
}
} else {
- if (edited_point!=-1) {
+ //look for points to move
- //apply
+ int closest_idx = -1;
+ Vector2 closest_pos;
+ real_t closest_dist = 1e10;
+ for (int i = 0; i < poly.size(); i++) {
- ERR_FAIL_INDEX_V(edited_point,poly.size(),false);
- poly[edited_point]=edited_point_pos;
- undo_redo->create_action(TTR("Edit Poly"));
- undo_redo->add_do_method(node,"set_polygon",poly);
- undo_redo->add_undo_method(node,"set_polygon",pre_move_edit);
- undo_redo->add_do_method(this,"_polygon_draw");
- undo_redo->add_undo_method(this,"_polygon_draw");
- undo_redo->commit_action();
+ Vector2 cp = p_camera->unproject_position(gt.xform(Vector3(poly[i].x, poly[i].y, depth)));
- edited_point=-1;
- return true;
+ real_t d = cp.distance_to(gpoint);
+ if (d < closest_dist && d < grab_treshold) {
+ closest_dist = d;
+ closest_pos = cp;
+ closest_idx = i;
+ }
}
- }
- } if (mb->get_button_index()==BUTTON_RIGHT && mb->is_pressed() && edited_point==-1) {
-
+ if (closest_idx >= 0) {
- int closest_idx=-1;
- Vector2 closest_pos;
- real_t closest_dist=1e10;
- for(int i=0;i<poly.size();i++) {
-
- Vector2 cp = p_camera->unproject_position(gt.xform(Vector3(poly[i].x,poly[i].y,depth)));
-
- real_t d = cp.distance_to(gpoint);
- if (d<closest_dist && d<grab_treshold) {
- closest_dist=d;
- closest_pos=cp;
- closest_idx=i;
+ pre_move_edit = poly;
+ edited_point = closest_idx;
+ edited_point_pos = poly[closest_idx];
+ _polygon_draw();
+ return true;
}
-
}
+ } else {
- if (closest_idx>=0) {
+ if (edited_point != -1) {
+ //apply
- undo_redo->create_action(TTR("Edit Poly (Remove Point)"));
- undo_redo->add_undo_method(node,"set_polygon",poly);
- poly.remove(closest_idx);
- undo_redo->add_do_method(node,"set_polygon",poly);
- undo_redo->add_do_method(this,"_polygon_draw");
- undo_redo->add_undo_method(this,"_polygon_draw");
+ ERR_FAIL_INDEX_V(edited_point, poly.size(), false);
+ poly[edited_point] = edited_point_pos;
+ undo_redo->create_action(TTR("Edit Poly"));
+ undo_redo->add_do_method(node, "set_polygon", poly);
+ undo_redo->add_undo_method(node, "set_polygon", pre_move_edit);
+ undo_redo->add_do_method(this, "_polygon_draw");
+ undo_redo->add_undo_method(this, "_polygon_draw");
undo_redo->commit_action();
+
+ edited_point = -1;
return true;
}
-
}
+ }
+ if (mb->get_button_index() == BUTTON_RIGHT && mb->is_pressed() && edited_point == -1) {
+ int closest_idx = -1;
+ Vector2 closest_pos;
+ real_t closest_dist = 1e10;
+ for (int i = 0; i < poly.size(); i++) {
+ Vector2 cp = p_camera->unproject_position(gt.xform(Vector3(poly[i].x, poly[i].y, depth)));
- } break;
- }
-
+ real_t d = cp.distance_to(gpoint);
+ if (d < closest_dist && d < grab_treshold) {
+ closest_dist = d;
+ closest_pos = cp;
+ closest_idx = i;
+ }
+ }
+ if (closest_idx >= 0) {
- } break;
- case InputEvent::MOUSE_MOTION: {
+ undo_redo->create_action(TTR("Edit Poly (Remove Point)"));
+ undo_redo->add_undo_method(node, "set_polygon", poly);
+ poly.remove(closest_idx);
+ undo_redo->add_do_method(node, "set_polygon", poly);
+ undo_redo->add_do_method(this, "_polygon_draw");
+ undo_redo->add_undo_method(this, "_polygon_draw");
+ undo_redo->commit_action();
+ return true;
+ }
+ }
- const InputEventMouseMotion &mm=p_event.mouse_motion;
+ } break;
+ }
+ }
- if (edited_point!=-1 && (wip_active || mm->get_button_mask()&BUTTON_MASK_LEFT)) {
+ Ref<InputEventMouseMotion> mm = p_event;
- Vector2 gpoint = Point2(mm.x,mm.y);
+ if (mm.is_valid()) {
- Vector3 ray_from = p_camera->project_ray_origin(gpoint);
- Vector3 ray_dir = p_camera->project_ray_normal(gpoint);
+ if (edited_point != -1 && (wip_active || mm->get_button_mask() & BUTTON_MASK_LEFT)) {
- Vector3 spoint;
+ Vector2 gpoint = mm->get_position();
- if (!p.intersects_ray(ray_from,ray_dir,&spoint))
- break;
+ Vector3 ray_from = p_camera->project_ray_origin(gpoint);
+ Vector3 ray_dir = p_camera->project_ray_normal(gpoint);
- spoint = gi.xform(spoint);
+ Vector3 spoint;
- Vector2 cpoint(spoint.x,spoint.y);
+ if (!p.intersects_ray(ray_from, ray_dir, &spoint))
+ return false;
- cpoint=CanvasItemEditor::get_singleton()->snap_point(cpoint);
- edited_point_pos = cpoint;
+ spoint = gi.xform(spoint);
- _polygon_draw();
+ Vector2 cpoint(spoint.x, spoint.y);
- }
+ cpoint = CanvasItemEditor::get_singleton()->snap_point(cpoint);
+ edited_point_pos = cpoint;
- } break;
+ _polygon_draw();
+ }
}
return false;
@@ -380,41 +345,38 @@ void CollisionPolygonEditor::_polygon_draw() {
Vector<Vector2> poly;
if (wip_active)
- poly=wip;
+ poly = wip;
else
- poly=node->get_polygon();
-
+ poly = node->get_polygon();
- float depth = node->get_depth()*0.5;
+ float depth = node->get_depth() * 0.5;
imgeom->clear();
imgeom->set_material_override(line_material);
- imgeom->begin(Mesh::PRIMITIVE_LINES,Ref<Texture>());
-
+ imgeom->begin(Mesh::PRIMITIVE_LINES, Ref<Texture>());
Rect2 rect;
- for(int i=0;i<poly.size();i++) {
-
+ for (int i = 0; i < poly.size(); i++) {
- Vector2 p,p2;
- p = i==edited_point ? edited_point_pos : poly[i];
- if ((wip_active && i==poly.size()-1) || (((i+1)%poly.size())==edited_point))
- p2=edited_point_pos;
+ Vector2 p, p2;
+ p = i == edited_point ? edited_point_pos : poly[i];
+ if ((wip_active && i == poly.size() - 1) || (((i + 1) % poly.size()) == edited_point))
+ p2 = edited_point_pos;
else
- p2 = poly[(i+1)%poly.size()];
+ p2 = poly[(i + 1) % poly.size()];
- if (i==0)
- rect.pos=p;
+ if (i == 0)
+ rect.position = p;
else
rect.expand_to(p);
- Vector3 point = Vector3(p.x,p.y,depth);
- Vector3 next_point = Vector3(p2.x,p2.y,depth);
+ Vector3 point = Vector3(p.x, p.y, depth);
+ Vector3 next_point = Vector3(p2.x, p2.y, depth);
- imgeom->set_color(Color(1,0.3,0.1,0.8));
+ imgeom->set_color(Color(1, 0.3, 0.1, 0.8));
imgeom->add_vertex(point);
- imgeom->set_color(Color(1,0.3,0.1,0.8));
+ imgeom->set_color(Color(1, 0.3, 0.1, 0.8));
imgeom->add_vertex(next_point);
//Color col=Color(1,0.3,0.1,0.8);
@@ -422,60 +384,59 @@ void CollisionPolygonEditor::_polygon_draw() {
//vpc->draw_texture(handle,point-handle->get_size()*0.5);
}
- rect=rect.grow(1);
-
- AABB r;
- r.pos.x=rect.pos.x;
- r.pos.y=rect.pos.y;
- r.pos.z=depth;
- r.size.x=rect.size.x;
- r.size.y=rect.size.y;
- r.size.z=0;
-
- imgeom->set_color(Color(0.8,0.8,0.8,0.2));
- imgeom->add_vertex(r.pos);
- imgeom->set_color(Color(0.8,0.8,0.8,0.2));
- imgeom->add_vertex(r.pos+Vector3(0.3,0,0));
- imgeom->set_color(Color(0.8,0.8,0.8,0.2));
- imgeom->add_vertex(r.pos);
- imgeom->set_color(Color(0.8,0.8,0.8,0.2));
- imgeom->add_vertex(r.pos+Vector3(0.0,0.3,0));
-
- imgeom->set_color(Color(0.8,0.8,0.8,0.2));
- imgeom->add_vertex(r.pos+Vector3(r.size.x,0,0));
- imgeom->set_color(Color(0.8,0.8,0.8,0.2));
- imgeom->add_vertex(r.pos+Vector3(r.size.x,0,0)-Vector3(0.3,0,0));
- imgeom->set_color(Color(0.8,0.8,0.8,0.2));
- imgeom->add_vertex(r.pos+Vector3(r.size.x,0,0));
- imgeom->set_color(Color(0.8,0.8,0.8,0.2));
- imgeom->add_vertex(r.pos+Vector3(r.size.x,0,0)+Vector3(0,0.3,0));
-
- imgeom->set_color(Color(0.8,0.8,0.8,0.2));
- imgeom->add_vertex(r.pos+Vector3(0,r.size.y,0));
- imgeom->set_color(Color(0.8,0.8,0.8,0.2));
- imgeom->add_vertex(r.pos+Vector3(0,r.size.y,0)-Vector3(0,0.3,0));
- imgeom->set_color(Color(0.8,0.8,0.8,0.2));
- imgeom->add_vertex(r.pos+Vector3(0,r.size.y,0));
- imgeom->set_color(Color(0.8,0.8,0.8,0.2));
- imgeom->add_vertex(r.pos+Vector3(0,r.size.y,0)+Vector3(0.3,0,0));
-
- imgeom->set_color(Color(0.8,0.8,0.8,0.2));
- imgeom->add_vertex(r.pos+r.size);
- imgeom->set_color(Color(0.8,0.8,0.8,0.2));
- imgeom->add_vertex(r.pos+r.size-Vector3(0.3,0,0));
- imgeom->set_color(Color(0.8,0.8,0.8,0.2));
- imgeom->add_vertex(r.pos+r.size);
- imgeom->set_color(Color(0.8,0.8,0.8,0.2));
- imgeom->add_vertex(r.pos+r.size-Vector3(0.0,0.3,0));
+ rect = rect.grow(1);
+
+ Rect3 r;
+ r.position.x = rect.position.x;
+ r.position.y = rect.position.y;
+ r.position.z = depth;
+ r.size.x = rect.size.x;
+ r.size.y = rect.size.y;
+ r.size.z = 0;
+
+ imgeom->set_color(Color(0.8, 0.8, 0.8, 0.2));
+ imgeom->add_vertex(r.position);
+ imgeom->set_color(Color(0.8, 0.8, 0.8, 0.2));
+ imgeom->add_vertex(r.position + Vector3(0.3, 0, 0));
+ imgeom->set_color(Color(0.8, 0.8, 0.8, 0.2));
+ imgeom->add_vertex(r.position);
+ imgeom->set_color(Color(0.8, 0.8, 0.8, 0.2));
+ imgeom->add_vertex(r.position + Vector3(0.0, 0.3, 0));
+
+ imgeom->set_color(Color(0.8, 0.8, 0.8, 0.2));
+ imgeom->add_vertex(r.position + Vector3(r.size.x, 0, 0));
+ imgeom->set_color(Color(0.8, 0.8, 0.8, 0.2));
+ imgeom->add_vertex(r.position + Vector3(r.size.x, 0, 0) - Vector3(0.3, 0, 0));
+ imgeom->set_color(Color(0.8, 0.8, 0.8, 0.2));
+ imgeom->add_vertex(r.position + Vector3(r.size.x, 0, 0));
+ imgeom->set_color(Color(0.8, 0.8, 0.8, 0.2));
+ imgeom->add_vertex(r.position + Vector3(r.size.x, 0, 0) + Vector3(0, 0.3, 0));
+
+ imgeom->set_color(Color(0.8, 0.8, 0.8, 0.2));
+ imgeom->add_vertex(r.position + Vector3(0, r.size.y, 0));
+ imgeom->set_color(Color(0.8, 0.8, 0.8, 0.2));
+ imgeom->add_vertex(r.position + Vector3(0, r.size.y, 0) - Vector3(0, 0.3, 0));
+ imgeom->set_color(Color(0.8, 0.8, 0.8, 0.2));
+ imgeom->add_vertex(r.position + Vector3(0, r.size.y, 0));
+ imgeom->set_color(Color(0.8, 0.8, 0.8, 0.2));
+ imgeom->add_vertex(r.position + Vector3(0, r.size.y, 0) + Vector3(0.3, 0, 0));
+
+ imgeom->set_color(Color(0.8, 0.8, 0.8, 0.2));
+ imgeom->add_vertex(r.position + r.size);
+ imgeom->set_color(Color(0.8, 0.8, 0.8, 0.2));
+ imgeom->add_vertex(r.position + r.size - Vector3(0.3, 0, 0));
+ imgeom->set_color(Color(0.8, 0.8, 0.8, 0.2));
+ imgeom->add_vertex(r.position + r.size);
+ imgeom->set_color(Color(0.8, 0.8, 0.8, 0.2));
+ imgeom->add_vertex(r.position + r.size - Vector3(0.0, 0.3, 0));
imgeom->end();
-
- while(m->get_surface_count()) {
+ while (m->get_surface_count()) {
m->surface_remove(0);
}
- if (poly.size()==0)
+ if (poly.size() == 0)
return;
Array a;
@@ -484,78 +445,69 @@ void CollisionPolygonEditor::_polygon_draw() {
{
va.resize(poly.size());
- PoolVector<Vector3>::Write w=va.write();
- for(int i=0;i<poly.size();i++) {
-
+ PoolVector<Vector3>::Write w = va.write();
+ for (int i = 0; i < poly.size(); i++) {
- Vector2 p,p2;
- p = i==edited_point ? edited_point_pos : poly[i];
+ Vector2 p, p2;
+ p = i == edited_point ? edited_point_pos : poly[i];
- Vector3 point = Vector3(p.x,p.y,depth);
- w[i]=point;
+ Vector3 point = Vector3(p.x, p.y, depth);
+ w[i] = point;
}
}
- a[Mesh::ARRAY_VERTEX]=va;
- m->add_surface(Mesh::PRIMITIVE_POINTS,a);
- m->surface_set_material(0,handle_material);
-
+ a[Mesh::ARRAY_VERTEX] = va;
+ m->add_surface_from_arrays(Mesh::PRIMITIVE_POINTS, a);
+ m->surface_set_material(0, handle_material);
}
-
-
void CollisionPolygonEditor::edit(Node *p_collision_polygon) {
-
-
if (p_collision_polygon) {
- node=p_collision_polygon->cast_to<CollisionPolygon>();
+ node = p_collision_polygon->cast_to<CollisionPolygon>();
wip.clear();
- wip_active=false;
- edited_point=-1;
+ wip_active = false;
+ edited_point = -1;
p_collision_polygon->add_child(imgeom);
_polygon_draw();
set_process(true);
- prev_depth=-1;
+ prev_depth = -1;
} else {
- node=NULL;
+ node = NULL;
if (imgeom->get_parent())
imgeom->get_parent()->remove_child(imgeom);
set_process(false);
}
-
}
void CollisionPolygonEditor::_bind_methods() {
- ClassDB::bind_method(D_METHOD("_menu_option"),&CollisionPolygonEditor::_menu_option);
- ClassDB::bind_method(D_METHOD("_polygon_draw"),&CollisionPolygonEditor::_polygon_draw);
- ClassDB::bind_method(D_METHOD("_node_removed"),&CollisionPolygonEditor::_node_removed);
-
+ ClassDB::bind_method(D_METHOD("_menu_option"), &CollisionPolygonEditor::_menu_option);
+ ClassDB::bind_method(D_METHOD("_polygon_draw"), &CollisionPolygonEditor::_polygon_draw);
+ ClassDB::bind_method(D_METHOD("_node_removed"), &CollisionPolygonEditor::_node_removed);
}
CollisionPolygonEditor::CollisionPolygonEditor(EditorNode *p_editor) {
-
- node=NULL;
- editor=p_editor;
+ node = NULL;
+ editor = p_editor;
undo_redo = editor->get_undo_redo();
- add_child( memnew( VSeparator ));
- button_create = memnew( ToolButton );
+ add_child(memnew(VSeparator));
+ button_create = memnew(ToolButton);
add_child(button_create);
- button_create->connect("pressed",this,"_menu_option",varray(MODE_CREATE));
+ button_create->connect("pressed", this, "_menu_option", varray(MODE_CREATE));
button_create->set_toggle_mode(true);
- button_edit = memnew( ToolButton );
+ button_edit = memnew(ToolButton);
add_child(button_edit);
- button_edit->connect("pressed",this,"_menu_option",varray(MODE_EDIT));
+ button_edit->connect("pressed", this, "_menu_option", varray(MODE_EDIT));
button_edit->set_toggle_mode(true);
- //add_constant_override("separation",0);
+//add_constant_override("separation",0);
#if 0
options = memnew( MenuButton );
@@ -567,46 +519,40 @@ CollisionPolygonEditor::CollisionPolygonEditor(EditorNode *p_editor) {
#endif
mode = MODE_EDIT;
- wip_active=false;
- imgeom = memnew( ImmediateGeometry );
- imgeom->set_transform(Transform(Matrix3(),Vector3(0,0,0.00001)));
-
+ wip_active = false;
+ imgeom = memnew(ImmediateGeometry);
+ imgeom->set_transform(Transform(Basis(), Vector3(0, 0, 0.00001)));
- line_material = Ref<SpatialMaterial>( memnew( SpatialMaterial ));
- line_material->set_flag(Material::FLAG_UNSHADED, true);
+ line_material = Ref<SpatialMaterial>(memnew(SpatialMaterial));
+ line_material->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
line_material->set_line_width(3.0);
- line_material->set_fixed_flag(SpatialMaterial::FLAG_USE_ALPHA, true);
- line_material->set_fixed_flag(SpatialMaterial::FLAG_USE_COLOR_ARRAY, true);
- line_material->set_parameter(SpatialMaterial::PARAM_DIFFUSE,Color(1,1,1));
-
-
-
-
- handle_material = Ref<SpatialMaterial>( memnew( SpatialMaterial ));
- handle_material->set_flag(Material::FLAG_UNSHADED, true);
- handle_material->set_fixed_flag(SpatialMaterial::FLAG_USE_POINT_SIZE, true);
- handle_material->set_parameter(SpatialMaterial::PARAM_DIFFUSE,Color(1,1,1));
- handle_material->set_fixed_flag(SpatialMaterial::FLAG_USE_ALPHA, true);
- handle_material->set_fixed_flag(SpatialMaterial::FLAG_USE_COLOR_ARRAY, false);
- Ref<Texture> handle=editor->get_gui_base()->get_icon("Editor3DHandle","EditorIcons");
+ line_material->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
+ line_material->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
+ line_material->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true);
+ line_material->set_albedo(Color(1, 1, 1));
+
+ handle_material = Ref<SpatialMaterial>(memnew(SpatialMaterial));
+ handle_material->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
+ handle_material->set_flag(SpatialMaterial::FLAG_USE_POINT_SIZE, true);
+ handle_material->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
+ handle_material->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
+ handle_material->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true);
+ Ref<Texture> handle = editor->get_gui_base()->get_icon("Editor3DHandle", "EditorIcons");
handle_material->set_point_size(handle->get_width());
- handle_material->set_texture(SpatialMaterial::PARAM_DIFFUSE,handle);
+ handle_material->set_texture(SpatialMaterial::TEXTURE_ALBEDO, handle);
- pointsm = memnew( MeshInstance );
+ pointsm = memnew(MeshInstance);
imgeom->add_child(pointsm);
- m = Ref<Mesh>( memnew( Mesh ) );
+ m.instance();
pointsm->set_mesh(m);
- pointsm->set_transform(Transform(Matrix3(),Vector3(0,0,0.00001)));
-
-
+ pointsm->set_transform(Transform(Basis(), Vector3(0, 0, 0.00001)));
}
CollisionPolygonEditor::~CollisionPolygonEditor() {
- memdelete( imgeom );
+ memdelete(imgeom);
}
-
void CollisionPolygonEditorPlugin::edit(Object *p_object) {
collision_polygon_editor->edit(p_object->cast_to<Node>());
@@ -614,7 +560,7 @@ void CollisionPolygonEditorPlugin::edit(Object *p_object) {
bool CollisionPolygonEditorPlugin::handles(Object *p_object) const {
- return p_object->is_type("CollisionPolygon");
+ return p_object->is_class("CollisionPolygon");
}
void CollisionPolygonEditorPlugin::make_visible(bool p_visible) {
@@ -626,24 +572,16 @@ void CollisionPolygonEditorPlugin::make_visible(bool p_visible) {
collision_polygon_editor->hide();
collision_polygon_editor->edit(NULL);
}
-
}
CollisionPolygonEditorPlugin::CollisionPolygonEditorPlugin(EditorNode *p_node) {
- editor=p_node;
- collision_polygon_editor = memnew( CollisionPolygonEditor(p_node) );
+ editor = p_node;
+ collision_polygon_editor = memnew(CollisionPolygonEditor(p_node));
SpatialEditor::get_singleton()->add_control_to_menu_panel(collision_polygon_editor);
collision_polygon_editor->hide();
-
-
-
}
-
-CollisionPolygonEditorPlugin::~CollisionPolygonEditorPlugin()
-{
+CollisionPolygonEditorPlugin::~CollisionPolygonEditorPlugin() {
}
-
-#endif
diff --git a/editor/plugins/collision_polygon_editor_plugin.h b/editor/plugins/collision_polygon_editor_plugin.h
index 995f2224bf..3a8428fc62 100644
--- a/editor/plugins/collision_polygon_editor_plugin.h
+++ b/editor/plugins/collision_polygon_editor_plugin.h
@@ -42,12 +42,11 @@
@author Juan Linietsky <reduzio@gmail.com>
*/
-#if 0
class CanvasItemEditor;
class CollisionPolygonEditor : public HBoxContainer {
- GDCLASS(CollisionPolygonEditor, HBoxContainer );
+ GDCLASS(CollisionPolygonEditor, HBoxContainer);
UndoRedo *undo_redo;
enum Mode {
@@ -62,7 +61,6 @@ class CollisionPolygonEditor : public HBoxContainer {
ToolButton *button_create;
ToolButton *button_edit;
-
Ref<SpatialMaterial> line_material;
Ref<SpatialMaterial> handle_material;
@@ -71,7 +69,7 @@ class CollisionPolygonEditor : public HBoxContainer {
CollisionPolygon *node;
ImmediateGeometry *imgeom;
MeshInstance *pointsm;
- Ref<Mesh> m;
+ Ref<ArrayMesh> m;
MenuButton *options;
@@ -91,9 +89,9 @@ protected:
void _notification(int p_what);
void _node_removed(Node *p_node);
static void _bind_methods();
-public:
- virtual bool forward_spatial_gui_input(Camera* p_camera,const InputEvent& p_event);
+public:
+ virtual bool forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event);
void edit(Node *p_collision_polygon);
CollisionPolygonEditor(EditorNode *p_editor);
~CollisionPolygonEditor();
@@ -101,14 +99,13 @@ public:
class CollisionPolygonEditorPlugin : public EditorPlugin {
- GDCLASS( CollisionPolygonEditorPlugin, EditorPlugin );
+ GDCLASS(CollisionPolygonEditorPlugin, EditorPlugin);
CollisionPolygonEditor *collision_polygon_editor;
EditorNode *editor;
public:
-
- virtual bool forward_spatial_gui_input(Camera* p_camera,const InputEvent& p_event) { return collision_polygon_editor->forward_spatial_gui_input(p_camera,p_event); }
+ virtual bool forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event) { return collision_polygon_editor->forward_spatial_gui_input(p_camera, p_event); }
virtual String get_name() const { return "CollisionPolygon"; }
bool has_main_screen() const { return false; }
@@ -118,7 +115,6 @@ public:
CollisionPolygonEditorPlugin(EditorNode *p_node);
~CollisionPolygonEditorPlugin();
-
};
-#endif
+
#endif // COLLISION_POLYGON_EDITOR_PLUGIN_H
diff --git a/editor/plugins/curve_editor_plugin.cpp b/editor/plugins/curve_editor_plugin.cpp
index d729bb7b76..2d05c8eba1 100644
--- a/editor/plugins/curve_editor_plugin.cpp
+++ b/editor/plugins/curve_editor_plugin.cpp
@@ -774,6 +774,8 @@ CurveEditorPlugin::CurveEditorPlugin(EditorNode *p_node) {
_toggle_button = _editor_node->add_bottom_panel_item(get_name(), _view);
_toggle_button->hide();
+
+ get_resource_previewer()->add_preview_generator(memnew(CurvePreviewGenerator));
}
CurveEditorPlugin::~CurveEditorPlugin() {
@@ -845,3 +847,74 @@ void CurveEditorPlugin::_bind_methods() {
ClassDB::bind_method(D_METHOD("_curve_texture_changed"), &CurveEditorPlugin::_curve_texture_changed);
}
+
+//-----------------------------------
+// Preview generator
+
+bool CurvePreviewGenerator::handles(const String &p_type) const {
+ return p_type == "Curve";
+}
+
+Ref<Texture> CurvePreviewGenerator::generate(const Ref<Resource> &p_from) {
+
+ Ref<Curve> curve_ref = p_from;
+ ERR_FAIL_COND_V(curve_ref.is_null(), Ref<Texture>());
+ Curve &curve = **curve_ref;
+
+ int thumbnail_size = EditorSettings::get_singleton()->get("filesystem/file_dialog/thumbnail_size");
+ thumbnail_size *= EDSCALE;
+ Ref<Image> img_ref;
+ img_ref.instance();
+ Image &im = **img_ref;
+
+ im.create(thumbnail_size, thumbnail_size, 0, Image::FORMAT_RGBA8);
+
+ im.lock();
+
+ Color bg_color(0.1, 0.1, 0.1, 1.0);
+ for (int i = 0; i < thumbnail_size; i++) {
+ for (int j = 0; j < thumbnail_size; j++) {
+ im.set_pixel(i, j, bg_color);
+ }
+ }
+
+ Color line_color(0.8, 0.8, 0.8, 1.0);
+ float range_y = curve.get_max_value() - curve.get_min_value();
+
+ int prev_y = 0;
+ for (int x = 0; x < im.get_width(); ++x) {
+
+ float t = static_cast<float>(x) / im.get_width();
+ float v = (curve.interpolate_baked(t) - curve.get_min_value()) / range_y;
+ int y = CLAMP(im.get_height() - v * im.get_height(), 0, im.get_height());
+
+ // Plot point
+ if (y >= 0 && y < im.get_height()) {
+ im.set_pixel(x, y, line_color);
+ }
+
+ // Plot vertical line to fix discontinuity (not 100% correct but enough for a preview)
+ if (x != 0 && Math::abs(y - prev_y) > 1) {
+ int y0, y1;
+ if (y < prev_y) {
+ y0 = y;
+ y1 = prev_y;
+ } else {
+ y0 = prev_y;
+ y1 = y;
+ }
+ for (int ly = y0; ly < y1; ++ly) {
+ im.set_pixel(x, ly, line_color);
+ }
+ }
+
+ prev_y = y;
+ }
+
+ im.unlock();
+
+ Ref<ImageTexture> ptex = Ref<ImageTexture>(memnew(ImageTexture));
+
+ ptex->create_from_image(img_ref, 0);
+ return ptex;
+}
diff --git a/editor/plugins/curve_editor_plugin.h b/editor/plugins/curve_editor_plugin.h
index a4952dfb28..040c298a92 100644
--- a/editor/plugins/curve_editor_plugin.h
+++ b/editor/plugins/curve_editor_plugin.h
@@ -143,4 +143,11 @@ private:
ToolButton *_toggle_button;
};
+class CurvePreviewGenerator : public EditorResourcePreviewGenerator {
+ GDCLASS(CurvePreviewGenerator, EditorResourcePreviewGenerator)
+public:
+ bool handles(const String &p_type) const;
+ Ref<Texture> generate(const Ref<Resource> &p_from);
+};
+
#endif // CURVE_EDITOR_PLUGIN_H
diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp
index 11d804422a..ce6eefd694 100644
--- a/editor/plugins/editor_preview_plugins.cpp
+++ b/editor/plugins/editor_preview_plugins.cpp
@@ -186,7 +186,7 @@ Ref<Texture> EditorPackedScenePreviewPlugin::generate(const RES &p_from) {
Ref<Texture> EditorPackedScenePreviewPlugin::generate_from_path(const String &p_path) {
String temp_path = EditorSettings::get_singleton()->get_settings_path().plus_file("tmp");
- String cache_base = GlobalConfig::get_singleton()->globalize_path(p_path).md5_text();
+ String cache_base = ProjectSettings::get_singleton()->globalize_path(p_path).md5_text();
cache_base = temp_path.plus_file("resthumb-" + cache_base);
//does not have it, try to load a cached thumbnail
@@ -431,7 +431,7 @@ Ref<Texture> EditorScriptPreviewPlugin::generate(const RES &p_from) {
for (int i = 0; i < thumbnail_size; i++) {
for (int j = 0; j < thumbnail_size; j++) {
- img->put_pixel(i, j, bg_color);
+ img->set_pixel(i, j, bg_color);
}
}
@@ -469,8 +469,8 @@ Ref<Texture> EditorScriptPreviewPlugin::generate(const RES &p_from) {
Color ul = color;
ul.a *= 0.5;
- img->put_pixel(col, line * 2, bg_color.blend(ul));
- img->put_pixel(col, line * 2 + 1, color);
+ img->set_pixel(col, line * 2, bg_color.blend(ul));
+ img->set_pixel(col, line * 2 + 1, color);
prev_is_text = _is_text_char(c);
}
diff --git a/editor/plugins/item_list_editor_plugin.cpp b/editor/plugins/item_list_editor_plugin.cpp
index 7f56286f08..f567abc5b1 100644
--- a/editor/plugins/item_list_editor_plugin.cpp
+++ b/editor/plugins/item_list_editor_plugin.cpp
@@ -193,6 +193,45 @@ ItemListPopupMenuPlugin::ItemListPopupMenuPlugin() {
}
///////////////////////////////////////////////////////////////
+
+void ItemListItemListPlugin::set_object(Object *p_object) {
+
+ pp = p_object->cast_to<ItemList>();
+}
+
+bool ItemListItemListPlugin::handles(Object *p_object) const {
+
+ return p_object->is_class("ItemList");
+}
+
+int ItemListItemListPlugin::get_flags() const {
+
+ return FLAG_ICON | FLAG_ENABLE;
+}
+
+void ItemListItemListPlugin::add_item() {
+
+ pp->add_item(vformat(TTR("Item %d"), pp->get_item_count()));
+ _change_notify();
+}
+
+int ItemListItemListPlugin::get_item_count() const {
+
+ return pp->get_item_count();
+}
+
+void ItemListItemListPlugin::erase(int p_idx) {
+
+ pp->remove_item(p_idx);
+ _change_notify();
+}
+
+ItemListItemListPlugin::ItemListItemListPlugin() {
+
+ pp = NULL;
+}
+
+///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////
@@ -373,6 +412,7 @@ ItemListEditorPlugin::ItemListEditorPlugin(EditorNode *p_node) {
item_list_editor->hide();
item_list_editor->add_plugin(memnew(ItemListOptionButtonPlugin));
item_list_editor->add_plugin(memnew(ItemListPopupMenuPlugin));
+ item_list_editor->add_plugin(memnew(ItemListItemListPlugin));
}
ItemListEditorPlugin::~ItemListEditorPlugin() {
diff --git a/editor/plugins/item_list_editor_plugin.h b/editor/plugins/item_list_editor_plugin.h
index 042e88839f..4fed8e49f5 100644
--- a/editor/plugins/item_list_editor_plugin.h
+++ b/editor/plugins/item_list_editor_plugin.h
@@ -167,6 +167,35 @@ public:
///////////////////////////////////////////////////////////////
+class ItemListItemListPlugin : public ItemListPlugin {
+
+ GDCLASS(ItemListItemListPlugin, ItemListPlugin);
+
+ ItemList *pp;
+
+public:
+ virtual void set_object(Object *p_object);
+ virtual bool handles(Object *p_object) const;
+ virtual int get_flags() const;
+
+ virtual void set_item_text(int p_idx, const String &p_text) { pp->set_item_text(p_idx, p_text); }
+ virtual String get_item_text(int p_idx) const { return pp->get_item_text(p_idx); }
+
+ virtual void set_item_icon(int p_idx, const Ref<Texture> &p_tex) { pp->set_item_icon(p_idx, p_tex); }
+ virtual Ref<Texture> get_item_icon(int p_idx) const { return pp->get_item_icon(p_idx); }
+
+ virtual void set_item_enabled(int p_idx, int p_enabled) { pp->set_item_disabled(p_idx, !p_enabled); }
+ virtual bool is_item_enabled(int p_idx) const { return !pp->is_item_disabled(p_idx); }
+
+ virtual void add_item();
+ virtual int get_item_count() const;
+ virtual void erase(int p_idx);
+
+ ItemListItemListPlugin();
+};
+
+///////////////////////////////////////////////////////////////
+
class ItemListEditor : public HBoxContainer {
GDCLASS(ItemListEditor, HBoxContainer);
diff --git a/editor/plugins/light_occluder_2d_editor_plugin.cpp b/editor/plugins/light_occluder_2d_editor_plugin.cpp
index 09021446dc..a7a20e71fe 100644
--- a/editor/plugins/light_occluder_2d_editor_plugin.cpp
+++ b/editor/plugins/light_occluder_2d_editor_plugin.cpp
@@ -126,7 +126,7 @@ bool LightOccluder2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
Vector<Vector2> poly = Variant(node->get_occluder_polygon()->get_polygon());
//first check if a point is to be added (segment split)
- real_t grab_treshold = EDITOR_DEF("editors/poly_editor/point_grab_radius", 8);
+ real_t grab_threshold = EDITOR_DEF("editors/poly_editor/point_grab_radius", 8);
switch (mode) {
@@ -145,12 +145,12 @@ bool LightOccluder2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
return true;
} else {
- if (wip.size() > 1 && xform.xform(wip[0]).distance_to(gpoint) < grab_treshold) {
+ if (wip.size() > 1 && xform.xform(wip[0]).distance_to(gpoint) < grab_threshold) {
//wip closed
_wip_close(true);
return true;
- } else if (wip.size() > 1 && xform.xform(wip[wip.size() - 1]).distance_to(gpoint) < grab_treshold) {
+ } else if (wip.size() > 1 && xform.xform(wip[wip.size() - 1]).distance_to(gpoint) < grab_threshold) {
//wip closed
_wip_close(false);
return true;
@@ -204,7 +204,7 @@ bool LightOccluder2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
continue; //not valid to reuse point
real_t d = cp.distance_to(gpoint);
- if (d < closest_dist && d < grab_treshold) {
+ if (d < closest_dist && d < grab_threshold) {
closest_dist = d;
closest_pos = cp;
closest_idx = i;
@@ -233,7 +233,7 @@ bool LightOccluder2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
Vector2 cp = xform.xform(poly[i]);
real_t d = cp.distance_to(gpoint);
- if (d < closest_dist && d < grab_treshold) {
+ if (d < closest_dist && d < grab_threshold) {
closest_dist = d;
closest_pos = cp;
closest_idx = i;
@@ -278,7 +278,7 @@ bool LightOccluder2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
Vector2 cp = xform.xform(poly[i]);
real_t d = cp.distance_to(gpoint);
- if (d < closest_dist && d < grab_treshold) {
+ if (d < closest_dist && d < grab_threshold) {
closest_dist = d;
closest_pos = cp;
closest_idx = i;
diff --git a/editor/plugins/line_2d_editor_plugin.cpp b/editor/plugins/line_2d_editor_plugin.cpp
index 76906a5b93..4a7ad74fbe 100644
--- a/editor/plugins/line_2d_editor_plugin.cpp
+++ b/editor/plugins/line_2d_editor_plugin.cpp
@@ -62,12 +62,12 @@ Vector2 Line2DEditor::mouse_to_local_pos(Vector2 gpoint, bool alt) {
int Line2DEditor::get_point_index_at(Vector2 gpos) {
ERR_FAIL_COND_V(node == 0, -1);
- real_t grab_treshold = EDITOR_DEF("editors/poly_editor/point_grab_radius", 8);
+ 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_pos(i));
- if (gpos.distance_to(p) < grab_treshold) {
+ if (gpos.distance_to(p) < grab_threshold) {
return i;
}
}
diff --git a/editor/plugins/mesh_editor_plugin.cpp b/editor/plugins/mesh_editor_plugin.cpp
index f377d3a7cc..23b19e61b9 100644
--- a/editor/plugins/mesh_editor_plugin.cpp
+++ b/editor/plugins/mesh_editor_plugin.cpp
@@ -29,18 +29,17 @@
/*************************************************************************/
#include "mesh_editor_plugin.h"
-#if 0
-void MeshEditor::_gui_input(InputEvent p_event) {
+void MeshEditor::_gui_input(Ref<InputEvent> p_event) {
+ Ref<InputEventMouseMotion> mm = p_event;
+ if (mm.is_valid() && mm->get_button_mask() & BUTTON_MASK_LEFT) {
- if (p_event.type==InputEvent::MOUSE_MOTION && p_event->get_button_mask()&BUTTON_MASK_LEFT) {
-
- rot_x-=p_event->get_relative().y*0.01;
- rot_y-=p_event->get_relative().x*0.01;
- if (rot_x<-Math_PI/2)
- rot_x=-Math_PI/2;
- else if (rot_x>Math_PI/2) {
- rot_x=Math_PI/2;
+ rot_x -= mm->get_relative().y * 0.01;
+ rot_y -= mm->get_relative().x * 0.01;
+ if (rot_x < -Math_PI / 2)
+ rot_x = -Math_PI / 2;
+ else if (rot_x > Math_PI / 2) {
+ rot_x = Math_PI / 2;
}
_update_rotation();
}
@@ -48,35 +47,30 @@ void MeshEditor::_gui_input(InputEvent p_event) {
void MeshEditor::_notification(int p_what) {
- if (p_what==NOTIFICATION_FIXED_PROCESS) {
-
+ if (p_what == NOTIFICATION_FIXED_PROCESS) {
}
-
- if (p_what==NOTIFICATION_READY) {
+ if (p_what == NOTIFICATION_READY) {
//get_scene()->connect("node_removed",this,"_node_removed");
if (first_enter) {
- //it's in propertyeditor so.. could be moved around
+ //it's in propertyeditor so. could be moved around
- light_1_switch->set_normal_texture(get_icon("MaterialPreviewLight1","EditorIcons"));
- light_1_switch->set_pressed_texture(get_icon("MaterialPreviewLight1Off","EditorIcons"));
- light_2_switch->set_normal_texture(get_icon("MaterialPreviewLight2","EditorIcons"));
- light_2_switch->set_pressed_texture(get_icon("MaterialPreviewLight2Off","EditorIcons"));
- first_enter=false;
+ light_1_switch->set_normal_texture(get_icon("MaterialPreviewLight1", "EditorIcons"));
+ light_1_switch->set_pressed_texture(get_icon("MaterialPreviewLight1Off", "EditorIcons"));
+ light_2_switch->set_normal_texture(get_icon("MaterialPreviewLight2", "EditorIcons"));
+ light_2_switch->set_pressed_texture(get_icon("MaterialPreviewLight2Off", "EditorIcons"));
+ first_enter = false;
}
-
}
- if (p_what==NOTIFICATION_DRAW) {
-
+ if (p_what == NOTIFICATION_DRAW) {
- Ref<Texture> checkerboard = get_icon("Checkerboard","EditorIcons");
+ Ref<Texture> checkerboard = get_icon("Checkerboard", "EditorIcons");
Size2 size = get_size();
- draw_texture_rect(checkerboard,Rect2(Point2(),size),true);
-
+ //draw_texture_rect(checkerboard, Rect2(Point2(), size), true);
}
}
@@ -85,125 +79,115 @@ void MeshEditor::_update_rotation() {
Transform t;
t.basis.rotate(Vector3(0, 1, 0), -rot_y);
t.basis.rotate(Vector3(1, 0, 0), -rot_x);
- mesh_instance->set_transform(t);
-
+ rotation->set_transform(t);
}
void MeshEditor::edit(Ref<Mesh> p_mesh) {
- mesh=p_mesh;
+ mesh = p_mesh;
mesh_instance->set_mesh(mesh);
if (mesh.is_null()) {
hide();
} else {
- rot_x=0;
- rot_y=0;
+ rot_x = 0;
+ rot_y = 0;
_update_rotation();
- AABB aabb= mesh->get_aabb();
- Vector3 ofs = aabb.pos + aabb.size*0.5;
- aabb.pos-=ofs;
- float m = MAX(aabb.size.x,aabb.size.y)*0.5;
- if (m!=0) {
- m=1.0/m;
- m*=0.5;
+ Rect3 aabb = mesh->get_aabb();
+ print_line("aabb: " + aabb);
+ Vector3 ofs = aabb.position + aabb.size * 0.5;
+ float m = aabb.get_longest_axis_size();
+ if (m != 0) {
+ m = 1.0 / m;
+ m *= 0.5;
//print_line("scale: "+rtos(m));
Transform xform;
- xform.basis.scale(Vector3(m,m,m));
- xform.origin=-xform.basis.xform(ofs); //-ofs*m;
- xform.origin.z-=aabb.size.z*2;
+ xform.basis.scale(Vector3(m, m, m));
+ xform.origin = -xform.basis.xform(ofs); //-ofs*m;
+ //xform.origin.z -= aabb.get_longest_axis_size() * 2;
mesh_instance->set_transform(xform);
}
-
}
-
}
+void MeshEditor::_button_pressed(Node *p_button) {
-void MeshEditor::_button_pressed(Node* p_button) {
-
- if (p_button==light_1_switch) {
- light1->set_enabled(!light_1_switch->is_pressed());
+ if (p_button == light_1_switch) {
+ light1->set_visible(!light_1_switch->is_pressed());
}
- if (p_button==light_2_switch) {
- light2->set_enabled(!light_2_switch->is_pressed());
+ if (p_button == light_2_switch) {
+ light2->set_visible(!light_2_switch->is_pressed());
}
-
-
}
void MeshEditor::_bind_methods() {
- ClassDB::bind_method(D_METHOD("_gui_input"),&MeshEditor::_gui_input);
- ClassDB::bind_method(D_METHOD("_button_pressed"),&MeshEditor::_button_pressed);
-
+ ClassDB::bind_method(D_METHOD("_gui_input"), &MeshEditor::_gui_input);
+ ClassDB::bind_method(D_METHOD("_button_pressed"), &MeshEditor::_button_pressed);
}
MeshEditor::MeshEditor() {
- viewport = memnew( Viewport );
+ viewport = memnew(Viewport);
Ref<World> world;
world.instance();
viewport->set_world(world); //use own world
add_child(viewport);
viewport->set_disable_input(true);
+ set_stretch(true);
- camera = memnew( Camera );
- camera->set_transform(Transform(Matrix3(),Vector3(0,0,3)));
- camera->set_perspective(45,0.1,10);
+ camera = memnew(Camera);
+ camera->set_transform(Transform(Basis(), Vector3(0, 0, 1.1)));
+ camera->set_perspective(45, 0.1, 10);
viewport->add_child(camera);
- light1 = memnew( DirectionalLight );
- light1->set_transform(Transform().looking_at(Vector3(-1,-1,-1),Vector3(0,1,0)));
+ light1 = memnew(DirectionalLight);
+ light1->set_transform(Transform().looking_at(Vector3(-1, -1, -1), Vector3(0, 1, 0)));
viewport->add_child(light1);
- light2 = memnew( DirectionalLight );
- light2->set_transform(Transform().looking_at(Vector3(0,1,0),Vector3(0,0,1)));
- light2->set_color(Light::COLOR_DIFFUSE,Color(0.7,0.7,0.7));
- light2->set_color(Light::COLOR_SPECULAR,Color(0.7,0.7,0.7));
+ light2 = memnew(DirectionalLight);
+ light2->set_transform(Transform().looking_at(Vector3(0, 1, 0), Vector3(0, 0, 1)));
+ light2->set_color(Color(0.7, 0.7, 0.7));
viewport->add_child(light2);
- mesh_instance = memnew( MeshInstance );
- viewport->add_child(mesh_instance);
-
-
+ rotation = memnew(Spatial);
+ viewport->add_child(rotation);
+ mesh_instance = memnew(MeshInstance);
+ rotation->add_child(mesh_instance);
- set_custom_minimum_size(Size2(1,150)*EDSCALE);
+ set_custom_minimum_size(Size2(1, 150) * EDSCALE);
- HBoxContainer *hb = memnew( HBoxContainer );
+ HBoxContainer *hb = memnew(HBoxContainer);
add_child(hb);
hb->set_area_as_parent_rect(2);
hb->add_spacer();
- VBoxContainer *vb_light = memnew( VBoxContainer );
+ VBoxContainer *vb_light = memnew(VBoxContainer);
hb->add_child(vb_light);
- light_1_switch = memnew( TextureButton );
+ light_1_switch = memnew(TextureButton);
light_1_switch->set_toggle_mode(true);
vb_light->add_child(light_1_switch);
- light_1_switch->connect("pressed",this,"_button_pressed",varray(light_1_switch));
+ light_1_switch->connect("pressed", this, "_button_pressed", varray(light_1_switch));
- light_2_switch = memnew( TextureButton );
+ light_2_switch = memnew(TextureButton);
light_2_switch->set_toggle_mode(true);
vb_light->add_child(light_2_switch);
- light_2_switch->connect("pressed",this,"_button_pressed",varray(light_2_switch));
-
- first_enter=true;
-
- rot_x=0;
- rot_y=0;
+ light_2_switch->connect("pressed", this, "_button_pressed", varray(light_2_switch));
+ first_enter = true;
+ rot_x = 0;
+ rot_y = 0;
}
-
void MeshEditorPlugin::edit(Object *p_object) {
- Mesh * s = p_object->cast_to<Mesh>();
+ Mesh *s = p_object->cast_to<Mesh>();
if (!s)
return;
@@ -212,7 +196,7 @@ void MeshEditorPlugin::edit(Object *p_object) {
bool MeshEditorPlugin::handles(Object *p_object) const {
- return p_object->is_type("Mesh");
+ return p_object->is_class("Mesh");
}
void MeshEditorPlugin::make_visible(bool p_visible) {
@@ -225,22 +209,15 @@ void MeshEditorPlugin::make_visible(bool p_visible) {
mesh_editor->hide();
//mesh_editor->set_process(false);
}
-
}
MeshEditorPlugin::MeshEditorPlugin(EditorNode *p_node) {
- editor=p_node;
- mesh_editor = memnew( MeshEditor );
- add_control_to_container(CONTAINER_PROPERTY_EDITOR_BOTTOM,mesh_editor);
+ editor = p_node;
+ mesh_editor = memnew(MeshEditor);
+ add_control_to_container(CONTAINER_PROPERTY_EDITOR_BOTTOM, mesh_editor);
mesh_editor->hide();
-
-
-
}
-
-MeshEditorPlugin::~MeshEditorPlugin()
-{
+MeshEditorPlugin::~MeshEditorPlugin() {
}
-#endif
diff --git a/editor/plugins/mesh_editor_plugin.h b/editor/plugins/mesh_editor_plugin.h
index 1d89448ed8..72d93c4126 100644
--- a/editor/plugins/mesh_editor_plugin.h
+++ b/editor/plugins/mesh_editor_plugin.h
@@ -30,8 +30,6 @@
#ifndef MESH_EDITOR_PLUGIN_H
#define MESH_EDITOR_PLUGIN_H
-#if 0
-
#include "editor/editor_node.h"
#include "editor/editor_plugin.h"
#include "scene/3d/camera.h"
@@ -39,51 +37,48 @@
#include "scene/3d/mesh_instance.h"
#include "scene/resources/material.h"
-class MeshEditor : public Control {
-
- GDCLASS(MeshEditor, Control);
-
+class MeshEditor : public ViewportContainer {
+ GDCLASS(MeshEditor, ViewportContainer);
float rot_x;
float rot_y;
Viewport *viewport;
MeshInstance *mesh_instance;
+ Spatial *rotation;
DirectionalLight *light1;
DirectionalLight *light2;
Camera *camera;
Ref<Mesh> mesh;
-
TextureButton *light_1_switch;
TextureButton *light_2_switch;
- void _button_pressed(Node* p_button);
+ void _button_pressed(Node *p_button);
bool first_enter;
void _update_rotation();
+
protected:
void _notification(int p_what);
- void _gui_input(InputEvent p_event);
+ void _gui_input(Ref<InputEvent> p_event);
static void _bind_methods();
-public:
+public:
void edit(Ref<Mesh> p_mesh);
MeshEditor();
};
-
class MeshEditorPlugin : public EditorPlugin {
- GDCLASS( MeshEditorPlugin, EditorPlugin );
+ GDCLASS(MeshEditorPlugin, EditorPlugin);
MeshEditor *mesh_editor;
EditorNode *editor;
public:
-
virtual String get_name() const { return "Mesh"; }
bool has_main_screen() const { return false; }
virtual void edit(Object *p_node);
@@ -92,8 +87,6 @@ public:
MeshEditorPlugin(EditorNode *p_node);
~MeshEditorPlugin();
-
};
-#endif // MESH_EDITOR_PLUGIN_H
#endif
diff --git a/editor/plugins/mesh_instance_editor_plugin.cpp b/editor/plugins/mesh_instance_editor_plugin.cpp
index ab09d0dd96..49498d0fa0 100644
--- a/editor/plugins/mesh_instance_editor_plugin.cpp
+++ b/editor/plugins/mesh_instance_editor_plugin.cpp
@@ -29,7 +29,7 @@
/*************************************************************************/
#include "mesh_instance_editor_plugin.h"
-#include "scene/3d/body_shape.h"
+#include "scene/3d/collision_shape.h"
#include "scene/3d/navigation_mesh.h"
#include "scene/3d/physics_body.h"
#include "scene/gui/box_container.h"
diff --git a/editor/plugins/navigation_polygon_editor_plugin.cpp b/editor/plugins/navigation_polygon_editor_plugin.cpp
index 1457b28ed1..725e57fe0b 100644
--- a/editor/plugins/navigation_polygon_editor_plugin.cpp
+++ b/editor/plugins/navigation_polygon_editor_plugin.cpp
@@ -140,7 +140,7 @@ bool NavigationPolygonEditor::forward_gui_input(const Ref<InputEvent> &p_event)
cpoint = node->get_global_transform().affine_inverse().xform(cpoint);
//first check if a point is to be added (segment split)
- real_t grab_treshold = EDITOR_DEF("editors/poly_editor/point_grab_radius", 8);
+ real_t grab_threshold = EDITOR_DEF("editors/poly_editor/point_grab_radius", 8);
switch (mode) {
@@ -160,7 +160,7 @@ bool NavigationPolygonEditor::forward_gui_input(const Ref<InputEvent> &p_event)
return true;
} else {
- if (wip.size() > 1 && xform.xform(wip[0]).distance_to(gpoint) < grab_treshold) {
+ if (wip.size() > 1 && xform.xform(wip[0]).distance_to(gpoint) < grab_threshold) {
//wip closed
_wip_close();
@@ -211,7 +211,7 @@ bool NavigationPolygonEditor::forward_gui_input(const Ref<InputEvent> &p_event)
continue; //not valid to reuse point
real_t d = cp.distance_to(gpoint);
- if (d < closest_dist && d < grab_treshold) {
+ if (d < closest_dist && d < grab_threshold) {
closest_dist = d;
closest_outline = j;
closest_pos = cp;
@@ -252,7 +252,7 @@ bool NavigationPolygonEditor::forward_gui_input(const Ref<InputEvent> &p_event)
Vector2 cp = xform.xform(poly[i]);
real_t d = cp.distance_to(gpoint);
- if (d < closest_dist && d < grab_treshold) {
+ if (d < closest_dist && d < grab_threshold) {
closest_dist = d;
closest_pos = cp;
closest_outline = j;
@@ -312,7 +312,7 @@ bool NavigationPolygonEditor::forward_gui_input(const Ref<InputEvent> &p_event)
Vector2 cp = xform.xform(poly[i]);
real_t d = cp.distance_to(gpoint);
- if (d < closest_dist && d < grab_treshold) {
+ if (d < closest_dist && d < grab_threshold) {
closest_dist = d;
closest_pos = cp;
closest_outline = j;
diff --git a/editor/plugins/path_2d_editor_plugin.cpp b/editor/plugins/path_2d_editor_plugin.cpp
index f9f16fea16..3a210f3fe0 100644
--- a/editor/plugins/path_2d_editor_plugin.cpp
+++ b/editor/plugins/path_2d_editor_plugin.cpp
@@ -248,7 +248,7 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
edited_point=1;
return true;
} else {
- if (wip.size()>1 && xform.xform(wip[0]).distance_to(gpoint)<grab_treshold) {
+ if (wip.size()>1 && xform.xform(wip[0]).distance_to(gpoint)<grab_threshold) {
//wip closed
_wip_close();
@@ -307,7 +307,7 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
continue; //not valid to reuse point
real_t d = cp.distance_to(gpoint);
- if (d<closest_dist && d<grab_treshold) {
+ if (d<closest_dist && d<grab_threshold) {
closest_dist=d;
closest_pos=cp;
closest_idx=i;
@@ -343,7 +343,7 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
Vector2 cp =xform.xform(poly[i]);
real_t d = cp.distance_to(gpoint);
- if (d<closest_dist && d<grab_treshold) {
+ if (d<closest_dist && d<grab_threshold) {
closest_dist=d;
closest_pos=cp;
closest_idx=i;
@@ -396,7 +396,7 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
Vector2 cp =xform.xform(poly[i]);
real_t d = cp.distance_to(gpoint);
- if (d<closest_dist && d<grab_treshold) {
+ if (d<closest_dist && d<grab_threshold) {
closest_dist=d;
closest_pos=cp;
closest_idx=i;
diff --git a/editor/plugins/path_editor_plugin.cpp b/editor/plugins/path_editor_plugin.cpp
index 877707d77b..c32ed1064f 100644
--- a/editor/plugins/path_editor_plugin.cpp
+++ b/editor/plugins/path_editor_plugin.cpp
@@ -104,7 +104,7 @@ void PathSpatialGizmo::set_handle(int p_idx, Camera *p_camera, const Point2 &p_p
if (SpatialEditor::get_singleton()->is_snap_enabled()) {
float snap = SpatialEditor::get_singleton()->get_translate_snap();
- inters.snap(snap);
+ inters.snap(Vector3(snap, snap, snap));
}
Vector3 local = gi.xform(inters);
@@ -204,7 +204,7 @@ void PathSpatialGizmo::redraw() {
if (c.is_null())
return;
- PoolVector<Vector3> v3a = c->tesselate();
+ PoolVector<Vector3> v3a = c->tessellate();
//PoolVector<Vector3> v3a=c->get_baked_points();
int v3s = v3a.size();
@@ -289,7 +289,7 @@ bool PathEditorPlugin::forward_spatial_gui_input(Camera *p_camera, const Ref<Inp
if (mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT && (curve_create->is_pressed() || (curve_edit->is_pressed() && mb->get_control()))) {
//click into curve, break it down
- PoolVector<Vector3> v3a = c->tesselate();
+ PoolVector<Vector3> v3a = c->tessellate();
int idx = 0;
int rc = v3a.size();
int closest_seg = -1;
diff --git a/editor/plugins/polygon_2d_editor_plugin.cpp b/editor/plugins/polygon_2d_editor_plugin.cpp
index dd13ca0e63..24ccdcd445 100644
--- a/editor/plugins/polygon_2d_editor_plugin.cpp
+++ b/editor/plugins/polygon_2d_editor_plugin.cpp
@@ -220,7 +220,7 @@ bool Polygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
Vector<Vector2> poly = Variant(node->get_polygon());
//first check if a point is to be added (segment split)
- real_t grab_treshold = EDITOR_DEF("editors/poly_editor/point_grab_radius", 8);
+ real_t grab_threshold = EDITOR_DEF("editors/poly_editor/point_grab_radius", 8);
switch (mode) {
@@ -239,7 +239,7 @@ bool Polygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
return true;
} else {
- if (wip.size() > 1 && xform.xform(wip[0] + node->get_offset()).distance_to(gpoint) < grab_treshold) {
+ if (wip.size() > 1 && xform.xform(wip[0] + node->get_offset()).distance_to(gpoint) < grab_threshold) {
//wip closed
_wip_close();
@@ -293,7 +293,7 @@ bool Polygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
continue; //not valid to reuse point
real_t d = cp.distance_to(gpoint);
- if (d < closest_dist && d < grab_treshold) {
+ if (d < closest_dist && d < grab_threshold) {
closest_dist = d;
closest_pos = cp;
closest_idx = i;
@@ -322,7 +322,7 @@ bool Polygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
Vector2 cp = xform.xform(poly[i] + node->get_offset());
real_t d = cp.distance_to(gpoint);
- if (d < closest_dist && d < grab_treshold) {
+ if (d < closest_dist && d < grab_threshold) {
closest_dist = d;
closest_pos = cp;
closest_idx = i;
@@ -367,7 +367,7 @@ bool Polygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
Vector2 cp = xform.xform(poly[i] + node->get_offset());
real_t d = cp.distance_to(gpoint);
- if (d < closest_dist && d < grab_treshold) {
+ if (d < closest_dist && d < grab_threshold) {
closest_dist = d;
closest_pos = cp;
closest_idx = i;
diff --git a/editor/plugins/resource_preloader_editor_plugin.cpp b/editor/plugins/resource_preloader_editor_plugin.cpp
index ea7a84d2f4..2703da12fe 100644
--- a/editor/plugins/resource_preloader_editor_plugin.cpp
+++ b/editor/plugins/resource_preloader_editor_plugin.cpp
@@ -30,8 +30,8 @@
#include "resource_preloader_editor_plugin.h"
#include "editor/editor_settings.h"
-#include "global_config.h"
#include "io/resource_loader.h"
+#include "project_settings.h"
void ResourcePreloaderEditor::_gui_input(Ref<InputEvent> p_event) {
}
diff --git a/editor/plugins/sample_editor_plugin.cpp b/editor/plugins/sample_editor_plugin.cpp
index a9af5823e3..739a8abb53 100644
--- a/editor/plugins/sample_editor_plugin.cpp
+++ b/editor/plugins/sample_editor_plugin.cpp
@@ -31,8 +31,8 @@
#if 0
#include "editor/editor_settings.h"
-#include "global_config.h"
#include "io/resource_loader.h"
+#include "project_settings.h"
diff --git a/editor/plugins/sample_library_editor_plugin.cpp b/editor/plugins/sample_library_editor_plugin.cpp
index 9eb1af70d1..5ccfde15ff 100644
--- a/editor/plugins/sample_library_editor_plugin.cpp
+++ b/editor/plugins/sample_library_editor_plugin.cpp
@@ -32,8 +32,8 @@
#include "sample_library_editor_plugin.h"
#include "editor/editor_settings.h"
-#include "global_config.h"
#include "io/resource_loader.h"
+#include "project_settings.h"
#include "sample_editor_plugin.h"
#include "scene/main/viewport.h"
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp
index 0024870665..77c540b746 100644
--- a/editor/plugins/script_editor_plugin.cpp
+++ b/editor/plugins/script_editor_plugin.cpp
@@ -32,13 +32,13 @@
#include "editor/editor_node.h"
#include "editor/editor_settings.h"
#include "editor/script_editor_debugger.h"
-#include "global_config.h"
#include "io/resource_loader.h"
#include "io/resource_saver.h"
#include "os/file_access.h"
#include "os/input.h"
#include "os/keyboard.h"
#include "os/os.h"
+#include "project_settings.h"
#include "scene/main/viewport.h"
/*** SCRIPT EDITOR ****/
@@ -405,6 +405,8 @@ void ScriptEditor::_go_to_tab(int p_idx) {
script_icon->set_texture(c->cast_to<ScriptEditorBase>()->get_icon());
if (is_visible_in_tree())
c->cast_to<ScriptEditorBase>()->ensure_focus();
+
+ notify_script_changed(c->cast_to<ScriptEditorBase>()->get_edited_script());
}
if (c->cast_to<EditorHelp>()) {
@@ -509,14 +511,16 @@ void ScriptEditor::_close_tab(int p_idx, bool p_save) {
if (p_save) {
apply_scripts();
}
- if (current->get_edit_menu()) {
- memdelete(current->get_edit_menu());
- }
+ current->clear_edit_menu();
+ notify_script_close(current->get_edited_script());
} else {
EditorHelp *help = tab_container->get_child(selected)->cast_to<EditorHelp>();
_add_recent_script(help->get_class());
}
+ // roll back to previous tab
+ _history_back();
+
//remove from history
history.resize(history_pos + 1);
@@ -778,6 +782,31 @@ void ScriptEditor::_file_dialog_action(String p_file) {
file_dialog_option = -1;
}
+Ref<Script> ScriptEditor::_get_current_script() {
+
+ int selected = tab_container->get_current_tab();
+ if (selected < 0 || selected >= tab_container->get_child_count())
+ return NULL;
+
+ ScriptEditorBase *current = tab_container->get_child(selected)->cast_to<ScriptEditorBase>();
+ if (current) {
+ return current->get_edited_script();
+ } else {
+ return NULL;
+ }
+}
+
+Array ScriptEditor::_get_open_scripts() const {
+
+ Array ret;
+ Vector<Ref<Script> > scripts = get_open_scripts();
+ int scrits_amount = scripts.size();
+ for (int idx_script = 0; idx_script < scrits_amount; idx_script++) {
+ ret.push_back(scripts[idx_script]);
+ }
+ return ret;
+}
+
void ScriptEditor::_menu_option(int p_option) {
switch (p_option) {
@@ -877,6 +906,9 @@ void ScriptEditor::_menu_option(int p_option) {
bool debug_with_external_editor = !debug_menu->get_popup()->is_item_checked(debug_menu->get_popup()->get_item_index(DEBUG_WITH_EXTERNAL_EDITOR));
debugger->set_debug_with_external_editor(debug_with_external_editor);
debug_menu->get_popup()->set_item_checked(debug_menu->get_popup()->get_item_index(DEBUG_WITH_EXTERNAL_EDITOR), debug_with_external_editor);
+ } break;
+ case TOGGLE_SCRIPTS_PANEL: {
+ list_split->set_visible(!list_split->is_visible());
}
}
@@ -1054,7 +1086,7 @@ void ScriptEditor::_notification(int p_what) {
}
EditorSettings::get_singleton()->connect("settings_changed", this, "_editor_settings_changed");
- help_search->set_icon(get_icon("Help", "EditorIcons"));
+ help_search->set_icon(get_icon("HelpSearch", "EditorIcons"));
site_search->set_icon(get_icon("Instance", "EditorIcons"));
class_search->set_icon(get_icon("ClassList", "EditorIcons"));
@@ -1125,6 +1157,14 @@ void ScriptEditor::edited_scene_changed() {
_update_modified_scripts_for_external_editor();
}
+void ScriptEditor::notify_script_close(const Ref<Script> &p_script) {
+ emit_signal("script_close", p_script);
+}
+
+void ScriptEditor::notify_script_changed(const Ref<Script> &p_script) {
+ emit_signal("editor_script_changed", p_script);
+}
+
static const Node *_find_node_with_script(const Node *p_node, const RefPtr &p_script) {
if (p_node->get_script() == p_script)
@@ -1279,7 +1319,8 @@ void ScriptEditor::ensure_focus_current() {
int cidx = tab_container->get_current_tab();
if (cidx < 0 || cidx >= tab_container->get_tab_count())
- ;
+ return;
+
Control *c = tab_container->get_child(cidx)->cast_to<Control>();
if (!c)
return;
@@ -1369,6 +1410,11 @@ struct _ScriptEditorItemData {
};
void ScriptEditor::_update_members_overview_visibility() {
+
+ int selected = tab_container->get_current_tab();
+ if (selected < 0 || selected >= tab_container->get_child_count())
+ return;
+
Node *current = tab_container->get_child(tab_container->get_current_tab());
ScriptEditorBase *se = current->cast_to<ScriptEditorBase>();
if (!se) {
@@ -1386,6 +1432,10 @@ void ScriptEditor::_update_members_overview_visibility() {
void ScriptEditor::_update_members_overview() {
members_overview->clear();
+ int selected = tab_container->get_current_tab();
+ if (selected < 0 || selected >= tab_container->get_child_count())
+ return;
+
Node *current = tab_container->get_child(tab_container->get_current_tab());
ScriptEditorBase *se = current->cast_to<ScriptEditorBase>();
if (!se) {
@@ -1566,8 +1616,8 @@ bool ScriptEditor::edit(const Ref<Script> &p_script, int p_line, int p_col, bool
String flags = EditorSettings::get_singleton()->get("text_editor/external/exec_flags");
Dictionary keys;
- keys["project"] = GlobalConfig::get_singleton()->get_resource_path();
- keys["file"] = GlobalConfig::get_singleton()->globalize_path(p_script->get_path());
+ keys["project"] = ProjectSettings::get_singleton()->get_resource_path();
+ keys["file"] = ProjectSettings::get_singleton()->globalize_path(p_script->get_path());
keys["line"] = p_line >= 0 ? p_line : 0;
keys["col"] = p_col;
@@ -1660,6 +1710,7 @@ bool ScriptEditor::edit(const Ref<Script> &p_script, int p_line, int p_col, bool
if (p_line >= 0)
se->goto_line(p_line - 1);
+ notify_script_changed(p_script);
return true;
}
@@ -1885,6 +1936,9 @@ void ScriptEditor::set_window_layout(Ref<ConfigFile> p_layout) {
for (int i = 0; i < helps.size(); i++) {
String path = helps[i];
+ if (path == "") { // invalid, skip
+ continue;
+ }
_help_class_open(path);
}
@@ -2033,6 +2087,8 @@ void ScriptEditor::_update_history_pos(int p_new_pos) {
n->cast_to<ScriptEditorBase>()->set_edit_state(history[history_pos].state);
n->cast_to<ScriptEditorBase>()->ensure_focus();
+
+ notify_script_changed(n->cast_to<ScriptEditorBase>()->get_edited_script());
}
if (n->cast_to<EditorHelp>()) {
@@ -2060,6 +2116,21 @@ void ScriptEditor::_history_back() {
_update_history_pos(history_pos - 1);
}
}
+
+Vector<Ref<Script> > ScriptEditor::get_open_scripts() const {
+
+ Vector<Ref<Script> > out_scripts = Vector<Ref<Script> >();
+
+ for (int i = 0; i < tab_container->get_child_count(); i++) {
+ ScriptEditorBase *se = tab_container->get_child(i)->cast_to<ScriptEditorBase>();
+ if (!se)
+ continue;
+ out_scripts.push_back(se->get_edited_script());
+ }
+
+ return out_scripts;
+}
+
void ScriptEditor::set_scene_root_script(Ref<Script> p_script) {
bool open_dominant = EditorSettings::get_singleton()->get("text_editor/files/open_dominant_script_on_scene_change");
@@ -2153,6 +2224,12 @@ void ScriptEditor::_bind_methods() {
ClassDB::bind_method("_history_back", &ScriptEditor::_history_back);
ClassDB::bind_method("_live_auto_reload_running_scripts", &ScriptEditor::_live_auto_reload_running_scripts);
ClassDB::bind_method("_unhandled_input", &ScriptEditor::_unhandled_input);
+
+ ClassDB::bind_method(D_METHOD("get_current_script"), &ScriptEditor::_get_current_script);
+ ClassDB::bind_method(D_METHOD("get_open_scripts"), &ScriptEditor::_get_open_scripts);
+
+ ADD_SIGNAL(MethodInfo("editor_script_changed", PropertyInfo(Variant::OBJECT, "script:Script")));
+ ADD_SIGNAL(MethodInfo("script_close", PropertyInfo(Variant::OBJECT, "script:Script")));
}
ScriptEditor::ScriptEditor(EditorNode *p_editor) {
@@ -2167,11 +2244,17 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
members_overview_enabled = true;
editor = p_editor;
+ Ref<StyleBox> sb = p_editor->get_gui_base()->get_stylebox("panel", "TabContainer")->duplicate();
+ sb->set_default_margin(MARGIN_TOP, 0);
+ add_style_override("panel", sb);
+ VBoxContainer *main_container = memnew(VBoxContainer);
+ add_child(main_container);
+
menu_hb = memnew(HBoxContainer);
- add_child(menu_hb);
+ main_container->add_child(menu_hb);
script_split = memnew(HSplitContainer);
- add_child(script_split);
+ main_container->add_child(script_split);
script_split->set_v_size_flags(SIZE_EXPAND_FILL);
list_split = memnew(VSplitContainer);
@@ -2180,13 +2263,15 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
script_list = memnew(ItemList);
list_split->add_child(script_list);
- script_list->set_custom_minimum_size(Size2(0, 0));
+ script_list->set_custom_minimum_size(Size2(150 * EDSCALE, 100)); //need to give a bit of limit to avoid it from disappearing
+ script_list->set_v_size_flags(SIZE_EXPAND_FILL);
script_split->set_split_offset(140);
- list_split->set_split_offset(500);
+ //list_split->set_split_offset(500);
members_overview = memnew(ItemList);
list_split->add_child(members_overview);
- members_overview->set_custom_minimum_size(Size2(0, 0));
+ members_overview->set_custom_minimum_size(Size2(0, 100)); //need to give a bit of limit to avoid it from disappearing
+ members_overview->set_v_size_flags(SIZE_EXPAND_FILL);
tab_container = memnew(TabContainer);
tab_container->add_style_override("panel", p_editor->get_gui_base()->get_stylebox("ScriptPanel", "EditorStyles"));
@@ -2231,6 +2316,8 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/close_docs", TTR("Close Docs")), CLOSE_DOCS);
file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/close_file", TTR("Close"), KEY_MASK_CMD | KEY_W), FILE_CLOSE);
file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/close_all", TTR("Close All")), CLOSE_ALL);
+ file_menu->get_popup()->add_separator();
+ file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/toggle_scripts_panel", TTR("Toggle Scripts Panel"), KEY_MASK_CMD | KEY_BACKSLASH), TOGGLE_SCRIPTS_PANEL);
file_menu->get_popup()->connect("id_pressed", this, "_menu_option");
script_search_menu = memnew(MenuButton);
diff --git a/editor/plugins/script_editor_plugin.h b/editor/plugins/script_editor_plugin.h
index 3b444c0883..d8a9415df1 100644
--- a/editor/plugins/script_editor_plugin.h
+++ b/editor/plugins/script_editor_plugin.h
@@ -106,6 +106,7 @@ public:
virtual void set_tooltip_request_func(String p_method, Object *p_obj) = 0;
virtual Control *get_edit_menu() = 0;
+ virtual void clear_edit_menu() = 0;
ScriptEditorBase() {}
};
@@ -114,9 +115,9 @@ typedef ScriptEditorBase *(*CreateScriptEditorFunc)(const Ref<Script> &p_script)
class EditorScriptCodeCompletionCache;
-class ScriptEditor : public VBoxContainer {
+class ScriptEditor : public PanelContainer {
- GDCLASS(ScriptEditor, VBoxContainer);
+ GDCLASS(ScriptEditor, PanelContainer);
EditorNode *editor;
enum {
@@ -133,6 +134,7 @@ class ScriptEditor : public VBoxContainer {
FILE_CLOSE,
CLOSE_DOCS,
CLOSE_ALL,
+ TOGGLE_SCRIPTS_PANEL,
FILE_TOOL_RELOAD,
FILE_TOOL_RELOAD_SOFT,
DEBUG_NEXT,
@@ -319,6 +321,9 @@ class ScriptEditor : public VBoxContainer {
int file_dialog_option;
void _file_dialog_action(String p_file);
+ Ref<Script> _get_current_script();
+ Array _get_open_scripts() const;
+
static void _open_script_request(const String &p_path);
static ScriptEditor *script_editor;
@@ -352,17 +357,23 @@ public:
void get_window_layout(Ref<ConfigFile> p_layout);
void set_scene_root_script(Ref<Script> p_script);
+ Vector<Ref<Script> > get_open_scripts() const;
bool script_goto_method(Ref<Script> p_script, const String &p_method);
virtual void edited_scene_changed();
+ void notify_script_close(const Ref<Script> &p_script);
+ void notify_script_changed(const Ref<Script> &p_script);
+
void close_builtin_scripts_from_scene(const String &p_scene);
void goto_help(const String &p_desc) { _help_class_goto(p_desc); }
bool can_take_away_focus() const;
+ VSplitContainer *get_left_list_split() { return list_split; }
+
ScriptEditorDebugger *get_debugger() { return debugger; }
void set_live_auto_reload_running_scripts(bool p_enabled);
diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp
index 60fd9d8e30..e260b1ea22 100644
--- a/editor/plugins/script_text_editor.cpp
+++ b/editor/plugins/script_text_editor.cpp
@@ -1093,6 +1093,10 @@ Control *ScriptTextEditor::get_edit_menu() {
return edit_hb;
}
+void ScriptTextEditor::clear_edit_menu() {
+ memdelete(edit_hb);
+}
+
void ScriptTextEditor::reload(bool p_soft) {
TextEdit *te = code_editor->get_text_edit();
@@ -1272,8 +1276,6 @@ void ScriptTextEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) {
color_picker->set_pick_color(Color(color[0], color[1], color[2], alpha));
}
color_panel->set_position(get_global_transform().xform(get_local_mouse_pos()));
- Size2 ms = Size2(300, color_picker->get_combined_minimum_size().height + 10);
- color_panel->set_size(ms);
} else {
have_color = false;
}
@@ -1356,7 +1358,6 @@ ScriptTextEditor::ScriptTextEditor() {
add_child(color_panel);
color_picker = memnew(ColorPicker);
color_panel->add_child(color_picker);
- color_panel->set_child_rect(color_picker); //NOT
color_picker->connect("color_changed", this, "_color_changed");
edit_hb = memnew(HBoxContainer);
diff --git a/editor/plugins/script_text_editor.h b/editor/plugins/script_text_editor.h
index ba40645161..e55847832f 100644
--- a/editor/plugins/script_text_editor.h
+++ b/editor/plugins/script_text_editor.h
@@ -156,7 +156,7 @@ public:
virtual void set_debugger_active(bool p_active);
Control *get_edit_menu();
-
+ virtual void clear_edit_menu();
static void register_editor();
ScriptTextEditor();
diff --git a/editor/plugins/shader_graph_editor_plugin.cpp b/editor/plugins/shader_graph_editor_plugin.cpp
index 9c65ef667a..5506c035ec 100644
--- a/editor/plugins/shader_graph_editor_plugin.cpp
+++ b/editor/plugins/shader_graph_editor_plugin.cpp
@@ -1382,7 +1382,7 @@ ToolButton *ShaderGraphView::make_editor(String text,GraphNode* gn,int p_id,int
Color c = graph->default_get_value(type,p_id,param);
for (int x=1;x<14;x++)
for (int y=1;y<14;y++)
- icon_color.put_pixel(x,y,c);
+ icon_color.set_pixel(x,y,c);
Ref<ImageTexture> t;
t.instance();
t->create_from_image(icon_color);
diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp
index c55bef1b03..2d77bfb2c1 100644
--- a/editor/plugins/spatial_editor_plugin.cpp
+++ b/editor/plugins/spatial_editor_plugin.cpp
@@ -36,9 +36,9 @@
#include "editor/editor_settings.h"
#include "editor/plugins/animation_player_editor_plugin.h"
#include "editor/spatial_editor_gizmos.h"
-#include "global_config.h"
#include "os/keyboard.h"
#include "print_string.h"
+#include "project_settings.h"
#include "scene/3d/camera.h"
#include "scene/3d/visual_instance.h"
#include "scene/resources/surface_tool.h"
@@ -518,7 +518,7 @@ void SpatialEditorViewport::_compute_edit(const Point2 &p_point) {
*/
}
-static int _get_key_modifier(const String &p_property) {
+static int _get_key_modifier_setting(const String &p_property) {
switch (EditorSettings::get_singleton()->get(p_property).operator int()) {
@@ -531,6 +531,18 @@ static int _get_key_modifier(const String &p_property) {
return 0;
}
+static int _get_key_modifier(Ref<InputEventWithModifiers> e) {
+ if (e->get_shift())
+ return KEY_SHIFT;
+ if (e->get_alt())
+ return KEY_ALT;
+ if (e->get_control())
+ return KEY_CONTROL;
+ if (e->get_metakey())
+ return KEY_META;
+ return 0;
+}
+
bool SpatialEditorViewport::_gizmo_select(const Vector2 &p_screenpos, bool p_highlight_only) {
if (!spatial_editor->is_gizmo_visible())
@@ -774,7 +786,15 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
set_message(TTR("Transform Aborted."), 3);
}
- freelook_active = b->is_pressed();
+ if (b->is_pressed()) {
+ int mod = _get_key_modifier(b);
+ if (mod == _get_key_modifier_setting("editors/3d/freelook_activation_modifier")) {
+ freelook_active = true;
+ }
+ } else {
+ freelook_active = false;
+ }
+
if (freelook_active && !surface->has_focus()) {
// Focus usually doesn't trigger on right-click, but in case of freelook it should,
// otherwise using keyboard navigation would misbehave
@@ -1180,7 +1200,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
if (_edit.snap || spatial_editor->is_snap_enabled()) {
snap = spatial_editor->get_translate_snap();
- motion.snap(snap);
+ motion.snap(Vector3(snap, snap, snap));
}
//set_message("Translating: "+motion);
@@ -1297,7 +1317,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
if (nav_scheme == NAVIGATION_MAYA && m->get_alt()) {
nav_mode = NAVIGATION_ZOOM;
- } else {
+ } else if (freelook_active) {
nav_mode = NAVIGATION_LOOK;
}
@@ -1305,21 +1325,13 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
if (nav_scheme == NAVIGATION_GODOT) {
- int mod = 0;
- if (m->get_shift())
- mod = KEY_SHIFT;
- if (m->get_alt())
- mod = KEY_ALT;
- if (m->get_control())
- mod = KEY_CONTROL;
- if (m->get_metakey())
- mod = KEY_META;
+ int mod = _get_key_modifier(m);
- if (mod == _get_key_modifier("editors/3d/pan_modifier"))
+ if (mod == _get_key_modifier_setting("editors/3d/pan_modifier"))
nav_mode = NAVIGATION_PAN;
- else if (mod == _get_key_modifier("editors/3d/zoom_modifier"))
+ else if (mod == _get_key_modifier_setting("editors/3d/zoom_modifier"))
nav_mode = NAVIGATION_ZOOM;
- else if (mod == _get_key_modifier("editors/3d/orbit_modifier"))
+ else if (mod == _get_key_modifier_setting("editors/3d/orbit_modifier"))
nav_mode = NAVIGATION_ORBIT;
} else if (nav_scheme == NAVIGATION_MAYA) {
@@ -1329,22 +1341,14 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
} else if (EditorSettings::get_singleton()->get("editors/3d/emulate_3_button_mouse")) {
// Handle trackpad (no external mouse) use case
- int mod = 0;
- if (m->get_shift())
- mod = KEY_SHIFT;
- if (m->get_alt())
- mod = KEY_ALT;
- if (m->get_control())
- mod = KEY_CONTROL;
- if (m->get_metakey())
- mod = KEY_META;
+ int mod = _get_key_modifier(m);
if (mod) {
- if (mod == _get_key_modifier("editors/3d/pan_modifier"))
+ if (mod == _get_key_modifier_setting("editors/3d/pan_modifier"))
nav_mode = NAVIGATION_PAN;
- else if (mod == _get_key_modifier("editors/3d/zoom_modifier"))
+ else if (mod == _get_key_modifier_setting("editors/3d/zoom_modifier"))
nav_mode = NAVIGATION_ZOOM;
- else if (mod == _get_key_modifier("editors/3d/orbit_modifier"))
+ else if (mod == _get_key_modifier_setting("editors/3d/orbit_modifier"))
nav_mode = NAVIGATION_ORBIT;
}
}
@@ -1559,13 +1563,13 @@ void SpatialEditorViewport::_update_freelook(real_t delta) {
Vector3 right = camera->get_transform().basis.xform(Vector3(1, 0, 0));
Vector3 up = camera->get_transform().basis.xform(Vector3(0, 1, 0));
- int key_left = ED_SHORTCUT("spatial_editor/freelook_left", TTR("Freelook Left"), KEY_A)->get_shortcut()->cast_to<InputEventKey>()->get_scancode();
- int key_right = ED_SHORTCUT("spatial_editor/freelook_right", TTR("Freelook Right"), KEY_D)->get_shortcut()->cast_to<InputEventKey>()->get_scancode();
- int key_forward = ED_SHORTCUT("spatial_editor/freelook_forward", TTR("Freelook Forward"), KEY_W)->get_shortcut()->cast_to<InputEventKey>()->get_scancode();
- int key_backwards = ED_SHORTCUT("spatial_editor/freelook_backwards", TTR("Freelook Backwards"), KEY_S)->get_shortcut()->cast_to<InputEventKey>()->get_scancode();
- int key_up = ED_SHORTCUT("spatial_editor/freelook_up", TTR("Freelook Up"), KEY_Q)->get_shortcut()->cast_to<InputEventKey>()->get_scancode();
- int key_down = ED_SHORTCUT("spatial_editor/freelook_down", TTR("Freelook Down"), KEY_E)->get_shortcut()->cast_to<InputEventKey>()->get_scancode();
- int key_speed_modifier = ED_SHORTCUT("spatial_editor/freelook_speed_modifier", TTR("Freelook Speed Modifier"), KEY_SHIFT)->get_shortcut()->cast_to<InputEventKey>()->get_scancode();
+ int key_left = ED_GET_SHORTCUT("spatial_editor/freelook_left")->get_shortcut()->cast_to<InputEventKey>()->get_scancode();
+ int key_right = ED_GET_SHORTCUT("spatial_editor/freelook_right")->get_shortcut()->cast_to<InputEventKey>()->get_scancode();
+ int key_forward = ED_GET_SHORTCUT("spatial_editor/freelook_forward")->get_shortcut()->cast_to<InputEventKey>()->get_scancode();
+ int key_backwards = ED_GET_SHORTCUT("spatial_editor/freelook_backwards")->get_shortcut()->cast_to<InputEventKey>()->get_scancode();
+ int key_up = ED_GET_SHORTCUT("spatial_editor/freelook_up")->get_shortcut()->cast_to<InputEventKey>()->get_scancode();
+ int key_down = ED_GET_SHORTCUT("spatial_editor/freelook_down")->get_shortcut()->cast_to<InputEventKey>()->get_scancode();
+ int key_speed_modifier = ED_GET_SHORTCUT("spatial_editor/freelook_speed_modifier")->get_shortcut()->cast_to<InputEventKey>()->get_scancode();
Vector3 velocity;
bool pressed = false;
@@ -1717,11 +1721,11 @@ void SpatialEditorViewport::_notification(int p_what) {
//update shadow atlas if changed
- int shadowmap_size = GlobalConfig::get_singleton()->get("rendering/shadow_atlas/size");
- int atlas_q0 = GlobalConfig::get_singleton()->get("rendering/shadow_atlas/quadrant_0_subdiv");
- int atlas_q1 = GlobalConfig::get_singleton()->get("rendering/shadow_atlas/quadrant_1_subdiv");
- int atlas_q2 = GlobalConfig::get_singleton()->get("rendering/shadow_atlas/quadrant_2_subdiv");
- int atlas_q3 = GlobalConfig::get_singleton()->get("rendering/shadow_atlas/quadrant_3_subdiv");
+ int shadowmap_size = ProjectSettings::get_singleton()->get("rendering/quality/shadow_atlas/size");
+ int atlas_q0 = ProjectSettings::get_singleton()->get("rendering/quality/shadow_atlas/quadrant_0_subdiv");
+ int atlas_q1 = ProjectSettings::get_singleton()->get("rendering/quality/shadow_atlas/quadrant_1_subdiv");
+ int atlas_q2 = ProjectSettings::get_singleton()->get("rendering/quality/shadow_atlas/quadrant_2_subdiv");
+ int atlas_q3 = ProjectSettings::get_singleton()->get("rendering/quality/shadow_atlas/quadrant_3_subdiv");
viewport->set_shadow_atlas_size(shadowmap_size);
viewport->set_shadow_atlas_quadrant_subdiv(0, Viewport::ShadowAtlasQuadrantSubdiv(atlas_q0));
@@ -1731,10 +1735,10 @@ void SpatialEditorViewport::_notification(int p_what) {
//update msaa if changed
- int msaa_mode = GlobalConfig::get_singleton()->get("rendering/quality/msaa");
+ int msaa_mode = ProjectSettings::get_singleton()->get("rendering/quality/filters/msaa");
viewport->set_msaa(Viewport::MSAA(msaa_mode));
- bool hdr = GlobalConfig::get_singleton()->get("rendering/quality/hdr");
+ bool hdr = ProjectSettings::get_singleton()->get("rendering/quality/depth/hdr");
viewport->set_hdr(hdr);
bool show_info = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_INFORMATION));
@@ -1834,7 +1838,7 @@ void SpatialEditorViewport::_draw() {
if (previewing) {
- Size2 ss = Size2(GlobalConfig::get_singleton()->get("display/width"), GlobalConfig::get_singleton()->get("display/height"));
+ Size2 ss = Size2(ProjectSettings::get_singleton()->get("display/window/size/width"), ProjectSettings::get_singleton()->get("display/window/size/height"));
float aspect = ss.aspect();
Size2 s = get_size();
@@ -2025,6 +2029,15 @@ void SpatialEditorViewport::_menu_option(int p_option) {
view_menu->get_popup()->set_item_checked(idx, current);
} break;
+ case VIEW_AUDIO_DOPPLER: {
+
+ int idx = view_menu->get_popup()->get_item_index(VIEW_AUDIO_DOPPLER);
+ bool current = view_menu->get_popup()->is_item_checked(idx);
+ current = !current;
+ camera->set_doppler_tracking(current ? Camera::DOPPLER_TRACKING_IDLE_STEP : Camera::DOPPLER_TRACKING_DISABLED);
+ view_menu->get_popup()->set_item_checked(idx, current);
+
+ } break;
case VIEW_GIZMOS: {
int idx = view_menu->get_popup()->get_item_index(VIEW_GIZMOS);
@@ -2237,6 +2250,13 @@ void SpatialEditorViewport::set_state(const Dictionary &p_state) {
viewport->set_as_audio_listener(listener);
view_menu->get_popup()->set_item_checked(idx, listener);
}
+ if (p_state.has("doppler")) {
+ bool doppler = p_state["doppler"];
+
+ int idx = view_menu->get_popup()->get_item_index(VIEW_AUDIO_DOPPLER);
+ camera->set_doppler_tracking(doppler ? Camera::DOPPLER_TRACKING_IDLE_STEP : Camera::DOPPLER_TRACKING_DISABLED);
+ view_menu->get_popup()->set_item_checked(idx, doppler);
+ }
if (p_state.has("previewing")) {
Node *pv = EditorNode::get_singleton()->get_edited_scene()->get_node(p_state["previewing"]);
@@ -2395,6 +2415,7 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed
view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_ENVIRONMENT), true);
view_menu->get_popup()->add_separator();
view_menu->get_popup()->add_check_shortcut(ED_SHORTCUT("spatial_editor/view_audio_listener", TTR("Audio Listener")), VIEW_AUDIO_LISTENER);
+ view_menu->get_popup()->add_check_shortcut(ED_SHORTCUT("spatial_editor/view_audio_doppler", TTR("Doppler Enable")), VIEW_AUDIO_DOPPLER);
view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_GIZMOS), true);
view_menu->get_popup()->add_separator();
@@ -2403,6 +2424,14 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed
view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/align_selection_with_view"), VIEW_ALIGN_SELECTION_WITH_VIEW);
view_menu->get_popup()->connect("id_pressed", this, "_menu_option");
+ ED_SHORTCUT("spatial_editor/freelook_left", TTR("Freelook Left"), KEY_A);
+ ED_SHORTCUT("spatial_editor/freelook_right", TTR("Freelook Right"), KEY_D);
+ ED_SHORTCUT("spatial_editor/freelook_forward", TTR("Freelook Forward"), KEY_W);
+ ED_SHORTCUT("spatial_editor/freelook_backwards", TTR("Freelook Backwards"), KEY_S);
+ ED_SHORTCUT("spatial_editor/freelook_up", TTR("Freelook Up"), KEY_Q);
+ ED_SHORTCUT("spatial_editor/freelook_down", TTR("Freelook Down"), KEY_E);
+ ED_SHORTCUT("spatial_editor/freelook_speed_modifier", TTR("Freelook Speed Modifier"), KEY_SHIFT);
+
preview_camera = memnew(Button);
preview_camera->set_toggle_mode(true);
preview_camera->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_END, 90);
@@ -3113,7 +3142,7 @@ void SpatialEditor::_menu_item_pressed(int p_option) {
xform_scale[i]->set_text("1");
}
- xform_dialog->popup_centered(Size2(200, 200));
+ xform_dialog->popup_centered(Size2(320, 240) * EDSCALE);
} break;
case MENU_VIEW_USE_1_VIEWPORT: {
@@ -3935,55 +3964,59 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
xform_dialog = memnew(ConfirmationDialog);
xform_dialog->set_title(TTR("Transform Change"));
add_child(xform_dialog);
+
+ VBoxContainer *xform_vbc = memnew(VBoxContainer);
+ xform_dialog->add_child(xform_vbc);
+
Label *l = memnew(Label);
l->set_text(TTR("Translate:"));
- l->set_position(Point2(5, 5));
- xform_dialog->add_child(l);
+ xform_vbc->add_child(l);
+
+ HBoxContainer *xform_hbc = memnew(HBoxContainer);
+ xform_vbc->add_child(xform_hbc);
for (int i = 0; i < 3; i++) {
xform_translate[i] = memnew(LineEdit);
- xform_translate[i]->set_position(Point2(15 + i * 60, 22));
- xform_translate[i]->set_size(Size2(50, 12));
- xform_dialog->add_child(xform_translate[i]);
+ xform_translate[i]->set_h_size_flags(SIZE_EXPAND_FILL);
+ xform_hbc->add_child(xform_translate[i]);
}
l = memnew(Label);
l->set_text(TTR("Rotate (deg.):"));
- l->set_position(Point2(5, 45));
- xform_dialog->add_child(l);
+ xform_vbc->add_child(l);
+
+ xform_hbc = memnew(HBoxContainer);
+ xform_vbc->add_child(xform_hbc);
for (int i = 0; i < 3; i++) {
xform_rotate[i] = memnew(LineEdit);
- xform_rotate[i]->set_position(Point2(15 + i * 60, 62));
- xform_rotate[i]->set_size(Size2(50, 22));
- xform_dialog->add_child(xform_rotate[i]);
+ xform_rotate[i]->set_h_size_flags(SIZE_EXPAND_FILL);
+ xform_hbc->add_child(xform_rotate[i]);
}
l = memnew(Label);
l->set_text(TTR("Scale (ratio):"));
- l->set_position(Point2(5, 85));
- xform_dialog->add_child(l);
+ xform_vbc->add_child(l);
+
+ xform_hbc = memnew(HBoxContainer);
+ xform_vbc->add_child(xform_hbc);
for (int i = 0; i < 3; i++) {
xform_scale[i] = memnew(LineEdit);
- xform_scale[i]->set_position(Point2(15 + i * 60, 102));
- xform_scale[i]->set_size(Size2(50, 22));
- xform_dialog->add_child(xform_scale[i]);
+ xform_scale[i]->set_h_size_flags(SIZE_EXPAND_FILL);
+ xform_hbc->add_child(xform_scale[i]);
}
l = memnew(Label);
l->set_text(TTR("Transform Type"));
- l->set_position(Point2(5, 125));
- xform_dialog->add_child(l);
+ xform_vbc->add_child(l);
xform_type = memnew(OptionButton);
- xform_type->set_anchor(MARGIN_RIGHT, ANCHOR_END);
- xform_type->set_begin(Point2(15, 142));
- xform_type->set_end(Point2(15, 75));
+ xform_type->set_h_size_flags(SIZE_EXPAND_FILL);
xform_type->add_item(TTR("Pre"));
xform_type->add_item(TTR("Post"));
- xform_dialog->add_child(xform_type);
+ xform_vbc->add_child(xform_type);
xform_dialog->connect("confirmed", this, "_xform_dialog_action");
diff --git a/editor/plugins/spatial_editor_plugin.h b/editor/plugins/spatial_editor_plugin.h
index 6b05a8b370..9b626054c0 100644
--- a/editor/plugins/spatial_editor_plugin.h
+++ b/editor/plugins/spatial_editor_plugin.h
@@ -83,6 +83,7 @@ class SpatialEditorViewport : public Control {
VIEW_ENVIRONMENT,
VIEW_ORTHOGONAL,
VIEW_AUDIO_LISTENER,
+ VIEW_AUDIO_DOPPLER,
VIEW_GIZMOS,
VIEW_INFORMATION,
VIEW_DISPLAY_NORMAL,
diff --git a/editor/plugins/sprite_frames_editor_plugin.cpp b/editor/plugins/sprite_frames_editor_plugin.cpp
index d06c065f4f..6a010062f2 100644
--- a/editor/plugins/sprite_frames_editor_plugin.cpp
+++ b/editor/plugins/sprite_frames_editor_plugin.cpp
@@ -30,8 +30,8 @@
#include "sprite_frames_editor_plugin.h"
#include "editor/editor_settings.h"
-#include "global_config.h"
#include "io/resource_loader.h"
+#include "project_settings.h"
#include "scene/3d/sprite_3d.h"
void SpriteFramesEditor::_gui_input(Ref<InputEvent> p_event) {
diff --git a/editor/plugins/texture_editor_plugin.cpp b/editor/plugins/texture_editor_plugin.cpp
index df71ea99c6..57c27a8a7e 100644
--- a/editor/plugins/texture_editor_plugin.cpp
+++ b/editor/plugins/texture_editor_plugin.cpp
@@ -30,8 +30,8 @@
#include "texture_editor_plugin.h"
#include "editor/editor_settings.h"
-#include "global_config.h"
#include "io/resource_loader.h"
+#include "project_settings.h"
void TextureEditor::_gui_input(Ref<InputEvent> p_event) {
}
diff --git a/editor/plugins/theme_editor_plugin.cpp b/editor/plugins/theme_editor_plugin.cpp
index a83ea70508..f5bb9d4a35 100644
--- a/editor/plugins/theme_editor_plugin.cpp
+++ b/editor/plugins/theme_editor_plugin.cpp
@@ -493,11 +493,10 @@ void ThemeEditor::_theme_menu_cbk(int p_option) {
Ref<Theme> base_theme;
- type_select->show();
- type_select_label->show();
name_select_label->show();
- name_edit->show();
- name_menu->show();
+ name_hbc->show();
+ type_select_label->show();
+ type_select->show();
if (p_option == POPUP_ADD) { //add
@@ -515,11 +514,10 @@ void ThemeEditor::_theme_menu_cbk(int p_option) {
base_theme = Theme::get_default();
- type_select->hide();
name_select_label->hide();
+ name_hbc->hide();
type_select_label->hide();
- name_edit->hide();
- name_menu->hide();
+ type_select->hide();
} else if (p_option == POPUP_REMOVE) {
@@ -537,11 +535,10 @@ void ThemeEditor::_theme_menu_cbk(int p_option) {
base_theme = Theme::get_default();
- type_select->hide();
name_select_label->hide();
+ name_hbc->hide();
type_select_label->hide();
- name_edit->hide();
- name_menu->hide();
+ type_select->hide();
}
popup_mode = p_option;
@@ -832,48 +829,46 @@ ThemeEditor::ThemeEditor() {
add_del_dialog->hide();
add_child(add_del_dialog);
+ VBoxContainer *dialog_vbc = memnew(VBoxContainer);
+ add_del_dialog->add_child(dialog_vbc);
+
Label *l = memnew(Label);
- l->set_position(Point2(5, 5) * EDSCALE);
l->set_text(TTR("Type:"));
- add_del_dialog->add_child(l);
- dtype_select_label = l;
+ dialog_vbc->add_child(l);
+
+ type_hbc = memnew(HBoxContainer);
+ dialog_vbc->add_child(type_hbc);
type_edit = memnew(LineEdit);
- type_edit->set_position(Point2(5, 25) * EDSCALE);
- type_edit->set_size(Point2(150, 5) * EDSCALE);
- add_del_dialog->add_child(type_edit);
+ type_edit->set_h_size_flags(SIZE_EXPAND_FILL);
+ type_hbc->add_child(type_edit);
type_menu = memnew(MenuButton);
- type_menu->set_position(Point2(160, 25) * EDSCALE);
- type_menu->set_size(Point2(30, 5) * EDSCALE);
type_menu->set_text("..");
- add_del_dialog->add_child(type_menu);
+ type_hbc->add_child(type_menu);
type_menu->get_popup()->connect("id_pressed", this, "_type_menu_cbk");
l = memnew(Label);
- l->set_position(Point2(200, 5) * EDSCALE);
l->set_text(TTR("Name:"));
- add_del_dialog->add_child(l);
+ dialog_vbc->add_child(l);
name_select_label = l;
+ name_hbc = memnew(HBoxContainer);
+ dialog_vbc->add_child(name_hbc);
+
name_edit = memnew(LineEdit);
- name_edit->set_position(Point2(200, 25) * EDSCALE);
- name_edit->set_size(Point2(150, 5) * EDSCALE);
- add_del_dialog->add_child(name_edit);
+ name_edit->set_h_size_flags(SIZE_EXPAND_FILL);
+ name_hbc->add_child(name_edit);
name_menu = memnew(MenuButton);
- name_menu->set_position(Point2(360, 25) * EDSCALE);
- name_menu->set_size(Point2(30, 5) * EDSCALE);
name_menu->set_text("..");
-
- add_del_dialog->add_child(name_menu);
+ name_hbc->add_child(name_menu);
name_menu->get_popup()->connect("about_to_show", this, "_name_menu_about_to_show");
name_menu->get_popup()->connect("id_pressed", this, "_name_menu_cbk");
type_select_label = memnew(Label);
- type_select_label->set_position(Point2(400, 5) * EDSCALE);
type_select_label->set_text(TTR("Data Type:"));
- add_del_dialog->add_child(type_select_label);
+ dialog_vbc->add_child(type_select_label);
type_select = memnew(OptionButton);
type_select->add_item(TTR("Icon"));
@@ -881,10 +876,8 @@ ThemeEditor::ThemeEditor() {
type_select->add_item(TTR("Font"));
type_select->add_item(TTR("Color"));
type_select->add_item(TTR("Constant"));
- type_select->set_position(Point2(400, 25) * EDSCALE);
- type_select->set_size(Point2(80, 5) * EDSCALE);
- add_del_dialog->add_child(type_select);
+ dialog_vbc->add_child(type_select);
add_del_dialog->get_ok()->connect("pressed", this, "_dialog_cbk");
diff --git a/editor/plugins/theme_editor_plugin.h b/editor/plugins/theme_editor_plugin.h
index 6db01c6246..a75b83e76a 100644
--- a/editor/plugins/theme_editor_plugin.h
+++ b/editor/plugins/theme_editor_plugin.h
@@ -54,14 +54,15 @@ class ThemeEditor : public Control {
MenuButton *theme_menu;
ConfirmationDialog *add_del_dialog;
+ HBoxContainer *type_hbc;
MenuButton *type_menu;
LineEdit *type_edit;
+ HBoxContainer *name_hbc;
MenuButton *name_menu;
LineEdit *name_edit;
OptionButton *type_select;
Label *type_select_label;
Label *name_select_label;
- Label *dtype_select_label;
enum PopupMode {
POPUP_ADD,
diff --git a/editor/plugins/tile_set_editor_plugin.cpp b/editor/plugins/tile_set_editor_plugin.cpp
index 70b6257bb2..3563f70d0b 100644
--- a/editor/plugins/tile_set_editor_plugin.cpp
+++ b/editor/plugins/tile_set_editor_plugin.cpp
@@ -90,9 +90,10 @@ void TileSetEditor::_import_node(Node *p_node, Ref<TileSet> p_library) {
phys_offset += -s / 2;
}
- Vector<Ref<Shape2D> > collisions;
+ Vector<TileSet::ShapeData> collisions;
Ref<NavigationPolygon> nav_poly;
Ref<OccluderPolygon2D> occluder;
+ bool found_collisions = false;
for (int j = 0; j < mi->get_child_count(); j++) {
@@ -106,24 +107,38 @@ void TileSetEditor::_import_node(Node *p_node, Ref<TileSet> p_library) {
if (!child2->cast_to<StaticBody2D>())
continue;
+
+ found_collisions = true;
+
StaticBody2D *sb = child2->cast_to<StaticBody2D>();
List<uint32_t> shapes;
sb->get_shape_owners(&shapes);
for (List<uint32_t>::Element *E = shapes.front(); E; E = E->next()) {
+ if (sb->is_shape_owner_disabled(E->get())) continue;
- Vector2 shape_offset = sb->shape_owner_get_transform(E->get()).get_origin();
+ Transform2D shape_transform = sb->shape_owner_get_transform(E->get());
bool one_way = sb->is_shape_owner_one_way_collision_enabled(E->get());
+ shape_transform.set_origin(shape_transform.get_origin() - phys_offset);
+
for (int k = 0; k < sb->shape_owner_get_shape_count(E->get()); k++) {
- Ref<Shape> shape = sb->shape_owner_get_shape(E->get(), k);
- p_library->tile_add_shape(id, shape, shape_offset, one_way);
+ Ref<Shape2D> shape = sb->shape_owner_get_shape(E->get(), k);
+ TileSet::ShapeData shape_data;
+ shape_data.shape = shape;
+ shape_data.shape_transform = shape_transform;
+ shape_data.one_way_collision = one_way;
+ collisions.push_back(shape_data);
}
}
}
+ if (found_collisions) {
+ p_library->tile_set_shapes(id, collisions);
+ }
+
p_library->tile_set_texture_offset(id, mi->get_offset());
p_library->tile_set_navigation_polygon(id, nav_poly);
p_library->tile_set_light_occluder(id, occluder);
diff --git a/editor/project_export.cpp b/editor/project_export.cpp
index 355f8ba22e..b9694dffcb 100644
--- a/editor/project_export.cpp
+++ b/editor/project_export.cpp
@@ -32,7 +32,6 @@
#include "editor_data.h"
#include "editor_node.h"
#include "editor_settings.h"
-#include "global_config.h"
#include "io/image_loader.h"
#include "io/resource_loader.h"
#include "io/resource_saver.h"
@@ -40,6 +39,7 @@
#include "os/dir_access.h"
#include "os/file_access.h"
#include "os/os.h"
+#include "project_settings.h"
#include "scene/gui/box_container.h"
#include "scene/gui/margin_container.h"
#include "scene/gui/scroll_container.h"
@@ -51,6 +51,7 @@ void ProjectExportDialog::_notification(int p_what) {
case NOTIFICATION_READY: {
delete_preset->set_icon(get_icon("Del", "EditorIcons"));
connect("confirmed", this, "_export_pck_zip");
+ custom_feature_display->get_parent_control()->add_style_override("panel", get_stylebox("bg", "Tree"));
} break;
case NOTIFICATION_POPUP_HIDE: {
EditorSettings::get_singleton()->set("interface/dialogs/export_bounds", get_rect());
@@ -240,9 +241,62 @@ void ProjectExportDialog::_edit_preset(int p_index) {
export_button->set_disabled(false);
}
+ custom_features->set_text(current->get_custom_features());
+ _update_feature_list();
+
updating = false;
}
+void ProjectExportDialog::_update_feature_list() {
+
+ Ref<EditorExportPreset> current = EditorExport::get_singleton()->get_export_preset(presets->get_current());
+ ERR_FAIL_COND(current.is_null());
+
+ Set<String> fset;
+ List<String> features;
+
+ current->get_platform()->get_platform_features(&features);
+ current->get_platform()->get_preset_features(current, &features);
+
+ String custom = current->get_custom_features();
+ Vector<String> custom_list = custom.split(",");
+ for (int i = 0; i < custom_list.size(); i++) {
+ String f = custom_list[i].strip_edges();
+ if (f != String()) {
+ features.push_back(f);
+ }
+ }
+
+ for (List<String>::Element *E = features.front(); E; E = E->next()) {
+ fset.insert(E->get());
+ }
+
+ custom_feature_display->clear();
+ for (Set<String>::Element *E = fset.front(); E; E = E->next()) {
+ String f = E->get();
+ if (E->next()) {
+ f += ", ";
+ }
+ custom_feature_display->add_text(f);
+ }
+}
+
+void ProjectExportDialog::_custom_features_changed(const String &p_text) {
+
+ if (updating)
+ return;
+
+ Ref<EditorExportPreset> current = EditorExport::get_singleton()->get_export_preset(presets->get_current());
+ ERR_FAIL_COND(current.is_null());
+
+ current->set_custom_features(p_text);
+ _update_feature_list();
+}
+
+void ProjectExportDialog::_tab_changed(int) {
+ _update_feature_list();
+}
+
void ProjectExportDialog::_patch_button_pressed(Object *p_item, int p_column, int p_id) {
TreeItem *ti = (TreeItem *)p_item;
@@ -294,10 +348,10 @@ void ProjectExportDialog::_patch_selected(const String &p_path) {
if (patch_index >= patches.size()) {
- current->add_patch(GlobalConfig::get_singleton()->get_resource_path().path_to(p_path) + "*");
+ current->add_patch(ProjectSettings::get_singleton()->get_resource_path().path_to(p_path) + "*");
} else {
String enabled = patches[patch_index].ends_with("*") ? String("*") : String();
- current->set_patch(patch_index, GlobalConfig::get_singleton()->get_resource_path().path_to(p_path) + enabled);
+ current->set_patch(patch_index, ProjectSettings::get_singleton()->get_resource_path().path_to(p_path) + enabled);
}
_edit_preset(presets->get_current());
@@ -705,6 +759,8 @@ void ProjectExportDialog::_bind_methods() {
ClassDB::bind_method("_open_export_template_manager", &ProjectExportDialog::_open_export_template_manager);
ClassDB::bind_method("_export_project", &ProjectExportDialog::_export_project);
ClassDB::bind_method("_export_project_to_path", &ProjectExportDialog::_export_project_to_path);
+ ClassDB::bind_method("_custom_features_changed", &ProjectExportDialog::_custom_features_changed);
+ ClassDB::bind_method("_tab_changed", &ProjectExportDialog::_tab_changed);
}
ProjectExportDialog::ProjectExportDialog() {
@@ -763,7 +819,7 @@ ProjectExportDialog::ProjectExportDialog() {
parameters->set_name(TTR("Options"));
parameters->hide_top_label();
parameters->set_v_size_flags(SIZE_EXPAND_FILL);
- parameters->set_hide_script(true);
+
parameters->connect("property_edited", this, "_update_parameters");
VBoxContainer *resources_vb = memnew(VBoxContainer);
@@ -828,6 +884,21 @@ ProjectExportDialog::ProjectExportDialog() {
patch_erase->connect("confirmed", this, "_patch_deleted");
add_child(patch_erase);
+ VBoxContainer *feature_vb = memnew(VBoxContainer);
+ feature_vb->set_name(TTR("Features"));
+ custom_features = memnew(LineEdit);
+ custom_features->connect("text_changed", this, "_custom_features_changed");
+ feature_vb->add_margin_child(TTR("Custom (comma-separated):"), custom_features);
+ Panel *features_panel = memnew(Panel);
+ custom_feature_display = memnew(RichTextLabel);
+ features_panel->add_child(custom_feature_display);
+ custom_feature_display->set_area_as_parent_rect(10 * EDSCALE);
+ custom_feature_display->set_v_size_flags(SIZE_EXPAND_FILL);
+ feature_vb->add_margin_child(TTR("Feature List:"), features_panel, true);
+ sections->add_child(feature_vb);
+
+ sections->connect("tab_changed", this, "_tab_changed");
+
//disable by default
name->set_editable(false);
runnable->set_disabled(true);
diff --git a/editor/project_export.h b/editor/project_export.h
index a3bbfc52ff..29c24005e0 100644
--- a/editor/project_export.h
+++ b/editor/project_export.h
@@ -40,6 +40,7 @@
#include "scene/gui/label.h"
#include "scene/gui/link_button.h"
#include "scene/gui/option_button.h"
+#include "scene/gui/rich_text_label.h"
#include "scene/gui/tab_container.h"
#include "scene/gui/tree.h"
#include "scene/main/timer.h"
@@ -91,6 +92,9 @@ private:
Button *export_button;
+ LineEdit *custom_features;
+ RichTextLabel *custom_feature_display;
+
Label *export_error;
HBoxContainer *export_templates_error;
@@ -132,6 +136,11 @@ private:
void _export_project();
void _export_project_to_path(const String &p_path);
+ void _update_feature_list();
+ void _custom_features_changed(const String &p_text);
+
+ void _tab_changed(int);
+
protected:
void _notification(int p_what);
static void _bind_methods();
diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp
index a3d3d42110..82f17b80d5 100644
--- a/editor/project_manager.cpp
+++ b/editor/project_manager.cpp
@@ -49,6 +49,7 @@
#include "scene/gui/texture_rect.h"
#include "scene/gui/tool_button.h"
#include "version.h"
+#include "version_hash.gen.h"
class NewProjectDialog : public ConfirmationDialog {
@@ -186,30 +187,17 @@ private:
} else {
if (mode == MODE_NEW) {
- FileAccess *f = FileAccess::open(dir.plus_file("/project.godot"), FileAccess::WRITE);
- if (!f) {
+ ProjectSettings::CustomMap initial_settings;
+ initial_settings["application/config/name"] = project_name->get_text();
+ initial_settings["application/config/icon"] = "res://icon.png";
+ initial_settings["rendering/environment/default_environment"] = "res://default_env.tres";
+
+ if (ProjectSettings::get_singleton()->save_custom(dir.plus_file("/project.godot"), initial_settings, Vector<String>(), false)) {
error->set_text(TTR("Couldn't create project.godot in project path."));
} else {
-
- f->store_line("; Engine configuration file.");
- f->store_line("; It's best edited using the editor UI and not directly,");
- f->store_line("; since the parameters that go here are not all obvious.");
- f->store_line("; ");
- f->store_line("; Format: ");
- f->store_line("; [section] ; section goes between []");
- f->store_line("; param=value ; assign values to parameters");
- f->store_line("\n");
- f->store_line("[application]");
- f->store_line("\n");
- f->store_line("name=\"" + project_name->get_text() + "\"");
- f->store_line("icon=\"res://icon.png\"");
- f->store_line("[rendering]");
- f->store_line("viewport/default_environment=\"res://default_env.tres\"");
- memdelete(f);
-
ResourceSaver::save(dir.plus_file("/icon.png"), get_icon("DefaultProjectIcon", "EditorIcons"));
- f = FileAccess::open(dir.plus_file("/default_env.tres"), FileAccess::WRITE);
+ FileAccess *f = FileAccess::open(dir.plus_file("/default_env.tres"), FileAccess::WRITE);
if (!f) {
error->set_text(TTR("Couldn't create project.godot in project path."));
} else {
@@ -810,16 +798,16 @@ void ProjectManager::_load_recent_projects() {
String project_name = TTR("Unnamed Project");
- if (cf->has_section_key("application", "name")) {
- project_name = static_cast<String>(cf->get_value("application", "name")).xml_unescape();
+ if (cf->has_section_key("application", "config/name")) {
+ project_name = static_cast<String>(cf->get_value("application", "config/name")).xml_unescape();
}
if (filter_option == ProjectListFilter::FILTER_NAME && search_term != "" && project_name.findn(search_term) == -1)
continue;
Ref<Texture> icon;
- if (cf->has_section_key("application", "icon")) {
- String appicon = cf->get_value("application", "icon");
+ if (cf->has_section_key("application", "config/icon")) {
+ String appicon = cf->get_value("application", "config/icon");
if (appicon != "") {
Ref<Image> img;
img.instance();
@@ -839,8 +827,8 @@ void ProjectManager::_load_recent_projects() {
}
String main_scene;
- if (cf->has_section_key("application", "main_scene")) {
- main_scene = cf->get_value("application", "main_scene");
+ if (cf->has_section_key("application", "run/main_scene")) {
+ main_scene = cf->get_value("application", "run/main_scene");
}
selected_list_copy.erase(project);
@@ -1244,7 +1232,10 @@ ProjectManager::ProjectManager() {
top_hb->add_child(ccl);
top_hb->add_spacer();
l = memnew(Label);
- l->set_text("v" VERSION_MKSTRING);
+ String hash = String(VERSION_HASH);
+ if (hash.length() != 0)
+ hash = "." + hash.left(7);
+ l->set_text("v" VERSION_MKSTRING "" + hash);
//l->add_font_override("font",get_font("bold","Fonts"));
l->set_align(Label::ALIGN_CENTER);
top_hb->add_child(l);
diff --git a/editor/project_settings.cpp b/editor/project_settings_editor.cpp
index 4000b3e05c..6d23e874df 100644
--- a/editor/project_settings.cpp
+++ b/editor/project_settings_editor.cpp
@@ -27,17 +27,17 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "project_settings.h"
+#include "project_settings_editor.h"
#include "editor_node.h"
-#include "global_config.h"
#include "global_constants.h"
#include "os/keyboard.h"
+#include "project_settings.h"
#include "scene/gui/margin_container.h"
#include "scene/gui/tab_container.h"
#include "translation.h"
-ProjectSettings *ProjectSettings::singleton = NULL;
+ProjectSettingsEditor *ProjectSettingsEditor::singleton = NULL;
static const char *_button_names[JOY_BUTTON_MAX] = {
"PS Cross, XBox A, Nintendo B",
@@ -72,13 +72,13 @@ static const char *_axis_names[JOY_AXIS_MAX * 2] = {
"", " (R2)"
};
-void ProjectSettings::_notification(int p_what) {
+void ProjectSettingsEditor::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
- globals_editor->edit(GlobalConfig::get_singleton());
+ globals_editor->edit(ProjectSettings::get_singleton());
- search_button->set_icon(get_icon("Zoom", "EditorIcons"));
+ search_button->set_icon(get_icon("Search", "EditorIcons"));
clear_button->set_icon(get_icon("Close", "EditorIcons"));
translation_list->connect("button_pressed", this, "_translation_delete");
@@ -112,7 +112,7 @@ void ProjectSettings::_notification(int p_what) {
}
}
-void ProjectSettings::_action_selected() {
+void ProjectSettingsEditor::_action_selected() {
TreeItem *ti = input_editor->get_selected();
if (!ti || !ti->is_editable(0))
@@ -122,7 +122,7 @@ void ProjectSettings::_action_selected() {
edit_idx = -1;
}
-void ProjectSettings::_action_edited() {
+void ProjectSettingsEditor::_action_edited() {
TreeItem *ti = input_editor->get_selected();
if (!ti)
@@ -146,7 +146,7 @@ void ProjectSettings::_action_edited() {
String action_prop = "input/" + new_name;
- if (GlobalConfig::get_singleton()->has(action_prop)) {
+ if (ProjectSettings::get_singleton()->has(action_prop)) {
ti->set_text(0, old_name);
add_at = "input/" + old_name;
@@ -156,17 +156,17 @@ void ProjectSettings::_action_edited() {
return;
}
- int order = GlobalConfig::get_singleton()->get_order(add_at);
- Array va = GlobalConfig::get_singleton()->get(add_at);
+ int order = ProjectSettings::get_singleton()->get_order(add_at);
+ Array va = ProjectSettings::get_singleton()->get(add_at);
setting = true;
undo_redo->create_action(TTR("Rename Input Action Event"));
- undo_redo->add_do_method(GlobalConfig::get_singleton(), "clear", add_at);
- undo_redo->add_do_method(GlobalConfig::get_singleton(), "set", action_prop, va);
- undo_redo->add_do_method(GlobalConfig::get_singleton(), "set_order", action_prop, order);
- undo_redo->add_undo_method(GlobalConfig::get_singleton(), "clear", action_prop);
- undo_redo->add_undo_method(GlobalConfig::get_singleton(), "set", add_at, va);
- undo_redo->add_undo_method(GlobalConfig::get_singleton(), "set_order", add_at, order);
+ undo_redo->add_do_method(ProjectSettings::get_singleton(), "clear", add_at);
+ undo_redo->add_do_method(ProjectSettings::get_singleton(), "set", action_prop, va);
+ undo_redo->add_do_method(ProjectSettings::get_singleton(), "set_order", action_prop, order);
+ undo_redo->add_undo_method(ProjectSettings::get_singleton(), "clear", action_prop);
+ undo_redo->add_undo_method(ProjectSettings::get_singleton(), "set", add_at, va);
+ undo_redo->add_undo_method(ProjectSettings::get_singleton(), "set_order", add_at, order);
undo_redo->add_do_method(this, "_update_actions");
undo_redo->add_undo_method(this, "_update_actions");
undo_redo->add_do_method(this, "_settings_changed");
@@ -177,12 +177,12 @@ void ProjectSettings::_action_edited() {
add_at = action_prop;
}
-void ProjectSettings::_device_input_add() {
+void ProjectSettingsEditor::_device_input_add() {
Ref<InputEvent> ie;
String name = add_at;
int idx = edit_idx;
- Variant old_val = GlobalConfig::get_singleton()->get(name);
+ Variant old_val = ProjectSettings::get_singleton()->get(name);
Array arr = old_val;
// ie.device = device_id->get_value();
// ie.type = add_type;
@@ -260,8 +260,8 @@ void ProjectSettings::_device_input_add() {
}
undo_redo->create_action(TTR("Add Input Action Event"));
- undo_redo->add_do_method(GlobalConfig::get_singleton(), "set", name, arr);
- undo_redo->add_undo_method(GlobalConfig::get_singleton(), "set", name, old_val);
+ undo_redo->add_do_method(ProjectSettings::get_singleton(), "set", name, arr);
+ undo_redo->add_undo_method(ProjectSettings::get_singleton(), "set", name, old_val);
undo_redo->add_do_method(this, "_update_actions");
undo_redo->add_undo_method(this, "_update_actions");
undo_redo->add_do_method(this, "_settings_changed");
@@ -271,7 +271,7 @@ void ProjectSettings::_device_input_add() {
_show_last_added(ie, name);
}
-void ProjectSettings::_press_a_key_confirm() {
+void ProjectSettingsEditor::_press_a_key_confirm() {
if (last_wait_for_key.is_null())
return;
@@ -287,7 +287,7 @@ void ProjectSettings::_press_a_key_confirm() {
String name = add_at;
int idx = edit_idx;
- Variant old_val = GlobalConfig::get_singleton()->get(name);
+ Variant old_val = ProjectSettings::get_singleton()->get(name);
Array arr = old_val;
for (int i = 0; i < arr.size(); i++) {
@@ -307,8 +307,8 @@ void ProjectSettings::_press_a_key_confirm() {
}
undo_redo->create_action(TTR("Add Input Action Event"));
- undo_redo->add_do_method(GlobalConfig::get_singleton(), "set", name, arr);
- undo_redo->add_undo_method(GlobalConfig::get_singleton(), "set", name, old_val);
+ undo_redo->add_do_method(ProjectSettings::get_singleton(), "set", name, arr);
+ undo_redo->add_undo_method(ProjectSettings::get_singleton(), "set", name, old_val);
undo_redo->add_do_method(this, "_update_actions");
undo_redo->add_undo_method(this, "_update_actions");
undo_redo->add_do_method(this, "_settings_changed");
@@ -318,7 +318,7 @@ void ProjectSettings::_press_a_key_confirm() {
_show_last_added(ie, name);
}
-void ProjectSettings::_show_last_added(const Ref<InputEvent> &p_event, const String &p_name) {
+void ProjectSettingsEditor::_show_last_added(const Ref<InputEvent> &p_event, const String &p_name) {
TreeItem *r = input_editor->get_root();
String name = p_name;
@@ -351,7 +351,7 @@ void ProjectSettings::_show_last_added(const Ref<InputEvent> &p_event, const Str
if (found) input_editor->ensure_cursor_is_visible();
}
-void ProjectSettings::_wait_for_key(const Ref<InputEvent> &p_event) {
+void ProjectSettingsEditor::_wait_for_key(const Ref<InputEvent> &p_event) {
Ref<InputEventKey> k = p_event;
@@ -373,7 +373,7 @@ void ProjectSettings::_wait_for_key(const Ref<InputEvent> &p_event) {
}
}
-void ProjectSettings::_add_item(int p_item, Ref<InputEvent> p_exiting_event) {
+void ProjectSettingsEditor::_add_item(int p_item, Ref<InputEvent> p_exiting_event) {
add_type = InputType(p_item);
@@ -458,7 +458,7 @@ void ProjectSettings::_add_item(int p_item, Ref<InputEvent> p_exiting_event) {
}
}
-void ProjectSettings::_edit_item(Ref<InputEvent> p_exiting_event) {
+void ProjectSettingsEditor::_edit_item(Ref<InputEvent> p_exiting_event) {
InputType ie_type;
@@ -480,7 +480,7 @@ void ProjectSettings::_edit_item(Ref<InputEvent> p_exiting_event) {
_add_item(ie_type, p_exiting_event);
}
-void ProjectSettings::_action_activated() {
+void ProjectSettingsEditor::_action_activated() {
TreeItem *ti = input_editor->get_selected();
@@ -489,7 +489,7 @@ void ProjectSettings::_action_activated() {
String name = "input/" + ti->get_parent()->get_text(0);
int idx = ti->get_metadata(0);
- Array va = GlobalConfig::get_singleton()->get(name);
+ Array va = ProjectSettings::get_singleton()->get(name);
ERR_FAIL_INDEX(idx, va.size());
@@ -503,7 +503,7 @@ void ProjectSettings::_action_activated() {
_edit_item(ie);
}
-void ProjectSettings::_action_button_pressed(Object *p_obj, int p_column, int p_id) {
+void ProjectSettingsEditor::_action_button_pressed(Object *p_obj, int p_column, int p_id) {
TreeItem *ti = p_obj->cast_to<TreeItem>();
@@ -528,13 +528,13 @@ void ProjectSettings::_action_button_pressed(Object *p_obj, int p_column, int p_
//remove main thing
String name = "input/" + ti->get_text(0);
- Variant old_val = GlobalConfig::get_singleton()->get(name);
- int order = GlobalConfig::get_singleton()->get_order(name);
+ Variant old_val = ProjectSettings::get_singleton()->get(name);
+ int order = ProjectSettings::get_singleton()->get_order(name);
undo_redo->create_action(TTR("Add Input Action"));
- undo_redo->add_do_method(GlobalConfig::get_singleton(), "clear", name);
- undo_redo->add_undo_method(GlobalConfig::get_singleton(), "set", name, old_val);
- undo_redo->add_undo_method(GlobalConfig::get_singleton(), "set_order", name, order);
+ undo_redo->add_do_method(ProjectSettings::get_singleton(), "clear", name);
+ undo_redo->add_undo_method(ProjectSettings::get_singleton(), "set", name, old_val);
+ undo_redo->add_undo_method(ProjectSettings::get_singleton(), "set_order", name, order);
undo_redo->add_do_method(this, "_update_actions");
undo_redo->add_undo_method(this, "_update_actions");
undo_redo->add_do_method(this, "_settings_changed");
@@ -544,7 +544,7 @@ void ProjectSettings::_action_button_pressed(Object *p_obj, int p_column, int p_
} else {
//remove action
String name = "input/" + ti->get_parent()->get_text(0);
- Variant old_val = GlobalConfig::get_singleton()->get(name);
+ Variant old_val = ProjectSettings::get_singleton()->get(name);
int idx = ti->get_metadata(0);
Array va = old_val;
@@ -559,8 +559,8 @@ void ProjectSettings::_action_button_pressed(Object *p_obj, int p_column, int p_
va.resize(va.size() - 1);
undo_redo->create_action(TTR("Erase Input Action Event"));
- undo_redo->add_do_method(GlobalConfig::get_singleton(), "set", name, va);
- undo_redo->add_undo_method(GlobalConfig::get_singleton(), "set", name, old_val);
+ undo_redo->add_do_method(ProjectSettings::get_singleton(), "set", name, va);
+ undo_redo->add_undo_method(ProjectSettings::get_singleton(), "set", name, old_val);
undo_redo->add_do_method(this, "_update_actions");
undo_redo->add_undo_method(this, "_update_actions");
undo_redo->add_do_method(this, "_settings_changed");
@@ -579,7 +579,7 @@ void ProjectSettings::_action_button_pressed(Object *p_obj, int p_column, int p_
//edit action
String name = "input/" + ti->get_parent()->get_text(0);
int idx = ti->get_metadata(0);
- Array va = GlobalConfig::get_singleton()->get(name);
+ Array va = ProjectSettings::get_singleton()->get(name);
ERR_FAIL_INDEX(idx, va.size());
@@ -596,7 +596,7 @@ void ProjectSettings::_action_button_pressed(Object *p_obj, int p_column, int p_
}
}
-void ProjectSettings::_update_actions() {
+void ProjectSettingsEditor::_update_actions() {
if (setting)
return;
@@ -606,7 +606,7 @@ void ProjectSettings::_update_actions() {
input_editor->set_hide_root(true);
List<PropertyInfo> props;
- GlobalConfig::get_singleton()->get_property_list(&props);
+ ProjectSettings::get_singleton()->get_property_list(&props);
for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) {
@@ -622,14 +622,14 @@ void ProjectSettings::_update_actions() {
//item->set_cell_mode(0,TreeItem::CELL_MODE_CHECK);
item->set_text(0, name);
item->add_button(0, get_icon("Add", "EditorIcons"), 1, false, TTR("Add Event"));
- if (!GlobalConfig::get_singleton()->get_input_presets().find(pi.name)) {
+ if (!ProjectSettings::get_singleton()->get_input_presets().find(pi.name)) {
item->add_button(0, get_icon("Remove", "EditorIcons"), 2, false, TTR("Remove"));
item->set_editable(0, true);
}
item->set_custom_bg_color(0, get_color("prop_subsection", "Editor"));
//item->set_checked(0,pi.usage&PROPERTY_USAGE_CHECKED);
- Array actions = GlobalConfig::get_singleton()->get(pi.name);
+ Array actions = ProjectSettings::get_singleton()->get(pi.name);
for (int i = 0; i < actions.size(); i++) {
@@ -706,7 +706,7 @@ void ProjectSettings::_update_actions() {
}
}
-void ProjectSettings::popup_project_settings() {
+void ProjectSettingsEditor::popup_project_settings() {
// Restore valid window bounds or pop up at default size.
if (EditorSettings::get_singleton()->has("interface/dialogs/project_settings_bounds")) {
@@ -720,7 +720,7 @@ void ProjectSettings::popup_project_settings() {
plugin_settings->update_plugins();
}
-void ProjectSettings::_item_selected() {
+void ProjectSettingsEditor::_item_selected() {
TreeItem *ti = globals_editor->get_property_editor()->get_scene_tree()->get_selected();
if (!ti)
@@ -729,15 +729,15 @@ void ProjectSettings::_item_selected() {
return;
category->set_text(globals_editor->get_current_section());
property->set_text(ti->get_text(0));
- popup_platform->set_disabled(false);
+ popup_copy_to_feature->set_disabled(false);
}
-void ProjectSettings::_item_adds(String) {
+void ProjectSettingsEditor::_item_adds(String) {
_item_add();
}
-void ProjectSettings::_item_add() {
+void ProjectSettingsEditor::_item_add() {
Variant value;
switch (type->get_selected()) {
@@ -765,12 +765,12 @@ void ProjectSettings::_item_add() {
undo_redo->create_action("Add Global Property");
- undo_redo->add_do_property(GlobalConfig::get_singleton(), name, value);
+ undo_redo->add_do_property(ProjectSettings::get_singleton(), name, value);
- if (GlobalConfig::get_singleton()->has(name)) {
- undo_redo->add_undo_property(GlobalConfig::get_singleton(), name, GlobalConfig::get_singleton()->get(name));
+ if (ProjectSettings::get_singleton()->has(name)) {
+ undo_redo->add_undo_property(ProjectSettings::get_singleton(), name, ProjectSettings::get_singleton()->get(name));
} else {
- undo_redo->add_undo_property(GlobalConfig::get_singleton(), name, Variant());
+ undo_redo->add_undo_property(ProjectSettings::get_singleton(), name, Variant());
}
undo_redo->add_do_method(globals_editor, "update_category_list");
@@ -786,20 +786,35 @@ void ProjectSettings::_item_add() {
_settings_changed();
}
-void ProjectSettings::_item_del() {
+void ProjectSettingsEditor::_item_del() {
- String catname = category->get_text().strip_edges();
- //ERR_FAIL_COND(!catname.is_valid_identifier());
- String propname = property->get_text().strip_edges();
- //ERR_FAIL_COND(!propname.is_valid_identifier());
+ String path = globals_editor->get_property_editor()->get_selected_path();
+ if (path == String()) {
+ EditorNode::get_singleton()->show_warning(TTR("Select an setting item first!"));
+ return;
+ }
- String name = catname != "" ? catname + "/" + propname : propname;
+ String property = globals_editor->get_current_section().plus_file(path);
- undo_redo->create_action("Delete Global Property");
+ if (!ProjectSettings::get_singleton()->has(property)) {
+ EditorNode::get_singleton()->show_warning(TTR("No property '" + property + "' exists."));
+ return;
+ }
- undo_redo->add_do_property(GlobalConfig::get_singleton(), name, Variant());
+ if (ProjectSettings::get_singleton()->get_order(property) < ProjectSettings::NO_BUILTIN_ORDER_BASE) {
+ EditorNode::get_singleton()->show_warning(TTR("Setting '" + property + "' is internal, and it can't be deleted."));
+ return;
+ }
- undo_redo->add_undo_property(GlobalConfig::get_singleton(), name, GlobalConfig::get_singleton()->get(name));
+ print_line("to delete.. " + property);
+ undo_redo->create_action(TTR("Delete Item"));
+
+ Variant value = ProjectSettings::get_singleton()->get(property);
+ int order = ProjectSettings::get_singleton()->get_order(property);
+
+ undo_redo->add_do_method(ProjectSettings::get_singleton(), "clear", property);
+ undo_redo->add_undo_method(ProjectSettings::get_singleton(), "set", property, value);
+ undo_redo->add_undo_method(ProjectSettings::get_singleton(), "set_order", property, order);
undo_redo->add_do_method(globals_editor, "update_category_list");
undo_redo->add_undo_method(globals_editor, "update_category_list");
@@ -808,16 +823,14 @@ void ProjectSettings::_item_del() {
undo_redo->add_undo_method(this, "_settings_changed");
undo_redo->commit_action();
-
- _settings_changed();
}
-void ProjectSettings::_action_adds(String) {
+void ProjectSettingsEditor::_action_adds(String) {
_action_add();
}
-void ProjectSettings::_action_add() {
+void ProjectSettingsEditor::_action_add() {
String action = action_name->get_text();
if (action.find("/") != -1 || action.find(":") != -1 || action == "") {
@@ -826,7 +839,7 @@ void ProjectSettings::_action_add() {
return;
}
- if (GlobalConfig::get_singleton()->has("input/" + action)) {
+ if (ProjectSettings::get_singleton()->has("input/" + action)) {
message->set_text(vformat(TTR("Action '%s' already exists!"), action));
message->popup_centered(Size2(300, 100));
return;
@@ -835,8 +848,8 @@ void ProjectSettings::_action_add() {
Array va;
String name = "input/" + action;
undo_redo->create_action(TTR("Add Input Action Event"));
- undo_redo->add_do_method(GlobalConfig::get_singleton(), "set", name, va);
- undo_redo->add_undo_method(GlobalConfig::get_singleton(), "clear", name);
+ undo_redo->add_do_method(ProjectSettings::get_singleton(), "set", name, va);
+ undo_redo->add_undo_method(ProjectSettings::get_singleton(), "clear", name);
undo_redo->add_do_method(this, "_update_actions");
undo_redo->add_undo_method(this, "_update_actions");
undo_redo->add_do_method(this, "_settings_changed");
@@ -859,66 +872,119 @@ void ProjectSettings::_action_add() {
input_editor->ensure_cursor_is_visible();
}
-void ProjectSettings::_item_checked(const String &p_item, bool p_check) {
+void ProjectSettingsEditor::_item_checked(const String &p_item, bool p_check) {
}
-void ProjectSettings::_save() {
+void ProjectSettingsEditor::_save() {
- Error err = GlobalConfig::get_singleton()->save();
+ Error err = ProjectSettings::get_singleton()->save();
message->set_text(err != OK ? TTR("Error saving settings.") : TTR("Settings saved OK."));
message->popup_centered(Size2(300, 100));
}
-void ProjectSettings::_settings_prop_edited(const String &p_name) {
+void ProjectSettingsEditor::_settings_prop_edited(const String &p_name) {
String full_item = globals_editor->get_full_item_path(p_name);
_settings_changed();
}
-void ProjectSettings::_settings_changed() {
+void ProjectSettingsEditor::_settings_changed() {
timer->start();
}
-void ProjectSettings::queue_save() {
+void ProjectSettingsEditor::queue_save() {
_settings_changed();
}
-void ProjectSettings::_copy_to_platform(int p_which) {
+void ProjectSettingsEditor::_copy_to_platform_about_to_show() {
- String catname = category->get_text();
- if (!catname.is_valid_identifier()) {
- message->set_text("Invalid Category.\nValid characters: a-z,A-Z,0-9 or _");
- message->popup_centered(Size2(300, 100));
- return;
+ Set<String> presets;
+
+ presets.insert("s3tc");
+ presets.insert("etc");
+ presets.insert("etc2");
+ presets.insert("pvrtc");
+ presets.insert("debug");
+ presets.insert("release");
+
+ for (int i = 0; i < EditorExport::get_singleton()->get_export_platform_count(); i++) {
+ List<String> p;
+ EditorExport::get_singleton()->get_export_platform(i)->get_platform_features(&p);
+ for (List<String>::Element *E = p.front(); E; E = E->next()) {
+ presets.insert(E->get());
+ }
}
- String propname = property->get_text();
- if (!propname.is_valid_identifier()) {
- message->set_text("Invalid Property.\nValid characters: a-z,A-Z,0-9 or _");
- message->popup_centered(Size2(300, 100));
+ for (int i = 0; i < EditorExport::get_singleton()->get_export_preset_count(); i++) {
+
+ List<String> p;
+ EditorExport::get_singleton()->get_export_preset(i)->get_platform()->get_preset_features(EditorExport::get_singleton()->get_export_preset(i), &p);
+ for (List<String>::Element *E = p.front(); E; E = E->next()) {
+ presets.insert(E->get());
+ }
+
+ String custom = EditorExport::get_singleton()->get_export_preset(i)->get_custom_features();
+ Vector<String> custom_list = custom.split(",");
+ for (int i = 0; i < custom_list.size(); i++) {
+ String f = custom_list[i].strip_edges();
+ if (f != String()) {
+ presets.insert(f);
+ }
+ }
+ }
+
+ popup_copy_to_feature->get_popup()->clear();
+ int id = 0;
+ for (Set<String>::Element *E = presets.front(); E; E = E->next()) {
+ popup_copy_to_feature->get_popup()->add_item(E->get(), id++);
+ }
+}
+
+void ProjectSettingsEditor::_copy_to_platform(int p_which) {
+
+ String path = globals_editor->get_property_editor()->get_selected_path();
+ if (path == String()) {
+ EditorNode::get_singleton()->show_warning(TTR("Select an setting item first!"));
return;
}
- String name = catname + "/" + propname;
- Variant value = GlobalConfig::get_singleton()->get(name);
+ String property = globals_editor->get_current_section().plus_file(path);
- catname += "." + popup_platform->get_popup()->get_item_text(p_which);
- name = catname + "/" + propname;
+ undo_redo->create_action(TTR("Override for Feature"));
- GlobalConfig::get_singleton()->set(name, value);
- globals_editor->get_property_editor()->update_tree();
+ Variant value = ProjectSettings::get_singleton()->get(property);
+ if (property.find(".") != -1) { //overwriting overwrite, keep overwrite
+ undo_redo->add_do_method(ProjectSettings::get_singleton(), "clear", property);
+ undo_redo->add_undo_method(ProjectSettings::get_singleton(), "set", property, value);
+ }
+
+ String feature = popup_copy_to_feature->get_popup()->get_item_text(p_which);
+ String new_path = property + "." + feature;
+
+ undo_redo->add_do_method(ProjectSettings::get_singleton(), "set", new_path, value);
+ if (ProjectSettings::get_singleton()->has(new_path)) {
+ undo_redo->add_undo_method(ProjectSettings::get_singleton(), "set", new_path, ProjectSettings::get_singleton()->get(new_path));
+ }
+
+ undo_redo->add_do_method(globals_editor, "update_category_list");
+ undo_redo->add_undo_method(globals_editor, "update_category_list");
+
+ undo_redo->add_do_method(this, "_settings_changed");
+ undo_redo->add_undo_method(this, "_settings_changed");
+
+ undo_redo->commit_action();
}
-void ProjectSettings::add_translation(const String &p_translation) {
+void ProjectSettingsEditor::add_translation(const String &p_translation) {
_translation_add(p_translation);
}
-void ProjectSettings::_translation_add(const String &p_path) {
+void ProjectSettingsEditor::_translation_add(const String &p_path) {
- PoolStringArray translations = GlobalConfig::get_singleton()->get("locale/translations");
+ PoolStringArray translations = ProjectSettings::get_singleton()->get("locale/translations");
for (int i = 0; i < translations.size(); i++) {
@@ -928,8 +994,8 @@ void ProjectSettings::_translation_add(const String &p_path) {
translations.push_back(p_path);
undo_redo->create_action(TTR("Add Translation"));
- undo_redo->add_do_property(GlobalConfig::get_singleton(), "locale/translations", translations);
- undo_redo->add_undo_property(GlobalConfig::get_singleton(), "locale/translations", GlobalConfig::get_singleton()->get("locale/translations"));
+ undo_redo->add_do_property(ProjectSettings::get_singleton(), "locale/translations", translations);
+ undo_redo->add_undo_property(ProjectSettings::get_singleton(), "locale/translations", ProjectSettings::get_singleton()->get("locale/translations"));
undo_redo->add_do_method(this, "_update_translations");
undo_redo->add_undo_method(this, "_update_translations");
undo_redo->add_do_method(this, "_settings_changed");
@@ -937,27 +1003,27 @@ void ProjectSettings::_translation_add(const String &p_path) {
undo_redo->commit_action();
}
-void ProjectSettings::_translation_file_open() {
+void ProjectSettingsEditor::_translation_file_open() {
translation_file_open->popup_centered_ratio();
}
-void ProjectSettings::_translation_delete(Object *p_item, int p_column, int p_button) {
+void ProjectSettingsEditor::_translation_delete(Object *p_item, int p_column, int p_button) {
TreeItem *ti = p_item->cast_to<TreeItem>();
ERR_FAIL_COND(!ti);
int idx = ti->get_metadata(0);
- PoolStringArray translations = GlobalConfig::get_singleton()->get("locale/translations");
+ PoolStringArray translations = ProjectSettings::get_singleton()->get("locale/translations");
ERR_FAIL_INDEX(idx, translations.size());
translations.remove(idx);
undo_redo->create_action(TTR("Remove Translation"));
- undo_redo->add_do_property(GlobalConfig::get_singleton(), "locale/translations", translations);
- undo_redo->add_undo_property(GlobalConfig::get_singleton(), "locale/translations", GlobalConfig::get_singleton()->get("locale/translations"));
+ undo_redo->add_do_property(ProjectSettings::get_singleton(), "locale/translations", translations);
+ undo_redo->add_undo_property(ProjectSettings::get_singleton(), "locale/translations", ProjectSettings::get_singleton()->get("locale/translations"));
undo_redo->add_do_method(this, "_update_translations");
undo_redo->add_undo_method(this, "_update_translations");
undo_redo->add_do_method(this, "_settings_changed");
@@ -965,18 +1031,18 @@ void ProjectSettings::_translation_delete(Object *p_item, int p_column, int p_bu
undo_redo->commit_action();
}
-void ProjectSettings::_translation_res_file_open() {
+void ProjectSettingsEditor::_translation_res_file_open() {
translation_res_file_open->popup_centered_ratio();
}
-void ProjectSettings::_translation_res_add(const String &p_path) {
+void ProjectSettingsEditor::_translation_res_add(const String &p_path) {
Variant prev;
Dictionary remaps;
- if (GlobalConfig::get_singleton()->has("locale/translation_remaps")) {
- remaps = GlobalConfig::get_singleton()->get("locale/translation_remaps");
+ if (ProjectSettings::get_singleton()->has("locale/translation_remaps")) {
+ remaps = ProjectSettings::get_singleton()->get("locale/translation_remaps");
prev = remaps;
}
@@ -986,8 +1052,8 @@ void ProjectSettings::_translation_res_add(const String &p_path) {
remaps[p_path] = PoolStringArray();
undo_redo->create_action(TTR("Add Remapped Path"));
- undo_redo->add_do_property(GlobalConfig::get_singleton(), "locale/translation_remaps", remaps);
- undo_redo->add_undo_property(GlobalConfig::get_singleton(), "locale/translation_remaps", prev);
+ undo_redo->add_do_property(ProjectSettings::get_singleton(), "locale/translation_remaps", remaps);
+ undo_redo->add_undo_property(ProjectSettings::get_singleton(), "locale/translation_remaps", prev);
undo_redo->add_do_method(this, "_update_translations");
undo_redo->add_undo_method(this, "_update_translations");
undo_redo->add_do_method(this, "_settings_changed");
@@ -995,15 +1061,15 @@ void ProjectSettings::_translation_res_add(const String &p_path) {
undo_redo->commit_action();
}
-void ProjectSettings::_translation_res_option_file_open() {
+void ProjectSettingsEditor::_translation_res_option_file_open() {
translation_res_option_file_open->popup_centered_ratio();
}
-void ProjectSettings::_translation_res_option_add(const String &p_path) {
+void ProjectSettingsEditor::_translation_res_option_add(const String &p_path) {
- ERR_FAIL_COND(!GlobalConfig::get_singleton()->has("locale/translation_remaps"));
+ ERR_FAIL_COND(!ProjectSettings::get_singleton()->has("locale/translation_remaps"));
- Dictionary remaps = GlobalConfig::get_singleton()->get("locale/translation_remaps");
+ Dictionary remaps = ProjectSettings::get_singleton()->get("locale/translation_remaps");
TreeItem *k = translation_remap->get_selected();
ERR_FAIL_COND(!k);
@@ -1016,8 +1082,8 @@ void ProjectSettings::_translation_res_option_add(const String &p_path) {
remaps[key] = r;
undo_redo->create_action(TTR("Resource Remap Add Remap"));
- undo_redo->add_do_property(GlobalConfig::get_singleton(), "locale/translation_remaps", remaps);
- undo_redo->add_undo_property(GlobalConfig::get_singleton(), "locale/translation_remaps", GlobalConfig::get_singleton()->get("locale/translation_remaps"));
+ undo_redo->add_do_property(ProjectSettings::get_singleton(), "locale/translation_remaps", remaps);
+ undo_redo->add_undo_property(ProjectSettings::get_singleton(), "locale/translation_remaps", ProjectSettings::get_singleton()->get("locale/translation_remaps"));
undo_redo->add_do_method(this, "_update_translations");
undo_redo->add_undo_method(this, "_update_translations");
undo_redo->add_do_method(this, "_settings_changed");
@@ -1025,7 +1091,7 @@ void ProjectSettings::_translation_res_option_add(const String &p_path) {
undo_redo->commit_action();
}
-void ProjectSettings::_translation_res_select() {
+void ProjectSettingsEditor::_translation_res_select() {
if (updating_translations)
return;
@@ -1033,15 +1099,15 @@ void ProjectSettings::_translation_res_select() {
call_deferred("_update_translations");
}
-void ProjectSettings::_translation_res_option_changed() {
+void ProjectSettingsEditor::_translation_res_option_changed() {
if (updating_translations)
return;
- if (!GlobalConfig::get_singleton()->has("locale/translation_remaps"))
+ if (!ProjectSettings::get_singleton()->has("locale/translation_remaps"))
return;
- Dictionary remaps = GlobalConfig::get_singleton()->get("locale/translation_remaps");
+ Dictionary remaps = ProjectSettings::get_singleton()->get("locale/translation_remaps");
TreeItem *k = translation_remap->get_selected();
ERR_FAIL_COND(!k);
@@ -1065,8 +1131,8 @@ void ProjectSettings::_translation_res_option_changed() {
updating_translations = true;
undo_redo->create_action(TTR("Change Resource Remap Language"));
- undo_redo->add_do_property(GlobalConfig::get_singleton(), "locale/translation_remaps", remaps);
- undo_redo->add_undo_property(GlobalConfig::get_singleton(), "locale/translation_remaps", GlobalConfig::get_singleton()->get("locale/translation_remaps"));
+ undo_redo->add_do_property(ProjectSettings::get_singleton(), "locale/translation_remaps", remaps);
+ undo_redo->add_undo_property(ProjectSettings::get_singleton(), "locale/translation_remaps", ProjectSettings::get_singleton()->get("locale/translation_remaps"));
undo_redo->add_do_method(this, "_update_translations");
undo_redo->add_undo_method(this, "_update_translations");
undo_redo->add_do_method(this, "_settings_changed");
@@ -1075,15 +1141,15 @@ void ProjectSettings::_translation_res_option_changed() {
updating_translations = false;
}
-void ProjectSettings::_translation_res_delete(Object *p_item, int p_column, int p_button) {
+void ProjectSettingsEditor::_translation_res_delete(Object *p_item, int p_column, int p_button) {
if (updating_translations)
return;
- if (!GlobalConfig::get_singleton()->has("locale/translation_remaps"))
+ if (!ProjectSettings::get_singleton()->has("locale/translation_remaps"))
return;
- Dictionary remaps = GlobalConfig::get_singleton()->get("locale/translation_remaps");
+ Dictionary remaps = ProjectSettings::get_singleton()->get("locale/translation_remaps");
TreeItem *k = p_item->cast_to<TreeItem>();
@@ -1093,8 +1159,8 @@ void ProjectSettings::_translation_res_delete(Object *p_item, int p_column, int
remaps.erase(key);
undo_redo->create_action(TTR("Remove Resource Remap"));
- undo_redo->add_do_property(GlobalConfig::get_singleton(), "locale/translation_remaps", remaps);
- undo_redo->add_undo_property(GlobalConfig::get_singleton(), "locale/translation_remaps", GlobalConfig::get_singleton()->get("locale/translation_remaps"));
+ undo_redo->add_do_property(ProjectSettings::get_singleton(), "locale/translation_remaps", remaps);
+ undo_redo->add_undo_property(ProjectSettings::get_singleton(), "locale/translation_remaps", ProjectSettings::get_singleton()->get("locale/translation_remaps"));
undo_redo->add_do_method(this, "_update_translations");
undo_redo->add_undo_method(this, "_update_translations");
undo_redo->add_do_method(this, "_settings_changed");
@@ -1102,15 +1168,15 @@ void ProjectSettings::_translation_res_delete(Object *p_item, int p_column, int
undo_redo->commit_action();
}
-void ProjectSettings::_translation_res_option_delete(Object *p_item, int p_column, int p_button) {
+void ProjectSettingsEditor::_translation_res_option_delete(Object *p_item, int p_column, int p_button) {
if (updating_translations)
return;
- if (!GlobalConfig::get_singleton()->has("locale/translation_remaps"))
+ if (!ProjectSettings::get_singleton()->has("locale/translation_remaps"))
return;
- Dictionary remaps = GlobalConfig::get_singleton()->get("locale/translation_remaps");
+ Dictionary remaps = ProjectSettings::get_singleton()->get("locale/translation_remaps");
TreeItem *k = translation_remap->get_selected();
ERR_FAIL_COND(!k);
@@ -1127,8 +1193,8 @@ void ProjectSettings::_translation_res_option_delete(Object *p_item, int p_colum
remaps[key] = r;
undo_redo->create_action(TTR("Remove Resource Remap Option"));
- undo_redo->add_do_property(GlobalConfig::get_singleton(), "locale/translation_remaps", remaps);
- undo_redo->add_undo_property(GlobalConfig::get_singleton(), "locale/translation_remaps", GlobalConfig::get_singleton()->get("locale/translation_remaps"));
+ undo_redo->add_do_property(ProjectSettings::get_singleton(), "locale/translation_remaps", remaps);
+ undo_redo->add_undo_property(ProjectSettings::get_singleton(), "locale/translation_remaps", ProjectSettings::get_singleton()->get("locale/translation_remaps"));
undo_redo->add_do_method(this, "_update_translations");
undo_redo->add_undo_method(this, "_update_translations");
undo_redo->add_do_method(this, "_settings_changed");
@@ -1136,7 +1202,7 @@ void ProjectSettings::_translation_res_option_delete(Object *p_item, int p_colum
undo_redo->commit_action();
}
-void ProjectSettings::_update_translations() {
+void ProjectSettingsEditor::_update_translations() {
//update translations
@@ -1148,9 +1214,9 @@ void ProjectSettings::_update_translations() {
translation_list->clear();
TreeItem *root = translation_list->create_item(NULL);
translation_list->set_hide_root(true);
- if (GlobalConfig::get_singleton()->has("locale/translations")) {
+ if (ProjectSettings::get_singleton()->has("locale/translations")) {
- PoolStringArray translations = GlobalConfig::get_singleton()->get("locale/translations");
+ PoolStringArray translations = ProjectSettings::get_singleton()->get("locale/translations");
for (int i = 0; i < translations.size(); i++) {
TreeItem *t = translation_list->create_item(root);
@@ -1186,9 +1252,9 @@ void ProjectSettings::_update_translations() {
langnames += names[i];
}
- if (GlobalConfig::get_singleton()->has("locale/translation_remaps")) {
+ if (ProjectSettings::get_singleton()->has("locale/translation_remaps")) {
- Dictionary remaps = GlobalConfig::get_singleton()->get("locale/translation_remaps");
+ Dictionary remaps = ProjectSettings::get_singleton()->get("locale/translation_remaps");
List<Variant> rk;
remaps.get_key_list(&rk);
Vector<String> keys;
@@ -1241,7 +1307,7 @@ void ProjectSettings::_update_translations() {
updating_translations = false;
}
-void ProjectSettings::_toggle_search_bar(bool p_pressed) {
+void ProjectSettingsEditor::_toggle_search_bar(bool p_pressed) {
globals_editor->get_property_editor()->set_use_filter(p_pressed);
@@ -1258,7 +1324,7 @@ void ProjectSettings::_toggle_search_bar(bool p_pressed) {
}
}
-void ProjectSettings::_clear_search_box() {
+void ProjectSettingsEditor::_clear_search_box() {
if (search_box->get_text() == "")
return;
@@ -1267,52 +1333,54 @@ void ProjectSettings::_clear_search_box() {
globals_editor->get_property_editor()->update_tree();
}
-void ProjectSettings::set_plugins_page() {
+void ProjectSettingsEditor::set_plugins_page() {
tab_container->set_current_tab(plugin_settings->get_index());
}
-void ProjectSettings::_bind_methods() {
-
- ClassDB::bind_method(D_METHOD("_item_selected"), &ProjectSettings::_item_selected);
- ClassDB::bind_method(D_METHOD("_item_add"), &ProjectSettings::_item_add);
- ClassDB::bind_method(D_METHOD("_item_adds"), &ProjectSettings::_item_adds);
- ClassDB::bind_method(D_METHOD("_item_del"), &ProjectSettings::_item_del);
- ClassDB::bind_method(D_METHOD("_item_checked"), &ProjectSettings::_item_checked);
- ClassDB::bind_method(D_METHOD("_save"), &ProjectSettings::_save);
- ClassDB::bind_method(D_METHOD("_action_add"), &ProjectSettings::_action_add);
- ClassDB::bind_method(D_METHOD("_action_adds"), &ProjectSettings::_action_adds);
- ClassDB::bind_method(D_METHOD("_action_selected"), &ProjectSettings::_action_selected);
- ClassDB::bind_method(D_METHOD("_action_edited"), &ProjectSettings::_action_edited);
- ClassDB::bind_method(D_METHOD("_action_activated"), &ProjectSettings::_action_activated);
- ClassDB::bind_method(D_METHOD("_action_button_pressed"), &ProjectSettings::_action_button_pressed);
- ClassDB::bind_method(D_METHOD("_update_actions"), &ProjectSettings::_update_actions);
- ClassDB::bind_method(D_METHOD("_wait_for_key"), &ProjectSettings::_wait_for_key);
- ClassDB::bind_method(D_METHOD("_add_item"), &ProjectSettings::_add_item, DEFVAL(Variant()));
- ClassDB::bind_method(D_METHOD("_device_input_add"), &ProjectSettings::_device_input_add);
- ClassDB::bind_method(D_METHOD("_press_a_key_confirm"), &ProjectSettings::_press_a_key_confirm);
- ClassDB::bind_method(D_METHOD("_settings_prop_edited"), &ProjectSettings::_settings_prop_edited);
- ClassDB::bind_method(D_METHOD("_copy_to_platform"), &ProjectSettings::_copy_to_platform);
- ClassDB::bind_method(D_METHOD("_update_translations"), &ProjectSettings::_update_translations);
- ClassDB::bind_method(D_METHOD("_translation_delete"), &ProjectSettings::_translation_delete);
- ClassDB::bind_method(D_METHOD("_settings_changed"), &ProjectSettings::_settings_changed);
- ClassDB::bind_method(D_METHOD("_translation_add"), &ProjectSettings::_translation_add);
- ClassDB::bind_method(D_METHOD("_translation_file_open"), &ProjectSettings::_translation_file_open);
-
- ClassDB::bind_method(D_METHOD("_translation_res_add"), &ProjectSettings::_translation_res_add);
- ClassDB::bind_method(D_METHOD("_translation_res_file_open"), &ProjectSettings::_translation_res_file_open);
- ClassDB::bind_method(D_METHOD("_translation_res_option_add"), &ProjectSettings::_translation_res_option_add);
- ClassDB::bind_method(D_METHOD("_translation_res_option_file_open"), &ProjectSettings::_translation_res_option_file_open);
- ClassDB::bind_method(D_METHOD("_translation_res_select"), &ProjectSettings::_translation_res_select);
- ClassDB::bind_method(D_METHOD("_translation_res_option_changed"), &ProjectSettings::_translation_res_option_changed);
- ClassDB::bind_method(D_METHOD("_translation_res_delete"), &ProjectSettings::_translation_res_delete);
- ClassDB::bind_method(D_METHOD("_translation_res_option_delete"), &ProjectSettings::_translation_res_option_delete);
-
- ClassDB::bind_method(D_METHOD("_clear_search_box"), &ProjectSettings::_clear_search_box);
- ClassDB::bind_method(D_METHOD("_toggle_search_bar"), &ProjectSettings::_toggle_search_bar);
+void ProjectSettingsEditor::_bind_methods() {
+
+ ClassDB::bind_method(D_METHOD("_item_selected"), &ProjectSettingsEditor::_item_selected);
+ ClassDB::bind_method(D_METHOD("_item_add"), &ProjectSettingsEditor::_item_add);
+ ClassDB::bind_method(D_METHOD("_item_adds"), &ProjectSettingsEditor::_item_adds);
+ ClassDB::bind_method(D_METHOD("_item_del"), &ProjectSettingsEditor::_item_del);
+ ClassDB::bind_method(D_METHOD("_item_checked"), &ProjectSettingsEditor::_item_checked);
+ ClassDB::bind_method(D_METHOD("_save"), &ProjectSettingsEditor::_save);
+ ClassDB::bind_method(D_METHOD("_action_add"), &ProjectSettingsEditor::_action_add);
+ ClassDB::bind_method(D_METHOD("_action_adds"), &ProjectSettingsEditor::_action_adds);
+ ClassDB::bind_method(D_METHOD("_action_selected"), &ProjectSettingsEditor::_action_selected);
+ ClassDB::bind_method(D_METHOD("_action_edited"), &ProjectSettingsEditor::_action_edited);
+ ClassDB::bind_method(D_METHOD("_action_activated"), &ProjectSettingsEditor::_action_activated);
+ ClassDB::bind_method(D_METHOD("_action_button_pressed"), &ProjectSettingsEditor::_action_button_pressed);
+ ClassDB::bind_method(D_METHOD("_update_actions"), &ProjectSettingsEditor::_update_actions);
+ ClassDB::bind_method(D_METHOD("_wait_for_key"), &ProjectSettingsEditor::_wait_for_key);
+ ClassDB::bind_method(D_METHOD("_add_item"), &ProjectSettingsEditor::_add_item, DEFVAL(Variant()));
+ ClassDB::bind_method(D_METHOD("_device_input_add"), &ProjectSettingsEditor::_device_input_add);
+ ClassDB::bind_method(D_METHOD("_press_a_key_confirm"), &ProjectSettingsEditor::_press_a_key_confirm);
+ ClassDB::bind_method(D_METHOD("_settings_prop_edited"), &ProjectSettingsEditor::_settings_prop_edited);
+ ClassDB::bind_method(D_METHOD("_copy_to_platform"), &ProjectSettingsEditor::_copy_to_platform);
+ ClassDB::bind_method(D_METHOD("_update_translations"), &ProjectSettingsEditor::_update_translations);
+ ClassDB::bind_method(D_METHOD("_translation_delete"), &ProjectSettingsEditor::_translation_delete);
+ ClassDB::bind_method(D_METHOD("_settings_changed"), &ProjectSettingsEditor::_settings_changed);
+ ClassDB::bind_method(D_METHOD("_translation_add"), &ProjectSettingsEditor::_translation_add);
+ ClassDB::bind_method(D_METHOD("_translation_file_open"), &ProjectSettingsEditor::_translation_file_open);
+
+ ClassDB::bind_method(D_METHOD("_translation_res_add"), &ProjectSettingsEditor::_translation_res_add);
+ ClassDB::bind_method(D_METHOD("_translation_res_file_open"), &ProjectSettingsEditor::_translation_res_file_open);
+ ClassDB::bind_method(D_METHOD("_translation_res_option_add"), &ProjectSettingsEditor::_translation_res_option_add);
+ ClassDB::bind_method(D_METHOD("_translation_res_option_file_open"), &ProjectSettingsEditor::_translation_res_option_file_open);
+ ClassDB::bind_method(D_METHOD("_translation_res_select"), &ProjectSettingsEditor::_translation_res_select);
+ ClassDB::bind_method(D_METHOD("_translation_res_option_changed"), &ProjectSettingsEditor::_translation_res_option_changed);
+ ClassDB::bind_method(D_METHOD("_translation_res_delete"), &ProjectSettingsEditor::_translation_res_delete);
+ ClassDB::bind_method(D_METHOD("_translation_res_option_delete"), &ProjectSettingsEditor::_translation_res_option_delete);
+
+ ClassDB::bind_method(D_METHOD("_clear_search_box"), &ProjectSettingsEditor::_clear_search_box);
+ ClassDB::bind_method(D_METHOD("_toggle_search_bar"), &ProjectSettingsEditor::_toggle_search_bar);
+
+ ClassDB::bind_method(D_METHOD("_copy_to_platform_about_to_show"), &ProjectSettingsEditor::_copy_to_platform_about_to_show);
}
-ProjectSettings::ProjectSettings(EditorData *p_data) {
+ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
singleton = this;
set_title(TTR("Project Settings (project.godot)"));
@@ -1388,11 +1456,6 @@ ProjectSettings::ProjectSettings(EditorData *p_data) {
add->set_text(TTR("Add"));
add->connect("pressed", this, "_item_add");
- Button *del = memnew(Button);
- add_prop_bar->add_child(del);
- del->set_text(TTR("Del"));
- del->connect("pressed", this, "_item_del");
-
search_bar = memnew(HBoxContainer);
search_bar->set_h_size_flags(Control::SIZE_EXPAND_FILL);
hbc->add_child(search_bar);
@@ -1409,9 +1472,10 @@ ProjectSettings::ProjectSettings(EditorData *p_data) {
globals_editor = memnew(SectionedPropertyEditor);
props_base->add_child(globals_editor);
globals_editor->get_property_editor()->set_undo_redo(EditorNode::get_singleton()->get_undo_redo());
+ globals_editor->get_property_editor()->set_property_selectable(true);
//globals_editor->hide_top_label();
globals_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL);
- globals_editor->get_property_editor()->register_text_enter(search_box);
+ globals_editor->register_search_box(search_box);
globals_editor->get_property_editor()->get_scene_tree()->connect("cell_selected", this, "_item_selected");
globals_editor->get_property_editor()->connect("property_toggled", this, "_item_checked", varray(), CONNECT_DEFERRED);
globals_editor->get_property_editor()->connect("property_edited", this, "_settings_prop_edited");
@@ -1430,15 +1494,17 @@ ProjectSettings::ProjectSettings(EditorData *p_data) {
save->connect("pressed",this,"_save");
*/
- hbc = memnew(HBoxContainer);
- props_base->add_child(hbc);
+ Button *del = memnew(Button);
+ hbc->add_child(del);
+ del->set_text(TTR("Delete"));
+ del->connect("pressed", this, "_item_del");
- popup_platform = memnew(MenuButton);
- popup_platform->set_text(TTR("Copy To Platform.."));
- popup_platform->set_disabled(true);
- hbc->add_child(popup_platform);
+ add_prop_bar->add_child(memnew(VSeparator));
- hbc->add_spacer();
+ popup_copy_to_feature = memnew(MenuButton);
+ popup_copy_to_feature->set_text(TTR("Override For.."));
+ popup_copy_to_feature->set_disabled(true);
+ add_prop_bar->add_child(popup_copy_to_feature);
/*List<StringName> ep;
EditorImportExport::get_singleton()->get_export_platforms(&ep);
@@ -1446,11 +1512,13 @@ ProjectSettings::ProjectSettings(EditorData *p_data) {
for(List<StringName>::Element *E=ep.front();E;E=E->next()) {
- popup_platform->get_popup()->add_item( E->get() );
+ popup_copy_to_feature->get_popup()->add_item( E->get() );
}*/
- popup_platform->get_popup()->connect("id_pressed", this, "_copy_to_platform");
+ popup_copy_to_feature->get_popup()->connect("id_pressed", this, "_copy_to_platform");
+ popup_copy_to_feature->get_popup()->connect("about_to_show", this, "_copy_to_platform_about_to_show");
+
get_ok()->set_text(TTR("Close"));
set_hide_on_ok(true);
@@ -1665,7 +1733,7 @@ ProjectSettings::ProjectSettings(EditorData *p_data) {
timer = memnew(Timer);
timer->set_wait_time(1.5);
- timer->connect("timeout", GlobalConfig::get_singleton(), "save");
+ timer->connect("timeout", ProjectSettings::get_singleton(), "save");
timer->set_one_shot(true);
add_child(timer);
diff --git a/editor/project_settings.h b/editor/project_settings_editor.h
index 03140a854b..4390a23d60 100644
--- a/editor/project_settings.h
+++ b/editor/project_settings_editor.h
@@ -40,8 +40,8 @@
//#include "project_export_settings.h"
-class ProjectSettings : public AcceptDialog {
- GDCLASS(ProjectSettings, AcceptDialog);
+class ProjectSettingsEditor : public AcceptDialog {
+ GDCLASS(ProjectSettingsEditor, AcceptDialog);
enum InputType {
INPUT_KEY,
@@ -78,7 +78,7 @@ class ProjectSettings : public AcceptDialog {
SpinBox *device_id;
OptionButton *device_index;
Label *device_index_label;
- MenuButton *popup_platform;
+ MenuButton *popup_copy_to_feature;
LineEdit *action_name;
Tree *input_editor;
@@ -145,9 +145,11 @@ class ProjectSettings : public AcceptDialog {
void _toggle_search_bar(bool p_pressed);
void _clear_search_box();
- ProjectSettings();
+ void _copy_to_platform_about_to_show();
- static ProjectSettings *singleton;
+ ProjectSettingsEditor();
+
+ static ProjectSettingsEditor *singleton;
protected:
void _notification(int p_what);
@@ -155,13 +157,13 @@ protected:
public:
void add_translation(const String &p_translation);
- static ProjectSettings *get_singleton() { return singleton; }
+ static ProjectSettingsEditor *get_singleton() { return singleton; }
void popup_project_settings();
void set_plugins_page();
void queue_save();
- ProjectSettings(EditorData *p_data);
+ ProjectSettingsEditor(EditorData *p_data);
};
#endif // PROJECT_SETTINGS_H
diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp
index ad9b3607e9..42485317c1 100644
--- a/editor/property_editor.cpp
+++ b/editor/property_editor.cpp
@@ -37,8 +37,6 @@
#include "editor_help.h"
#include "editor_node.h"
#include "editor_settings.h"
-#include "global_config.h"
-#include "global_config.h"
#include "io/image_loader.h"
#include "io/resource_loader.h"
#include "multi_node_edit.h"
@@ -46,6 +44,8 @@
#include "os/keyboard.h"
#include "pair.h"
#include "print_string.h"
+#include "project_settings.h"
+#include "project_settings.h"
#include "property_selector.h"
#include "scene/gui/label.h"
#include "scene/main/viewport.h"
@@ -415,7 +415,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
int idx = i * 10 + j;
CheckBox *c = checks20[idx];
- c->set_text(GlobalConfig::get_singleton()->get(basename + "/layer_" + itos(idx + 1)));
+ c->set_text(ProjectSettings::get_singleton()->get(basename + "/layer_" + itos(idx + 1)));
c->set_pressed(flgs & (1 << (i * 10 + j)));
c->show();
}
@@ -815,16 +815,12 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
color_picker = memnew(ColorPicker);
add_child(color_picker);
color_picker->hide();
- color_picker->set_area_as_parent_rect();
- for (int i = 0; i < 4; i++)
- color_picker->set_margin((Margin)i, 5);
color_picker->connect("color_changed", this, "_color_changed");
}
color_picker->show();
color_picker->set_edit_alpha(hint != PROPERTY_HINT_COLOR_NO_ALPHA);
color_picker->set_pick_color(v);
- set_size(Size2(307 * EDSCALE, 460 * EDSCALE));
color_picker->set_focus_on_line_edit();
/*
int ofs=80;
@@ -1023,7 +1019,7 @@ void CustomPropertyEditor::_file_selected(String p_file) {
if (hint == PROPERTY_HINT_FILE || hint == PROPERTY_HINT_DIR) {
- v = GlobalConfig::get_singleton()->localize_path(p_file);
+ v = ProjectSettings::get_singleton()->localize_path(p_file);
emit_signal("variant_changed");
hide();
}
@@ -1961,11 +1957,6 @@ CustomPropertyEditor::CustomPropertyEditor() {
add_child(error);
//error->get_cancel()->hide();
- type_button = memnew(MenuButton);
- add_child(type_button);
- type_button->hide();
- type_button->get_popup()->connect("id_pressed", this, "_type_create_selected");
-
scene_tree = memnew(SceneTreeDialog);
add_child(scene_tree);
scene_tree->connect("selected", this, "_node_path_selected");
@@ -1983,6 +1974,11 @@ CustomPropertyEditor::CustomPropertyEditor() {
//easing_draw->emit_signal(SceneStringNames::get_singleton()->input_event,InputEvent());
easing_draw->set_default_cursor_shape(Control::CURSOR_MOVE);
+ type_button = memnew(MenuButton);
+ add_child(type_button);
+ type_button->hide();
+ type_button->get_popup()->connect("id_pressed", this, "_type_create_selected");
+
menu = memnew(PopupMenu);
add_child(menu);
menu->connect("id_pressed", this, "_menu_option");
@@ -3006,8 +3002,18 @@ void PropertyEditor::update_tree() {
String name = (basename.find("/") != -1) ? basename.right(basename.find_last("/") + 1) : basename;
- if (capitalize_paths)
- name = name.camelcase_to_underscore().capitalize();
+ if (capitalize_paths) {
+ int dot = name.find(".");
+ if (dot != -1) {
+ String ov = name.right(dot);
+ name = name.substr(0, dot);
+ name = name.camelcase_to_underscore().capitalize();
+ name += ov;
+
+ } else {
+ name = name.camelcase_to_underscore().capitalize();
+ }
+ }
String path = basename.left(basename.find_last("/"));
@@ -3050,7 +3056,7 @@ void PropertyEditor::update_tree() {
//item->set_custom_bg_color(1,col);
}
item->set_editable(0, false);
- item->set_selectable(0, false);
+ item->set_selectable(0, property_selectable);
if (p.usage & PROPERTY_USAGE_CHECKABLE) {
@@ -3063,6 +3069,18 @@ void PropertyEditor::update_tree() {
item->set_text(0, name);
item->set_tooltip(0, p.name);
+ if (name.find(".") != -1) {
+ Color textcol = get_color("font_color", "Tree");
+ textcol.a *= 0.5;
+ //override :D
+ item->set_custom_color(0, textcol);
+ item->set_custom_color(1, textcol);
+
+ Color iconcol(1, 1, 1, 0.6);
+ item->set_icon_color(0, iconcol);
+ item->set_icon_color(1, iconcol);
+ }
+
if (use_doc_hints) {
StringName setter;
StringName type;
@@ -3840,7 +3858,7 @@ void PropertyEditor::_item_edited() {
break;
if (type == Variant::INT)
- _edit_set(name, int(item->get_range(1)), refresh_all);
+ _edit_set(name, round(item->get_range(1)), refresh_all);
else
_edit_set(name, item->get_range(1), refresh_all);
} break;
@@ -4312,6 +4330,11 @@ void PropertyEditor::register_text_enter(Node *p_line_edit) {
search_box->connect("text_changed", this, "_filter_changed");
}
+void PropertyEditor::set_property_selectable(bool p_selectable) {
+ property_selectable = p_selectable;
+ update_tree();
+}
+
void PropertyEditor::set_subsection_selectable(bool p_selectable) {
if (p_selectable == subsection_selectable)
@@ -4331,7 +4354,7 @@ PropertyEditor::PropertyEditor() {
_prop_edited = "property_edited";
- hide_script = false;
+ hide_script = true;
use_folding = false;
undo_redo = NULL;
@@ -4398,6 +4421,7 @@ PropertyEditor::PropertyEditor() {
updating_folding = true;
use_filter = false;
subsection_selectable = false;
+ property_selectable = false;
show_type_icons = EDITOR_DEF("interface/show_type_icons", false);
}
@@ -4462,7 +4486,7 @@ class SectionedPropertyEditorFilter : public Object {
continue;
if (sp == -1) {
- pi.name = "Global/" + pi.name;
+ pi.name = "global/" + pi.name;
}
if (pi.name.begins_with(section + "/")) {
@@ -4512,6 +4536,7 @@ public:
void SectionedPropertyEditor::_bind_methods() {
ClassDB::bind_method("_section_selected", &SectionedPropertyEditor::_section_selected);
+ ClassDB::bind_method("_search_changed", &SectionedPropertyEditor::_search_changed);
ClassDB::bind_method("update_category_list", &SectionedPropertyEditor::update_category_list);
}
@@ -4609,6 +4634,10 @@ void SectionedPropertyEditor::update_category_list() {
if (pi.name.find(":") != -1 || pi.name == "script" || pi.name == "resource_name" || pi.name == "resource_path")
continue;
+
+ if (search_box && search_box->get_text() != String() && pi.name.findn(search_box->get_text()) == -1)
+ continue;
+
int sp = pi.name.find("/");
if (sp == -1)
pi.name = "Global/" + pi.name;
@@ -4616,7 +4645,9 @@ void SectionedPropertyEditor::update_category_list() {
Vector<String> sectionarr = pi.name.split("/");
String metasection;
- for (int i = 0; i < MIN(2, sectionarr.size() - 1); i++) {
+ int sc = MIN(2, sectionarr.size() - 1);
+
+ for (int i = 0; i < sc; i++) {
TreeItem *parent = section_map[metasection];
@@ -4631,6 +4662,12 @@ void SectionedPropertyEditor::update_category_list() {
section_map[metasection] = ms;
ms->set_text(0, sectionarr[i].capitalize());
ms->set_metadata(0, metasection);
+ ms->set_selectable(0, false);
+ }
+
+ if (i == sc - 1) {
+ //if it has children, make selectable
+ section_map[metasection]->set_selectable(0, true);
}
}
}
@@ -4638,6 +4675,20 @@ void SectionedPropertyEditor::update_category_list() {
if (section_map.has(selected_category)) {
section_map[selected_category]->select(0);
}
+
+ editor->update_tree();
+}
+
+void SectionedPropertyEditor::register_search_box(LineEdit *p_box) {
+
+ search_box = p_box;
+ editor->register_text_enter(p_box);
+ search_box->connect("text_changed", this, "_search_changed");
+}
+
+void SectionedPropertyEditor::_search_changed(const String &p_what) {
+
+ update_category_list();
}
PropertyEditor *SectionedPropertyEditor::get_property_editor() {
@@ -4649,6 +4700,8 @@ SectionedPropertyEditor::SectionedPropertyEditor() {
obj = -1;
+ search_box = NULL;
+
VBoxContainer *left_vb = memnew(VBoxContainer);
left_vb->set_custom_minimum_size(Size2(160, 0) * EDSCALE);
add_child(left_vb);
diff --git a/editor/property_editor.h b/editor/property_editor.h
index 47bd807c3f..273eff371e 100644
--- a/editor/property_editor.h
+++ b/editor/property_editor.h
@@ -1,4 +1,4 @@
-/*************************************************************************/
+/*************************************************************************/
/* property_editor.h */
/*************************************************************************/
/* This file is part of: */
@@ -191,6 +191,7 @@ class PropertyEditor : public Control {
bool subsection_selectable;
bool hide_script;
bool use_folding;
+ bool property_selectable;
bool updating_folding;
@@ -288,6 +289,7 @@ public:
void register_text_enter(Node *p_line_edit);
void set_subsection_selectable(bool p_selectable);
+ void set_property_selectable(bool p_selectable);
void set_use_folding(bool p_enable);
PropertyEditor();
@@ -307,11 +309,15 @@ class SectionedPropertyEditor : public HBoxContainer {
Map<String, TreeItem *> section_map;
PropertyEditor *editor;
+ LineEdit *search_box;
static void _bind_methods();
void _section_selected();
+ void _search_changed(const String &p_what);
+
public:
+ void register_search_box(LineEdit *p_box);
PropertyEditor *get_property_editor();
void edit(Object *p_object);
String get_full_item_path(const String &p_item);
diff --git a/editor/property_selector.cpp b/editor/property_selector.cpp
index 47e5994e3f..c6af993676 100644
--- a/editor/property_selector.cpp
+++ b/editor/property_selector.cpp
@@ -167,7 +167,7 @@ void PropertySelector::_update_search() {
continue;
}
- if (!(E->get().usage & PROPERTY_USAGE_EDITOR))
+ if (!(E->get().usage & PROPERTY_USAGE_EDITOR) && !(E->get().usage & PROPERTY_USAGE_SCRIPT_VARIABLE))
continue;
if (search_box->get_text() != String() && E->get().name.find(search_box->get_text()) == -1)
diff --git a/editor/resources_dock.cpp b/editor/resources_dock.cpp
index ddecfd108f..d3b68d92e4 100644
--- a/editor/resources_dock.cpp
+++ b/editor/resources_dock.cpp
@@ -32,10 +32,10 @@
#include "editor_file_system.h"
#include "editor_node.h"
#include "editor_settings.h"
-#include "global_config.h"
#include "io/resource_loader.h"
#include "io/resource_saver.h"
#include "project_settings.h"
+#include "project_settings_editor.h"
void ResourcesDock::_tool_selected(int p_tool) {
@@ -124,7 +124,7 @@ void ResourcesDock::save_resource(const String &p_path, const Ref<Resource> &p_r
flg|=ResourceSaver::FLAG_RELATIVE_PATHS;
*/
- String path = GlobalConfig::get_singleton()->localize_path(p_path);
+ String path = ProjectSettings::get_singleton()->localize_path(p_path);
Error err = ResourceSaver::save(path, p_resource, flg | ResourceSaver::FLAG_REPLACE_SUBRESOURCE_PATHS);
if (err != OK) {
diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp
index da2d22b900..47a9185389 100644
--- a/editor/scene_tree_dock.cpp
+++ b/editor/scene_tree_dock.cpp
@@ -37,9 +37,9 @@
#include "editor/plugins/spatial_editor_plugin.h"
#include "editor_node.h"
#include "editor_settings.h"
-#include "global_config.h"
#include "multi_node_edit.h"
#include "os/keyboard.h"
+#include "project_settings.h"
#include "scene/main/viewport.h"
#include "scene/resources/packed_scene.h"
#include "script_editor_debugger.h"
@@ -183,7 +183,7 @@ void SceneTreeDock::_perform_instance_scenes(const Vector<String> &p_files, Node
}
}
- instanced_scene->set_filename(GlobalConfig::get_singleton()->localize_path(p_files[i]));
+ instanced_scene->set_filename(ProjectSettings::get_singleton()->localize_path(p_files[i]));
instances.push_back(instanced_scene);
}
@@ -658,7 +658,96 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
}
}
} break;
+ case TOOL_SCENE_EDITABLE_CHILDREN: {
+ List<Node *> selection = editor_selection->get_selected_node_list();
+ if (List<Node *>::Element *e = selection.front()) {
+ if (Node *node = e->get()) {
+ bool editable = EditorNode::get_singleton()->get_edited_scene()->is_editable_instance(node);
+ int editable_item_idx = menu->get_item_idx_from_text(TTR("Editable Children"));
+ int placeholder_item_idx = menu->get_item_idx_from_text(TTR("Load As Placeholder"));
+ editable = !editable;
+
+ EditorNode::get_singleton()->get_edited_scene()->set_editable_instance(node, editable);
+ menu->set_item_checked(editable_item_idx, editable);
+ if (editable) {
+ node->set_scene_instance_load_placeholder(false);
+ menu->set_item_checked(placeholder_item_idx, false);
+ }
+ scene_tree->update_tree();
+ }
+ }
+ } break;
+ case TOOL_SCENE_USE_PLACEHOLDER: {
+ List<Node *> selection = editor_selection->get_selected_node_list();
+ if (List<Node *>::Element *e = selection.front()) {
+ if (Node *node = e->get()) {
+ bool placeholder = node->get_scene_instance_load_placeholder();
+ placeholder = !placeholder;
+ int editable_item_idx = menu->get_item_idx_from_text(TTR("Editable Children"));
+ int placeholder_item_idx = menu->get_item_idx_from_text(TTR("Load As Placeholder"));
+ if (placeholder)
+ EditorNode::get_singleton()->get_edited_scene()->set_editable_instance(node, false);
+
+ node->set_scene_instance_load_placeholder(placeholder);
+ menu->set_item_checked(editable_item_idx, false);
+ menu->set_item_checked(placeholder_item_idx, placeholder);
+ scene_tree->update_tree();
+ }
+ }
+ } break;
+ case TOOL_SCENE_CLEAR_INSTANCING: {
+ List<Node *> selection = editor_selection->get_selected_node_list();
+ if (List<Node *>::Element *e = selection.front()) {
+ if (Node *node = e->get()) {
+ Node *root = EditorNode::get_singleton()->get_edited_scene();
+ UndoRedo *undo_redo = &editor_data->get_undo_redo();
+ if (!root)
+ break;
+
+ ERR_FAIL_COND(node->get_filename() == String());
+
+ undo_redo->create_action("Discard Instancing");
+ undo_redo->add_do_method(node, "set_filename", "");
+ undo_redo->add_undo_method(node, "set_filename", node->get_filename());
+ _node_replace_owner(node, node, root);
+ undo_redo->add_do_method(scene_tree, "update_tree");
+ undo_redo->add_undo_method(scene_tree, "update_tree");
+ undo_redo->commit_action();
+ }
+ }
+ } break;
+ case TOOL_SCENE_OPEN: {
+ List<Node *> selection = editor_selection->get_selected_node_list();
+ if (List<Node *>::Element *e = selection.front()) {
+ if (Node *node = e->get()) {
+ scene_tree->emit_signal("open", node->get_filename());
+ }
+ }
+ } break;
+ case TOOL_SCENE_CLEAR_INHERITANCE: {
+ clear_inherit_confirm->popup_centered_minsize();
+ } break;
+ case TOOL_SCENE_CLEAR_INHERITANCE_CONFIRM: {
+ List<Node *> selection = editor_selection->get_selected_node_list();
+ if (List<Node *>::Element *e = selection.front()) {
+ if (Node *node = e->get()) {
+ node->set_scene_inherited_state(Ref<SceneState>());
+ scene_tree->update_tree();
+ EditorNode::get_singleton()->get_property_editor()->update_tree();
+ }
+ }
+ } break;
+ case TOOL_SCENE_OPEN_INHERITED: {
+ List<Node *> selection = editor_selection->get_selected_node_list();
+ if (List<Node *>::Element *e = selection.front()) {
+ if (Node *node = e->get()) {
+ if (node && node->get_scene_inherited_state().is_valid()) {
+ scene_tree->emit_signal("open", node->get_scene_inherited_state()->get_path());
+ }
+ }
+ }
+ } break;
default: {
if (p_tool >= EDIT_SUBRESOURCE_BASE) {
@@ -697,11 +786,34 @@ void SceneTreeDock::_notification(int p_what) {
button_create_script->set_icon(get_icon("ScriptCreate", "EditorIcons"));
button_clear_script->set_icon(get_icon("ScriptRemove", "EditorIcons"));
- filter_icon->set_texture(get_icon("Search", "EditorIcons"));
+ filter->add_icon_override("right_icon", get_icon("Search", "EditorIcons"));
EditorNode::get_singleton()->get_editor_selection()->connect("selection_changed", this, "_selection_changed");
} break;
+
+ case NOTIFICATION_ENTER_TREE: {
+ clear_inherit_confirm->connect("confirmed", this, "_tool_selected", varray(TOOL_SCENE_CLEAR_INHERITANCE_CONFIRM));
+ } break;
+
+ case NOTIFICATION_EXIT_TREE: {
+ clear_inherit_confirm->disconnect("confirmed", this, "_tool_selected");
+ } break;
+ }
+}
+
+void SceneTreeDock::_node_replace_owner(Node *p_base, Node *p_node, Node *p_root) {
+
+ if (p_base != p_node) {
+ if (p_node->get_owner() == p_base) {
+ UndoRedo *undo_redo = &editor_data->get_undo_redo();
+ undo_redo->add_do_method(p_node, "set_owner", p_root);
+ undo_redo->add_undo_method(p_node, "set_owner", p_base);
+ }
+ }
+
+ for (int i = 0; i < p_node->get_child_count(); i++) {
+ _node_replace_owner(p_base, p_node->get_child(i), p_root);
}
}
@@ -1769,6 +1881,26 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) {
menu->add_icon_shortcut(get_icon("CreateNewSceneFrom", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/save_branch_as_scene"), TOOL_NEW_SCENE_FROM);
menu->add_separator();
menu->add_icon_shortcut(get_icon("CopyNodePath", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/copy_node_path"), TOOL_COPY_NODE_PATH);
+ bool is_external = (selection[0]->get_filename() != "");
+ if (is_external) {
+ bool is_inherited = selection[0]->get_scene_inherited_state() != NULL;
+ bool is_top_level = selection[0]->get_owner() == NULL;
+ if (is_inherited && is_top_level) {
+ menu->add_separator();
+ menu->add_item(TTR("Clear Inheritance"), TOOL_SCENE_CLEAR_INHERITANCE);
+ menu->add_icon_item(get_icon("Load", "EditorIcons"), TTR("Open in Editor"), TOOL_SCENE_OPEN_INHERITED);
+ } else if (!is_top_level) {
+ menu->add_separator();
+ bool editable = EditorNode::get_singleton()->get_edited_scene()->is_editable_instance(selection[0]);
+ bool placeholder = selection[0]->get_scene_instance_load_placeholder();
+ menu->add_check_item(TTR("Editable Children"), TOOL_SCENE_EDITABLE_CHILDREN);
+ menu->add_check_item(TTR("Load As Placeholder"), TOOL_SCENE_USE_PLACEHOLDER);
+ menu->add_item(TTR("Discard Instancing"), TOOL_SCENE_CLEAR_INSTANCING);
+ menu->add_icon_item(get_icon("Load", "EditorIcons"), TTR("Open in Editor"), TOOL_SCENE_OPEN);
+ menu->set_item_checked(menu->get_item_idx_from_text(TTR("Editable Children")), editable);
+ menu->set_item_checked(menu->get_item_idx_from_text(TTR("Load As Placeholder")), placeholder);
+ }
+ }
}
menu->add_separator();
menu->add_icon_shortcut(get_icon("Remove", "EditorIcons"), ED_SHORTCUT("scene_tree/delete", TTR("Delete Node(s)"), KEY_DELETE), TOOL_ERASE);
@@ -1889,11 +2021,8 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSel
vbc->add_child(filter_hbc);
filter = memnew(LineEdit);
filter->set_h_size_flags(SIZE_EXPAND_FILL);
+ filter->set_placeholder(TTR("Filter nodes"));
filter_hbc->add_child(filter);
- filter_icon = memnew(TextureRect);
- filter_icon->set_custom_minimum_size(Size2(24 * EDSCALE, 0));
- filter_hbc->add_child(filter_icon);
- filter_icon->set_stretch_mode(TextureRect::STRETCH_KEEP_CENTERED);
filter->connect("text_changed", this, "_filter_changed");
tb = memnew(ToolButton);
@@ -1978,6 +2107,11 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSel
first_enter = true;
restore_script_editor_on_drag = false;
+ clear_inherit_confirm = memnew(ConfirmationDialog);
+ clear_inherit_confirm->set_text(TTR("Clear Inheritance? (No Undo!)"));
+ clear_inherit_confirm->get_ok()->set_text(TTR("Clear!"));
+ add_child(clear_inherit_confirm);
+
vbc->add_constant_override("separation", 4);
set_process_input(true);
}
diff --git a/editor/scene_tree_dock.h b/editor/scene_tree_dock.h
index 79e01e7571..5872c5a25d 100644
--- a/editor/scene_tree_dock.h
+++ b/editor/scene_tree_dock.h
@@ -70,7 +70,14 @@ class SceneTreeDock : public VBoxContainer {
TOOL_MULTI_EDIT,
TOOL_ERASE,
TOOL_COPY_NODE_PATH,
- TOOL_BUTTON_MAX
+ TOOL_BUTTON_MAX,
+ TOOL_SCENE_EDITABLE_CHILDREN,
+ TOOL_SCENE_USE_PLACEHOLDER,
+ TOOL_SCENE_CLEAR_INSTANCING,
+ TOOL_SCENE_OPEN,
+ TOOL_SCENE_CLEAR_INHERITANCE,
+ TOOL_SCENE_CLEAR_INHERITANCE_CONFIRM,
+ TOOL_SCENE_OPEN_INHERITED
};
enum {
@@ -112,6 +119,7 @@ class SceneTreeDock : public VBoxContainer {
TextureRect *filter_icon;
PopupMenu *menu;
+ ConfirmationDialog *clear_inherit_confirm;
bool first_enter;
@@ -127,6 +135,7 @@ class SceneTreeDock : public VBoxContainer {
void _do_reparent(Node *p_new_parent, int p_position_in_parent, Vector<Node *> p_nodes, bool p_keep_global_xform);
void _set_owners(Node *p_owner, const Array &p_nodes);
+ void _node_replace_owner(Node *p_base, Node *p_node, Node *p_root);
void _load_request(const String &p_path);
void _script_open_request(const Ref<Script> &p_script);
diff --git a/editor/scene_tree_editor.cpp b/editor/scene_tree_editor.cpp
index d4e5714c0d..f35e098065 100644
--- a/editor/scene_tree_editor.cpp
+++ b/editor/scene_tree_editor.cpp
@@ -44,110 +44,6 @@ Node *SceneTreeEditor::get_scene_node() {
return get_tree()->get_edited_scene_root();
}
-void SceneTreeEditor::_subscene_option(int p_idx) {
-
- Object *obj = ObjectDB::get_instance(instance_node);
- if (!obj)
- return;
- Node *node = obj->cast_to<Node>();
- if (!node)
- return;
-
- switch (p_idx) {
-
- case SCENE_MENU_EDITABLE_CHILDREN: {
-
- bool editable = EditorNode::get_singleton()->get_edited_scene()->is_editable_instance(node);
- editable = !editable;
-
- //node->set_instance_children_editable(editable);
- EditorNode::get_singleton()->get_edited_scene()->set_editable_instance(node, editable);
- instance_menu->set_item_checked(0, editable);
- if (editable) {
- node->set_scene_instance_load_placeholder(false);
- instance_menu->set_item_checked(1, false);
- }
-
- _update_tree();
-
- } break;
- case SCENE_MENU_USE_PLACEHOLDER: {
-
- bool placeholder = node->get_scene_instance_load_placeholder();
- placeholder = !placeholder;
-
- //node->set_instance_children_editable(editable);
- if (placeholder) {
- EditorNode::get_singleton()->get_edited_scene()->set_editable_instance(node, false);
- }
- node->set_scene_instance_load_placeholder(placeholder);
- instance_menu->set_item_checked(0, false);
- instance_menu->set_item_checked(1, placeholder);
-
- _update_tree();
-
- } break;
- case SCENE_MENU_OPEN: {
-
- emit_signal("open", node->get_filename());
- } break;
- case SCENE_MENU_CLEAR_INHERITANCE: {
- clear_inherit_confirm->popup_centered_minsize();
- } break;
- case SCENE_MENU_CLEAR_INSTANCING: {
-
- Node *root = EditorNode::get_singleton()->get_edited_scene();
- if (!root)
- break;
-
- ERR_FAIL_COND(node->get_filename() == String());
-
- undo_redo->create_action("Discard Instancing");
-
- undo_redo->add_do_method(node, "set_filename", "");
- undo_redo->add_undo_method(node, "set_filename", node->get_filename());
-
- _node_replace_owner(node, node, root);
-
- undo_redo->add_do_method(this, "update_tree");
- undo_redo->add_undo_method(this, "update_tree");
-
- undo_redo->commit_action();
-
- } break;
- case SCENE_MENU_OPEN_INHERITED: {
- if (node && node->get_scene_inherited_state().is_valid()) {
- emit_signal("open", node->get_scene_inherited_state()->get_path());
- }
- } break;
- case SCENE_MENU_CLEAR_INHERITANCE_CONFIRM: {
- if (node && node->get_scene_inherited_state().is_valid()) {
- node->set_scene_inherited_state(Ref<SceneState>());
- update_tree();
- EditorNode::get_singleton()->get_property_editor()->update_tree();
- }
-
- } break;
- }
-}
-
-void SceneTreeEditor::_node_replace_owner(Node *p_base, Node *p_node, Node *p_root) {
-
- if (p_base != p_node) {
-
- if (p_node->get_owner() == p_base) {
-
- undo_redo->add_do_method(p_node, "set_owner", p_root);
- undo_redo->add_undo_method(p_node, "set_owner", p_base);
- }
- }
-
- for (int i = 0; i < p_node->get_child_count(); i++) {
-
- _node_replace_owner(p_base, p_node->get_child(i), p_root);
- }
-}
-
void SceneTreeEditor::_cell_button_pressed(Object *p_item, int p_column, int p_id) {
TreeItem *item = p_item->cast_to<TreeItem>();
@@ -159,38 +55,13 @@ void SceneTreeEditor::_cell_button_pressed(Object *p_item, int p_column, int p_i
ERR_FAIL_COND(!n);
if (p_id == BUTTON_SUBSCENE) {
- //open scene request
- Rect2 item_rect = tree->get_item_rect(item, 0);
- item_rect.position.y -= tree->get_scroll().y;
- item_rect.position += tree->get_global_position();
-
if (n == get_scene_node()) {
- inheritance_menu->set_position(item_rect.position + Vector2(0, item_rect.size.y));
- inheritance_menu->set_size(Vector2(item_rect.size.x, 0));
- inheritance_menu->popup();
- instance_node = n->get_instance_ID();
-
- } else {
- instance_menu->set_position(item_rect.position + Vector2(0, item_rect.size.y));
- instance_menu->set_size(Vector2(item_rect.size.x, 0));
- if (EditorNode::get_singleton()->get_edited_scene()->is_editable_instance(n))
- instance_menu->set_item_checked(0, true);
- else
- instance_menu->set_item_checked(0, false);
-
- if (n->get_owner() == get_scene_node()) {
- instance_menu->set_item_checked(1, n->get_scene_instance_load_placeholder());
- instance_menu->set_item_disabled(1, false);
- } else {
-
- instance_menu->set_item_checked(1, false);
- instance_menu->set_item_disabled(1, true);
+ if (n && n->get_scene_inherited_state().is_valid()) {
+ emit_signal("open", n->get_scene_inherited_state()->get_path());
}
-
- instance_menu->popup();
- instance_node = n->get_instance_ID();
+ } else {
+ emit_signal("open", n->get_filename());
}
- //emit_signal("open",n->get_filename());
} else if (p_id == BUTTON_SCRIPT) {
RefPtr script = n->get_script();
if (!script.is_null())
@@ -290,7 +161,7 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) {
item->set_selectable(0, true);
if (can_rename) {
-#ifdef ENABLE_DEPRECATED
+#ifndef DISABLE_DEPRECATED
if (p_node->has_meta("_editor_collapsed")) {
//remove previous way of storing folding, which did not get along with scene inheritance and instancing
if ((bool)p_node->get_meta("_editor_collapsed"))
@@ -353,11 +224,11 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) {
}
if (p_node == get_scene_node() && p_node->get_scene_inherited_state().is_valid()) {
- item->add_button(0, get_icon("InstanceOptions", "EditorIcons"), BUTTON_SUBSCENE, false, TTR("Subscene options"));
+ item->add_button(0, get_icon("InstanceOptions", "EditorIcons"), BUTTON_SUBSCENE, false, TTR("Open in Editor"));
item->set_tooltip(0, TTR("Inherits:") + " " + p_node->get_scene_inherited_state()->get_path() + "\n" + TTR("Type:") + " " + p_node->get_class());
} else if (p_node != get_scene_node() && p_node->get_filename() != "" && can_open_instance) {
- item->add_button(0, get_icon("InstanceOptions", "EditorIcons"), BUTTON_SUBSCENE, false, TTR("Subscene options"));
+ item->add_button(0, get_icon("InstanceOptions", "EditorIcons"), BUTTON_SUBSCENE, false, TTR("Open in Editor"));
item->set_tooltip(0, TTR("Instance:") + " " + p_node->get_filename() + "\n" + TTR("Type:") + " " + p_node->get_class());
} else {
item->set_tooltip(0, String(p_node->get_name()) + "\n" + TTR("Type:") + " " + p_node->get_class());
@@ -472,7 +343,7 @@ void SceneTreeEditor::_node_visibility_changed(Node *p_node) {
void SceneTreeEditor::_update_visibility_color(Node *p_node, TreeItem *p_item) {
if (p_node->is_class("CanvasItem") || p_node->is_class("Spatial")) {
Color color(1, 1, 1, 1);
- bool visible_on_screen = p_node->call("is_visible");
+ bool visible_on_screen = p_node->call("is_visible_in_tree");
if (!visible_on_screen) {
color = Color(0.6, 0.6, 0.6, 1);
}
@@ -633,10 +504,7 @@ void SceneTreeEditor::_notification(int p_what) {
get_tree()->connect("node_removed", this, "_node_removed");
get_tree()->connect("node_configuration_warning_changed", this, "_warning_changed");
- instance_menu->set_item_icon(5, get_icon("Load", "EditorIcons"));
tree->connect("item_collapsed", this, "_cell_collapsed");
- inheritance_menu->set_item_icon(2, get_icon("Load", "EditorIcons"));
- clear_inherit_confirm->connect("confirmed", this, "_subscene_option", varray(SCENE_MENU_CLEAR_INHERITANCE_CONFIRM));
EditorSettings::get_singleton()->connect("settings_changed", this, "_editor_settings_changed");
@@ -649,7 +517,6 @@ void SceneTreeEditor::_notification(int p_what) {
get_tree()->disconnect("tree_changed", this, "_tree_changed");
get_tree()->disconnect("node_removed", this, "_node_removed");
tree->disconnect("item_collapsed", this, "_cell_collapsed");
- clear_inherit_confirm->disconnect("confirmed", this, "_subscene_option");
get_tree()->disconnect("node_configuration_warning_changed", this, "_warning_changed");
EditorSettings::get_singleton()->disconnect("settings_changed", this, "_editor_settings_changed");
}
@@ -1059,7 +926,6 @@ void SceneTreeEditor::_bind_methods() {
ClassDB::bind_method("_selection_changed", &SceneTreeEditor::_selection_changed);
ClassDB::bind_method("_cell_button_pressed", &SceneTreeEditor::_cell_button_pressed);
ClassDB::bind_method("_cell_collapsed", &SceneTreeEditor::_cell_collapsed);
- ClassDB::bind_method("_subscene_option", &SceneTreeEditor::_subscene_option);
ClassDB::bind_method("_rmb_select", &SceneTreeEditor::_rmb_select);
ClassDB::bind_method("_warning_changed", &SceneTreeEditor::_warning_changed);
@@ -1145,29 +1011,6 @@ SceneTreeEditor::SceneTreeEditor(bool p_label, bool p_can_rename, bool p_can_ope
updating_tree = false;
blocked = 0;
- instance_menu = memnew(PopupMenu);
- instance_menu->add_check_item(TTR("Editable Children"), SCENE_MENU_EDITABLE_CHILDREN);
- instance_menu->add_check_item(TTR("Load As Placeholder"), SCENE_MENU_USE_PLACEHOLDER);
- instance_menu->add_separator();
- instance_menu->add_item(TTR("Discard Instancing"), SCENE_MENU_CLEAR_INSTANCING);
- instance_menu->add_separator();
- instance_menu->add_item(TTR("Open in Editor"), SCENE_MENU_OPEN);
- instance_menu->connect("id_pressed", this, "_subscene_option");
- add_child(instance_menu);
-
- inheritance_menu = memnew(PopupMenu);
- inheritance_menu->add_item(TTR("Clear Inheritance"), SCENE_MENU_CLEAR_INHERITANCE);
- inheritance_menu->add_separator();
- inheritance_menu->add_item(TTR("Open in Editor"), SCENE_MENU_OPEN_INHERITED);
- inheritance_menu->connect("id_pressed", this, "_subscene_option");
-
- add_child(inheritance_menu);
-
- clear_inherit_confirm = memnew(ConfirmationDialog);
- clear_inherit_confirm->set_text(TTR("Clear Inheritance? (No Undo!)"));
- clear_inherit_confirm->get_ok()->set_text(TTR("Clear!"));
- add_child(clear_inherit_confirm);
-
update_timer = memnew(Timer);
update_timer->connect("timeout", this, "_update_tree");
update_timer->set_one_shot(true);
diff --git a/editor/scene_tree_editor.h b/editor/scene_tree_editor.h
index ec7115afed..c6283af7b5 100644
--- a/editor/scene_tree_editor.h
+++ b/editor/scene_tree_editor.h
@@ -56,27 +56,14 @@ class SceneTreeEditor : public Control {
BUTTON_GROUPS = 7,
};
- enum {
- SCENE_MENU_EDITABLE_CHILDREN,
- SCENE_MENU_USE_PLACEHOLDER,
- SCENE_MENU_OPEN,
- SCENE_MENU_CLEAR_INHERITANCE,
- SCENE_MENU_OPEN_INHERITED,
- SCENE_MENU_CLEAR_INHERITANCE_CONFIRM,
- SCENE_MENU_CLEAR_INSTANCING,
- };
-
Tree *tree;
Node *selected;
- PopupMenu *instance_menu;
- PopupMenu *inheritance_menu;
ObjectID instance_node;
String filter;
AcceptDialog *error;
AcceptDialog *warning;
- ConfirmationDialog *clear_inherit_confirm;
int blocked;
@@ -119,7 +106,6 @@ class SceneTreeEditor : public Control {
void _node_script_changed(Node *p_node);
void _node_visibility_changed(Node *p_node);
void _update_visibility_color(Node *p_node, TreeItem *p_item);
- void _subscene_option(int p_idx);
void _node_replace_owner(Node *p_base, Node *p_node, Node *p_root);
diff --git a/editor/script_create_dialog.cpp b/editor/script_create_dialog.cpp
index 0f3f5500a8..d81161ae94 100644
--- a/editor/script_create_dialog.cpp
+++ b/editor/script_create_dialog.cpp
@@ -31,9 +31,9 @@
#include "editor/editor_scale.h"
#include "editor_file_system.h"
-#include "global_config.h"
#include "io/resource_saver.h"
#include "os/file_access.h"
+#include "project_settings.h"
#include "script_language.h"
void ScriptCreateDialog::_notification(int p_what) {
@@ -118,13 +118,15 @@ void ScriptCreateDialog::_parent_name_changed(const String &p_parent) {
void ScriptCreateDialog::_template_changed(int p_template) {
+ String selected_template = p_template == 0 ? "" : template_menu->get_item_text(template_menu->get_selected());
+ EditorSettings::get_singleton()->set_project_metadata("script_setup", "last_selected_template", selected_template);
if (p_template == 0) {
//default
script_template = "";
return;
}
String ext = ScriptServer::get_language(language_menu->get_selected())->get_extension();
- String name = template_menu->get_item_text(p_template) + "." + ext;
+ String name = template_list[p_template - 1] + "." + ext;
script_template = EditorSettings::get_singleton()->get_settings_path() + "/script_templates/" + name;
}
@@ -148,20 +150,24 @@ void ScriptCreateDialog::_create_new() {
Ref<Script> scr;
if (script_template != "") {
- scr = ResourceLoader::load(script_template)->duplicate();
+ scr = ResourceLoader::load(script_template);
+ if (scr.is_null()) {
+ alert->get_ok()->set_text(TTR("OK"));
+ alert->set_text(vformat(TTR("Error loading template '%s'"), script_template));
+ alert->popup_centered();
+ return;
+ }
+ scr = scr->duplicate();
ScriptServer::get_language(language_menu->get_selected())->make_template(cname, parent_name->get_text(), scr);
} else {
scr = ScriptServer::get_language(language_menu->get_selected())->get_template(cname, parent_name->get_text());
}
- String selected_language = language_menu->get_item_text(language_menu->get_selected());
- editor_settings->set_project_metadata("script_setup", "last_selected_language", selected_language);
-
if (cname != "")
scr->set_name(cname);
if (!is_built_in) {
- String lpath = GlobalConfig::get_singleton()->localize_path(file_path->get_text());
+ String lpath = ProjectSettings::get_singleton()->localize_path(file_path->get_text());
scr->set_path(lpath);
Error err = ResourceSaver::save(lpath, scr, ResourceSaver::FLAG_CHANGE_PATH);
if (err != OK) {
@@ -239,16 +245,31 @@ void ScriptCreateDialog::_lang_changed(int l) {
bool use_templates = language->is_using_templates();
template_menu->set_disabled(!use_templates);
+ template_menu->clear();
if (use_templates) {
- Vector<String> template_list = EditorSettings::get_singleton()->get_script_templates(language->get_extension());
- template_menu->clear();
+ template_list = EditorSettings::get_singleton()->get_script_templates(language->get_extension());
+
+ String last_lang = EditorSettings::get_singleton()->get_project_metadata("script_setup", "last_selected_language", "");
+ String last_template = EditorSettings::get_singleton()->get_project_metadata("script_setup", "last_selected_template", "");
+
template_menu->add_item(TTR("Default"));
for (int i = 0; i < template_list.size(); i++) {
- template_menu->add_item(template_list[i].capitalize());
+ String s = template_list[i].capitalize();
+ template_menu->add_item(s);
+ if (language_menu->get_item_text(language_menu->get_selected()) == last_lang && last_template == s) {
+ template_menu->select(i + 1);
+ }
}
+ } else {
+
+ template_menu->add_item(TTR("N/A"));
+ script_template = "";
}
+ _template_changed(template_menu->get_selected());
+ EditorSettings::get_singleton()->set_project_metadata("script_setup", "last_selected_language", language_menu->get_item_text(language_menu->get_selected()));
+
_update_dialog();
}
@@ -271,10 +292,8 @@ void ScriptCreateDialog::_browse_path(bool browse_parent) {
file_browse->clear_filters();
List<String> extensions;
- // get all possible extensions for script
- for (int l = 0; l < language_menu->get_item_count(); l++) {
- ScriptServer::get_language(l)->get_recognized_extensions(&extensions);
- }
+ int lang = language_menu->get_selected();
+ ScriptServer::get_language(lang)->get_recognized_extensions(&extensions);
for (List<String>::Element *E = extensions.front(); E; E = E->next()) {
file_browse->add_filter("*." + E->get());
@@ -286,7 +305,7 @@ void ScriptCreateDialog::_browse_path(bool browse_parent) {
void ScriptCreateDialog::_file_selected(const String &p_file) {
- String p = GlobalConfig::get_singleton()->localize_path(p_file);
+ String p = ProjectSettings::get_singleton()->localize_path(p_file);
if (is_browsing_parent) {
parent_name->set_text("\"" + p + "\"");
_class_name_changed("\"" + p + "\"");
@@ -308,7 +327,7 @@ void ScriptCreateDialog::_path_changed(const String &p_path) {
return;
}
- p = GlobalConfig::get_singleton()->localize_path(p);
+ p = ProjectSettings::get_singleton()->localize_path(p);
if (!p.begins_with("res://")) {
_msg_path_valid(false, TTR("Path is not local"));
_update_dialog();
@@ -508,8 +527,6 @@ void ScriptCreateDialog::_bind_methods() {
ScriptCreateDialog::ScriptCreateDialog() {
- editor_settings = EditorSettings::get_singleton();
-
GridContainer *gc = memnew(GridContainer);
VBoxContainer *vb = memnew(VBoxContainer);
HBoxContainer *hb = memnew(HBoxContainer);
@@ -615,7 +632,7 @@ ScriptCreateDialog::ScriptCreateDialog() {
}
}
- String last_selected_language = editor_settings->get_project_metadata("script_setup", "last_selected_language", "");
+ String last_selected_language = EditorSettings::get_singleton()->get_project_metadata("script_setup", "last_selected_language", "");
if (last_selected_language != "") {
for (int i = 0; i < language_menu->get_item_count(); i++) {
if (language_menu->get_item_text(i) == last_selected_language) {
diff --git a/editor/script_create_dialog.h b/editor/script_create_dialog.h
index 1adbfe3f7d..f503b878f5 100644
--- a/editor/script_create_dialog.h
+++ b/editor/script_create_dialog.h
@@ -59,7 +59,6 @@ class ScriptCreateDialog : public ConfirmationDialog {
bool create_new;
bool is_browsing_parent;
String initial_bp;
- EditorSettings *editor_settings;
bool is_new_script_created;
bool is_path_valid;
bool has_named_classes;
@@ -70,6 +69,7 @@ class ScriptCreateDialog : public ConfirmationDialog {
int current_language;
bool re_check_path;
String script_template;
+ Vector<String> template_list;
void _path_changed(const String &p_path = String());
void _lang_changed(int l = 0);
diff --git a/editor/script_editor_debugger.cpp b/editor/script_editor_debugger.cpp
index 9dce48937c..f4ed430d3d 100644
--- a/editor/script_editor_debugger.cpp
+++ b/editor/script_editor_debugger.cpp
@@ -32,8 +32,8 @@
#include "editor_node.h"
#include "editor_profiler.h"
#include "editor_settings.h"
-#include "global_config.h"
#include "main/performance.h"
+#include "project_settings.h"
#include "property_editor.h"
#include "scene/gui/dialogs.h"
#include "scene/gui/label.h"
@@ -1625,24 +1625,24 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) {
hbc->add_child(memnew(VSeparator));
- step = memnew(Button);
+ step = memnew(ToolButton);
hbc->add_child(step);
step->set_tooltip(TTR("Step Into"));
step->connect("pressed", this, "debug_step");
- next = memnew(Button);
+ next = memnew(ToolButton);
hbc->add_child(next);
next->set_tooltip(TTR("Step Over"));
next->connect("pressed", this, "debug_next");
hbc->add_child(memnew(VSeparator));
- dobreak = memnew(Button);
+ dobreak = memnew(ToolButton);
hbc->add_child(dobreak);
dobreak->set_tooltip(TTR("Break"));
dobreak->connect("pressed", this, "debug_break");
- docontinue = memnew(Button);
+ docontinue = memnew(ToolButton);
hbc->add_child(docontinue);
docontinue->set_tooltip(TTR("Continue"));
docontinue->connect("pressed", this, "debug_continue");
@@ -1816,7 +1816,7 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) {
vmem_total->set_editable(false);
vmem_total->set_custom_minimum_size(Size2(100, 1) * EDSCALE);
vmem_hb->add_child(vmem_total);
- vmem_refresh = memnew(Button);
+ vmem_refresh = memnew(ToolButton);
vmem_hb->add_child(vmem_refresh);
vmem_vb->add_child(vmem_hb);
vmem_refresh->connect("pressed", this, "_video_mem_request");
@@ -1849,30 +1849,31 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) {
}
{ // misc
- VBoxContainer *info_left = memnew(VBoxContainer);
- info_left->set_h_size_flags(SIZE_EXPAND_FILL);
+ GridContainer *info_left = memnew(GridContainer);
+ info_left->set_columns(2);
info_left->set_name(TTR("Misc"));
tabs->add_child(info_left);
clicked_ctrl = memnew(LineEdit);
- info_left->add_margin_child(TTR("Clicked Control:"), clicked_ctrl);
+ clicked_ctrl->set_h_size_flags(SIZE_EXPAND_FILL);
+ info_left->add_child(memnew(Label(TTR("Clicked Control:"))));
+ info_left->add_child(clicked_ctrl);
clicked_ctrl_type = memnew(LineEdit);
- info_left->add_margin_child(TTR("Clicked Control Type:"), clicked_ctrl_type);
+ info_left->add_child(memnew(Label(TTR("Clicked Control Type:"))));
+ info_left->add_child(clicked_ctrl_type);
live_edit_root = memnew(LineEdit);
+ live_edit_root->set_h_size_flags(SIZE_EXPAND_FILL);
{
HBoxContainer *lehb = memnew(HBoxContainer);
Label *l = memnew(Label(TTR("Live Edit Root:")));
- lehb->add_child(l);
- l->set_h_size_flags(SIZE_EXPAND_FILL);
+ info_left->add_child(l);
+ lehb->add_child(live_edit_root);
le_set = memnew(Button(TTR("Set From Tree")));
lehb->add_child(le_set);
le_clear = memnew(Button(TTR("Clear")));
lehb->add_child(le_clear);
info_left->add_child(lehb);
- MarginContainer *mc = memnew(MarginContainer);
- mc->add_child(live_edit_root);
- info_left->add_child(mc);
le_set->set_disabled(true);
le_clear->set_disabled(true);
}
diff --git a/editor/settings_config_dialog.cpp b/editor/settings_config_dialog.cpp
index 563de78415..d455e0cea9 100644
--- a/editor/settings_config_dialog.cpp
+++ b/editor/settings_config_dialog.cpp
@@ -32,8 +32,8 @@
#include "editor_file_system.h"
#include "editor_node.h"
#include "editor_settings.h"
-#include "global_config.h"
#include "os/keyboard.h"
+#include "project_settings.h"
#include "scene/gui/margin_container.h"
void EditorSettingsDialog::ok_pressed() {
@@ -332,7 +332,7 @@ EditorSettingsDialog::EditorSettingsDialog() {
property_editor = memnew(SectionedPropertyEditor);
//property_editor->hide_top_label();
property_editor->get_property_editor()->set_use_filter(true);
- property_editor->get_property_editor()->register_text_enter(search_box);
+ property_editor->register_search_box(search_box);
property_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL);
vbc->add_child(property_editor);
property_editor->get_property_editor()->connect("property_edited", this, "_settings_property_edited");
@@ -382,10 +382,6 @@ EditorSettingsDialog::EditorSettingsDialog() {
press_a_key->add_child(l);
press_a_key->connect("gui_input", this, "_wait_for_key");
press_a_key->connect("confirmed", this, "_press_a_key_confirm");
- //Button *load = memnew( Button );
-
- //load->set_text("Load..");
- //hbc->add_child(load);
//get_ok()->set_text("Apply");
set_hide_on_ok(true);
diff --git a/editor/spatial_editor_gizmos.cpp b/editor/spatial_editor_gizmos.cpp
index 76df9eb1ff..faf9dee5d0 100644
--- a/editor/spatial_editor_gizmos.cpp
+++ b/editor/spatial_editor_gizmos.cpp
@@ -867,6 +867,127 @@ LightSpatialGizmo::LightSpatialGizmo(Light *p_light) {
//////
+//// player gizmo
+
+String AudioStreamPlayer3DSpatialGizmo::get_handle_name(int p_idx) const {
+
+ return "Emission Radius";
+}
+
+Variant AudioStreamPlayer3DSpatialGizmo::get_handle_value(int p_idx) const {
+
+ return player->get_emission_angle();
+}
+
+void AudioStreamPlayer3DSpatialGizmo::set_handle(int p_idx, Camera *p_camera, const Point2 &p_point) {
+
+ Transform gt = player->get_global_transform();
+ gt.orthonormalize();
+ Transform gi = gt.affine_inverse();
+
+ Vector3 ray_from = p_camera->project_ray_origin(p_point);
+ Vector3 ray_dir = p_camera->project_ray_normal(p_point);
+ Vector3 ray_to = ray_from + ray_dir * 4096;
+
+ ray_from = gi.xform(ray_from);
+ ray_to = gi.xform(ray_to);
+
+ float closest_dist = 1e20;
+ float closest_angle = 1e20;
+
+ for (int i = 0; i < 180; i++) {
+
+ float a = i * Math_PI / 180.0;
+ float an = (i + 1) * Math_PI / 180.0;
+
+ Vector3 from(Math::sin(a), 0, -Math::cos(a));
+ Vector3 to(Math::sin(an), 0, -Math::cos(an));
+
+ Vector3 r1, r2;
+ Geometry::get_closest_points_between_segments(from, to, ray_from, ray_to, r1, r2);
+ float d = r1.distance_to(r2);
+ if (d < closest_dist) {
+ closest_dist = d;
+ closest_angle = i;
+ }
+ }
+
+ if (closest_angle < 91) {
+ player->set_emission_angle(closest_angle);
+ }
+}
+
+void AudioStreamPlayer3DSpatialGizmo::commit_handle(int p_idx, const Variant &p_restore, bool p_cancel) {
+
+ if (p_cancel) {
+
+ player->set_emission_angle(p_restore);
+
+ } else {
+
+ UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo();
+ ur->create_action(TTR("Change AudioStreamPlayer3D Emission Angle"));
+ ur->add_do_method(player, "set_emission_angle", player->get_emission_angle());
+ ur->add_undo_method(player, "set_emission_angle", p_restore);
+ ur->commit_action();
+ }
+}
+
+void AudioStreamPlayer3DSpatialGizmo::redraw() {
+
+ clear();
+
+ if (player->is_emission_angle_enabled()) {
+ float pc = player->get_emission_angle();
+
+ Vector<Vector3> points;
+ points.resize(208);
+
+ float ofs = -Math::cos(Math::deg2rad(pc));
+ float radius = Math::sin(Math::deg2rad(pc));
+
+ for (int i = 0; i < 100; i++) {
+
+ float a = i * 2.0 * Math_PI / 100.0;
+ float an = (i + 1) * 2.0 * Math_PI / 100.0;
+
+ Vector3 from(Math::sin(a) * radius, Math::cos(a) * radius, ofs);
+ Vector3 to(Math::sin(an) * radius, Math::cos(an) * radius, ofs);
+
+ points[i * 2 + 0] = from;
+ points[i * 2 + 1] = to;
+ }
+
+ for (int i = 0; i < 4; i++) {
+
+ float a = i * 2.0 * Math_PI / 4.0;
+
+ Vector3 from(Math::sin(a) * radius, Math::cos(a) * radius, ofs);
+
+ points[200 + i * 2 + 0] = from;
+ points[200 + i * 2 + 1] = Vector3();
+ }
+
+ add_lines(points, SpatialEditorGizmos::singleton->car_wheel_material);
+ add_collision_segments(points);
+
+ Vector<Vector3> handles;
+ float ha = Math::deg2rad(player->get_emission_angle());
+ handles.push_back(Vector3(Math::sin(ha), 0, -Math::cos(ha)));
+ add_handles(handles);
+ }
+
+ add_unscaled_billboard(SpatialEditorGizmos::singleton->sample_player_icon, 0.05);
+}
+
+AudioStreamPlayer3DSpatialGizmo::AudioStreamPlayer3DSpatialGizmo(AudioStreamPlayer3D *p_player) {
+
+ player = p_player;
+ set_spatial_node(p_player);
+}
+
+//////
+
String CameraSpatialGizmo::get_handle_name(int p_idx) const {
if (camera->get_projection() == Camera::PROJECTION_PERSPECTIVE) {
@@ -1279,8 +1400,8 @@ void RoomSpatialGizmo::redraw() {
for (int j = 0; j < 3; j++) {
_EdgeKey ek;
- ek.from = r[i].vertex[j].snapped(CMP_EPSILON);
- ek.to = r[i].vertex[(j + 1) % 3].snapped(CMP_EPSILON);
+ ek.from = r[i].vertex[j].snapped(Vector3(CMP_EPSILON, CMP_EPSILON, CMP_EPSILON));
+ ek.to = r[i].vertex[(j + 1) % 3].snapped(Vector3(CMP_EPSILON, CMP_EPSILON, CMP_EPSILON));
if (ek.from < ek.to)
SWAP(ek.from, ek.to);
@@ -2463,8 +2584,8 @@ void NavigationMeshSpatialGizmo::redraw() {
tw[tidx++] = f.vertex[j];
_EdgeKey ek;
- ek.from = f.vertex[j].snapped(CMP_EPSILON);
- ek.to = f.vertex[(j + 1) % 3].snapped(CMP_EPSILON);
+ ek.from = f.vertex[j].snapped(Vector3(CMP_EPSILON, CMP_EPSILON, CMP_EPSILON));
+ ek.to = f.vertex[(j + 1) % 3].snapped(Vector3(CMP_EPSILON, CMP_EPSILON, CMP_EPSILON));
if (ek.from < ek.to)
SWAP(ek.from, ek.to);
@@ -3101,6 +3222,12 @@ Ref<SpatialEditorGizmo> SpatialEditorGizmos::get_gizmo(Spatial *p_spatial) {
return misg;
}
+ if (p_spatial->cast_to<AudioStreamPlayer3D>()) {
+
+ Ref<AudioStreamPlayer3DSpatialGizmo> misg = memnew(AudioStreamPlayer3DSpatialGizmo(p_spatial->cast_to<AudioStreamPlayer3D>()));
+ return misg;
+ }
+
return Ref<SpatialEditorGizmo>();
}
diff --git a/editor/spatial_editor_gizmos.h b/editor/spatial_editor_gizmos.h
index a8ace87530..469a2d594a 100644
--- a/editor/spatial_editor_gizmos.h
+++ b/editor/spatial_editor_gizmos.h
@@ -31,9 +31,10 @@
#define SPATIAL_EDITOR_GIZMOS_H
#include "editor/plugins/spatial_editor_plugin.h"
-#include "scene/3d/body_shape.h"
+#include "scene/3d/audio_stream_player_3d.h"
#include "scene/3d/camera.h"
#include "scene/3d/collision_polygon.h"
+#include "scene/3d/collision_shape.h"
#include "scene/3d/gi_probe.h"
#include "scene/3d/light.h"
#include "scene/3d/listener.h"
@@ -137,6 +138,22 @@ public:
LightSpatialGizmo(Light *p_light = NULL);
};
+class AudioStreamPlayer3DSpatialGizmo : public EditorSpatialGizmo {
+
+ GDCLASS(AudioStreamPlayer3DSpatialGizmo, EditorSpatialGizmo);
+
+ AudioStreamPlayer3D *player;
+
+public:
+ virtual String get_handle_name(int p_idx) const;
+ virtual Variant get_handle_value(int p_idx) const;
+ virtual void set_handle(int p_idx, Camera *p_camera, const Point2 &p_point);
+ virtual void commit_handle(int p_idx, const Variant &p_restore, bool p_cancel = false);
+
+ void redraw();
+ AudioStreamPlayer3DSpatialGizmo(AudioStreamPlayer3D *p_player = NULL);
+};
+
class CameraSpatialGizmo : public EditorSpatialGizmo {
GDCLASS(CameraSpatialGizmo, EditorSpatialGizmo);
diff --git a/main/input_default.cpp b/main/input_default.cpp
index bde1e84926..3361aa0678 100644
--- a/main/input_default.cpp
+++ b/main/input_default.cpp
@@ -770,6 +770,7 @@ static const char *s_ControllerMappings[] = {
"4e564944494120436f72706f72617469,NVIDIA Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,",
"532e542e442e20496e74657261637420,3dfx InterAct HammerHead FX,leftx:a0,lefty:a1,dpdown:h0.4,rightstick:b25,rightshoulder:b27,rightx:a2,start:b31,righty:a3,dpleft:h0.8,lefttrigger:b28,x:b20,dpup:h0.1,back:b30,leftstick:b22,leftshoulder:b26,y:b21,a:b23,dpright:h0.2,righttrigger:b29,b:b24,",
"506572666f726d616e63652044657369,PDP Rock Candy Wireless Controller for PS3,leftx:a0,lefty:a1,dpdown:h0.4,rightstick:b6,rightshoulder:b18,rightx:a2,start:b16,righty:a3,dpleft:h0.8,lefttrigger:b9,x:b0,dpup:h0.1,back:h0.2,leftstick:b4,leftshoulder:b3,y:b2,a:b1,dpright:h0.2,righttrigger:b10,b:b17,",
+ "4f5559412047616d6520436f6e74726f,OUYA Game Controller,leftx:a0,lefty:a1,dpdown:b9,rightstick:b7,rightshoulder:b5,rightx:a3,start:b16,righty:a4,dpleft:b10,lefttrigger:b12,x:b1,dpup:b8,back:b14,leftstick:b6,leftshoulder:b4,y:b2,a:b0,dpright:b11,righttrigger:b13,b:b3,",
#endif
#ifdef JAVASCRIPT_ENABLED
diff --git a/main/main.cpp b/main/main.cpp
index 218321ef25..8960d85c45 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -31,10 +31,10 @@
#include "app_icon.gen.h"
#include "core/register_core_types.h"
#include "drivers/register_driver_types.h"
-#include "global_config.h"
#include "message_queue.h"
#include "modules/register_module_types.h"
#include "os/os.h"
+#include "project_settings.h"
#include "scene/register_scene_types.h"
#include "script_debugger_local.h"
#include "script_debugger_remote.h"
@@ -74,7 +74,7 @@
#include "translation.h"
#include "version.h"
-static GlobalConfig *globals = NULL;
+static ProjectSettings *globals = NULL;
static Engine *engine = NULL;
static InputMap *input_map = NULL;
static bool _start_success = false;
@@ -205,14 +205,14 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
Thread::_main_thread_id = Thread::get_caller_ID();
- globals = memnew(GlobalConfig);
+ globals = memnew(ProjectSettings);
input_map = memnew(InputMap);
register_core_settings(); //here globals is present
translation_server = memnew(TranslationServer);
performance = memnew(Performance);
- globals->add_singleton(GlobalConfig::Singleton("Performance", performance));
+ globals->add_singleton(ProjectSettings::Singleton("Performance", performance));
MAIN_PRINT("Main: Parse CMDLine");
@@ -529,7 +529,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
if (I->next()) {
- GlobalConfig::get_singleton()->set("editor_scene", game_path = I->next()->get());
+ ProjectSettings::get_singleton()->set("editor_scene", game_path = I->next()->get());
} else {
goto error;
}
@@ -551,7 +551,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
if (I->next()) {
int editor_pid = I->next()->get().to_int();
- GlobalConfig::get_singleton()->set("editor_pid", editor_pid);
+ ProjectSettings::get_singleton()->set("editor_pid", editor_pid);
N = I->next()->next();
} else {
goto error;
@@ -578,9 +578,8 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
I = N;
}
- GLOBAL_DEF("memory/multithread/thread_rid_pool_prealloc", 60);
-
- GLOBAL_DEF("network/debug/max_remote_stdout_chars_per_second", 2048);
+ GLOBAL_DEF("memory/limits/multithreaded_server/rid_pool_prealloc", 60);
+ GLOBAL_DEF("network/limits/debugger_stdout/max_chars_per_second", 2048);
if (debug_mode == "remote") {
@@ -643,7 +642,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
#ifdef TOOLS_ENABLED
if (editor) {
packed_data->set_disabled(true);
- globals->set_disable_platform_override(true);
+ globals->set_disable_feature_overrides(true);
StreamPeerSSL::initialize_certs = false; //will be initialized by editor
}
@@ -666,10 +665,10 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
use_custom_res = false;
}
- if (bool(GlobalConfig::get_singleton()->get("application/disable_stdout"))) {
+ if (bool(ProjectSettings::get_singleton()->get("application/run/disable_stdout"))) {
quiet_stdout = true;
}
- if (bool(GlobalConfig::get_singleton()->get("application/disable_stderr"))) {
+ if (bool(ProjectSettings::get_singleton()->get("application/run/disable_stderr"))) {
_print_error_enabled = false;
};
@@ -680,7 +679,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
#ifdef TOOLS_ENABLED
- if (main_args.size() == 0 && (!GlobalConfig::get_singleton()->has("application/main_loop_type")) && (!GlobalConfig::get_singleton()->has("application/main_scene") || String(GlobalConfig::get_singleton()->get("application/main_scene")) == ""))
+ if (main_args.size() == 0 && (!ProjectSettings::get_singleton()->has("application/run/main_loop_type")) && (!ProjectSettings::get_singleton()->has("application/run/main_scene") || String(ProjectSettings::get_singleton()->get("application/run/main_scene")) == ""))
use_custom_res = false; //project manager (run without arguments)
#endif
@@ -690,43 +689,46 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
else
input_map->load_from_globals(); //keys for game
- if (video_driver == "") // specified in project.godot
- video_driver = GLOBAL_DEF("display/driver/name", Variant((const char *)OS::get_singleton()->get_video_driver_name(0)));
+ //if (video_driver == "") // useless for now, so removing
+ // video_driver = GLOBAL_DEF("display/driver/name", Variant((const char *)OS::get_singleton()->get_video_driver_name(0)));
- if (!force_res && use_custom_res && globals->has("display/window/width"))
- video_mode.width = globals->get("display/window/width");
- if (!force_res && use_custom_res && globals->has("display/window/height"))
- video_mode.height = globals->get("display/window/height");
- if (!editor && ((globals->has("display/window/allow_hidpi") && !globals->get("display/window/allow_hidpi")) || force_lowdpi)) {
+ if (!force_res && use_custom_res && globals->has("display/window/size/width"))
+ video_mode.width = globals->get("display/window/size/width");
+ if (!force_res && use_custom_res && globals->has("display/window/size/height"))
+ video_mode.height = globals->get("display/window/size/height");
+ if (!editor && ((globals->has("display/window/dpi/allow_hidpi") && !globals->get("display/window/dpi/allow_hidpi")) || force_lowdpi)) {
OS::get_singleton()->_allow_hidpi = false;
}
- if (use_custom_res && globals->has("display/window/fullscreen"))
- video_mode.fullscreen = globals->get("display/window/fullscreen");
- if (use_custom_res && globals->has("display/window/resizable"))
- video_mode.resizable = globals->get("display/window/resizable");
- if (use_custom_res && globals->has("display/window/borderless"))
- video_mode.borderless_window = globals->get("display/window/borderless");
-
- if (!force_res && use_custom_res && globals->has("display/window/test_width") && globals->has("display/window/test_height")) {
- int tw = globals->get("display/window/test_width");
- int th = globals->get("display/window/test_height");
+ if (use_custom_res && globals->has("display/window/size/fullscreen"))
+ video_mode.fullscreen = globals->get("display/window/size/fullscreen");
+ if (use_custom_res && globals->has("display/window/size/resizable"))
+ video_mode.resizable = globals->get("display/window/size/resizable");
+ if (use_custom_res && globals->has("display/window/size/borderless"))
+ video_mode.borderless_window = globals->get("display/window/size/borderless");
+
+ if (!force_res && use_custom_res && globals->has("display/window/size/test_width") && globals->has("display/window/size/test_height")) {
+ int tw = globals->get("display/window/size/test_width");
+ int th = globals->get("display/window/size/test_height");
if (tw > 0 && th > 0) {
video_mode.width = tw;
video_mode.height = th;
}
}
- GLOBAL_DEF("display/window/width", video_mode.width);
- GLOBAL_DEF("display/window/height", video_mode.height);
- GLOBAL_DEF("display/window/allow_hidpi", false);
- GLOBAL_DEF("display/window/fullscreen", video_mode.fullscreen);
- GLOBAL_DEF("display/window/resizable", video_mode.resizable);
- GLOBAL_DEF("display/window/borderless", video_mode.borderless_window);
- use_vsync = GLOBAL_DEF("display/window/use_vsync", use_vsync);
- GLOBAL_DEF("display/window/test_width", 0);
- GLOBAL_DEF("display/window/test_height", 0);
- Engine::get_singleton()->_pixel_snap = GLOBAL_DEF("rendering/2d/use_pixel_snap", false);
- OS::get_singleton()->_keep_screen_on = GLOBAL_DEF("display/energy_saving/keep_screen_on", true);
+ GLOBAL_DEF("display/window/size/width", video_mode.width);
+ GLOBAL_DEF("display/window/size/height", video_mode.height);
+ GLOBAL_DEF("display/window/dpi/allow_hidpi", false);
+ GLOBAL_DEF("display/window/size/fullscreen", video_mode.fullscreen);
+ GLOBAL_DEF("display/window/size/resizable", video_mode.resizable);
+ GLOBAL_DEF("display/window/size/borderless", video_mode.borderless_window);
+ use_vsync = GLOBAL_DEF("display/window/vsync/use_vsync", use_vsync);
+ GLOBAL_DEF("display/window/size/test_width", 0);
+ GLOBAL_DEF("display/window/size/test_height", 0);
+ GLOBAL_DEF("rendering/quality/intended_usage/framebuffer_allocation", 2);
+ GLOBAL_DEF("rendering/quality/intended_usage/framebuffer_allocation.mobile", 3);
+
+ Engine::get_singleton()->_pixel_snap = GLOBAL_DEF("rendering/quality/2d/use_pixel_snap", false);
+ OS::get_singleton()->_keep_screen_on = GLOBAL_DEF("display/window/energy_saving/keep_screen_on", true);
if (rtm == -1) {
rtm = GLOBAL_DEF("rendering/threads/thread_model", OS::RENDER_THREAD_SAFE);
if (rtm >= 1) //hack for now
@@ -757,7 +759,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
if (video_driver_idx < 0) {
- OS::get_singleton()->alert("Invalid Video Driver: " + video_driver);
+ //OS::get_singleton()->alert("Invalid Video Driver: " + video_driver);
video_driver_idx = 0;
//goto error;
}
@@ -779,7 +781,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
}
{
- String orientation = GLOBAL_DEF("display/handheld/orientation", "landscape");
+ String orientation = GLOBAL_DEF("display/window/handheld/orientation", "landscape");
if (orientation == "portrait")
OS::get_singleton()->set_screen_orientation(OS::SCREEN_PORTRAIT);
@@ -798,22 +800,22 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
}
Engine::get_singleton()->set_iterations_per_second(GLOBAL_DEF("physics/common/fixed_fps", 60));
- Engine::get_singleton()->set_target_fps(GLOBAL_DEF("debug/fps/force_fps", 0));
+ Engine::get_singleton()->set_target_fps(GLOBAL_DEF("debug/settings/fps/force_fps", 0));
- GLOBAL_DEF("debug/stdout/print_fps", OS::get_singleton()->is_stdout_verbose());
+ GLOBAL_DEF("debug/settings/stdout/print_fps", OS::get_singleton()->is_stdout_verbose());
if (!OS::get_singleton()->_verbose_stdout) //overrided
- OS::get_singleton()->_verbose_stdout = GLOBAL_DEF("debug/stdout/verbose_stdout", false);
+ OS::get_singleton()->_verbose_stdout = GLOBAL_DEF("debug/settings/stdout/verbose_stdout", false);
if (frame_delay == 0) {
- frame_delay = GLOBAL_DEF("application/frame_delay_msec", 0);
+ frame_delay = GLOBAL_DEF("application/run/frame_delay_msec", 0);
}
Engine::get_singleton()->set_frame_delay(frame_delay);
message_queue = memnew(MessageQueue);
- GlobalConfig::get_singleton()->register_global_defaults();
+ ProjectSettings::get_singleton()->register_global_defaults();
if (p_second_phase)
return setup2();
@@ -908,13 +910,13 @@ Error Main::setup2() {
MAIN_PRINT("Main: Load Remaps");
- Color clear = GLOBAL_DEF("rendering/viewport/default_clear_color", Color(0.3, 0.3, 0.3));
+ Color clear = GLOBAL_DEF("rendering/environment/default_clear_color", Color(0.3, 0.3, 0.3));
VisualServer::get_singleton()->set_default_clear_color(clear);
if (show_logo) { //boot logo!
- String boot_logo_path = GLOBAL_DEF("application/boot_splash", String());
- bool boot_logo_scale = GLOBAL_DEF("application/boot_splash_fullsize", true);
- GlobalConfig::get_singleton()->set_custom_property_info("application/boot_splash", PropertyInfo(Variant::STRING, "application/boot_splash", PROPERTY_HINT_FILE, "*.png"));
+ String boot_logo_path = GLOBAL_DEF("application/boot_splash/image", String());
+ bool boot_logo_scale = GLOBAL_DEF("application/boot_splash/fullsize", true);
+ ProjectSettings::get_singleton()->set_custom_property_info("application/boot_splash/image", PropertyInfo(Variant::STRING, "application/boot_splash/image", PROPERTY_HINT_FILE, "*.png"));
Ref<Image> boot_logo;
@@ -930,11 +932,11 @@ Error Main::setup2() {
if (boot_logo.is_valid()) {
OS::get_singleton()->_msec_splash = OS::get_singleton()->get_ticks_msec();
- Color boot_bg = GLOBAL_DEF("application/boot_bg_color", clear);
+ Color boot_bg = GLOBAL_DEF("application/boot_splash/bg_color", clear);
VisualServer::get_singleton()->set_boot_image(boot_logo, boot_bg, boot_logo_scale);
#ifndef TOOLS_ENABLED
//no tools, so free the boot logo (no longer needed)
-//GlobalConfig::get_singleton()->set("application/boot_logo",Image());
+//ProjectSettings::get_singleton()->set("application/boot_logo",Image());
#endif
} else {
@@ -955,13 +957,13 @@ Error Main::setup2() {
}
MAIN_PRINT("Main: DCC");
- VisualServer::get_singleton()->set_default_clear_color(GLOBAL_DEF("rendering/viewport/default_clear_color", Color(0.3, 0.3, 0.3)));
+ VisualServer::get_singleton()->set_default_clear_color(GLOBAL_DEF("rendering/environment/default_clear_color", Color(0.3, 0.3, 0.3)));
MAIN_PRINT("Main: END");
- GLOBAL_DEF("application/icon", String());
- GlobalConfig::get_singleton()->set_custom_property_info("application/icon", PropertyInfo(Variant::STRING, "application/icon", PROPERTY_HINT_FILE, "*.png,*.webp"));
+ GLOBAL_DEF("application/config/icon", String());
+ ProjectSettings::get_singleton()->set_custom_property_info("application/config/icon", PropertyInfo(Variant::STRING, "application/config/icon", PROPERTY_HINT_FILE, "*.png,*.webp"));
- if (bool(GLOBAL_DEF("display/handheld/emulate_touchscreen", false))) {
+ if (bool(GLOBAL_DEF("display/window/handheld/emulate_touchscreen", false))) {
if (!OS::get_singleton()->has_touchscreen_ui_hint() && Input::get_singleton() && !editor) {
//only if no touchscreen ui hint, set emulation
InputDefault *id = Input::get_singleton()->cast_to<InputDefault>();
@@ -978,15 +980,15 @@ Error Main::setup2() {
GLOBAL_DEF("display/mouse_cursor/custom_image", String());
GLOBAL_DEF("display/mouse_cursor/custom_image_hotspot", Vector2());
- GlobalConfig::get_singleton()->set_custom_property_info("display/mouse_cursor/custom_image", PropertyInfo(Variant::STRING, "display/mouse_cursor/custom_image", PROPERTY_HINT_FILE, "*.png,*.webp"));
+ ProjectSettings::get_singleton()->set_custom_property_info("display/mouse_cursor/custom_image", PropertyInfo(Variant::STRING, "display/mouse_cursor/custom_image", PROPERTY_HINT_FILE, "*.png,*.webp"));
- if (String(GlobalConfig::get_singleton()->get("display/mouse_cursor/custom_image")) != String()) {
+ if (String(ProjectSettings::get_singleton()->get("display/mouse_cursor/custom_image")) != String()) {
//print_line("use custom cursor");
- Ref<Texture> cursor = ResourceLoader::load(GlobalConfig::get_singleton()->get("display/mouse_cursor/custom_image"));
+ Ref<Texture> cursor = ResourceLoader::load(ProjectSettings::get_singleton()->get("display/mouse_cursor/custom_image"));
if (cursor.is_valid()) {
//print_line("loaded ok");
- Vector2 hotspot = GlobalConfig::get_singleton()->get("display/mouse_cursor/custom_image_hotspot");
+ Vector2 hotspot = ProjectSettings::get_singleton()->get("display/mouse_cursor/custom_image_hotspot");
Input::get_singleton()->set_custom_mouse_cursor(cursor, hotspot);
}
}
@@ -1145,8 +1147,8 @@ bool Main::start() {
}
}
- if (script == "" && game_path == "" && String(GLOBAL_DEF("application/main_scene", "")) != "") {
- game_path = GLOBAL_DEF("application/main_scene", "");
+ if (script == "" && game_path == "" && String(GLOBAL_DEF("application/run/main_scene", "")) != "") {
+ game_path = GLOBAL_DEF("application/run/main_scene", "");
}
MainLoop *main_loop = NULL;
@@ -1189,7 +1191,7 @@ bool Main::start() {
}
} else {
- main_loop_type = GLOBAL_DEF("application/main_loop_type", "");
+ main_loop_type = GLOBAL_DEF("application/run/main_loop_type", "");
}
if (!main_loop && main_loop_type == "")
@@ -1249,12 +1251,16 @@ bool Main::start() {
}
#endif
+ {
+ }
+
if (!editor) {
//standard helpers that can be changed from main config
- String stretch_mode = GLOBAL_DEF("display/stretch/mode", "disabled");
- String stretch_aspect = GLOBAL_DEF("display/stretch/aspect", "ignore");
- Size2i stretch_size = Size2(GLOBAL_DEF("display/window/width", 0), GLOBAL_DEF("display/window/height", 0));
+ 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);
SceneTree::StretchMode sml_sm = SceneTree::STRETCH_MODE_DISABLED;
if (stretch_mode == "2d")
@@ -1270,45 +1276,37 @@ bool Main::start() {
else if (stretch_aspect == "keep_height")
sml_aspect = SceneTree::STRETCH_ASPECT_KEEP_HEIGHT;
- sml->set_screen_stretch(sml_sm, sml_aspect, stretch_size);
+ sml->set_screen_stretch(sml_sm, sml_aspect, stretch_size, stretch_shrink);
- sml->set_auto_accept_quit(GLOBAL_DEF("application/auto_accept_quit", true));
- sml->set_quit_on_go_back(GLOBAL_DEF("application/quit_on_go_back", true));
- String appname = GlobalConfig::get_singleton()->get("application/name");
+ sml->set_auto_accept_quit(GLOBAL_DEF("application/config/auto_accept_quit", true));
+ sml->set_quit_on_go_back(GLOBAL_DEF("application/config/quit_on_go_back", true));
+ String appname = ProjectSettings::get_singleton()->get("application/config/name");
appname = TranslationServer::get_singleton()->translate(appname);
OS::get_singleton()->set_window_title(appname);
- int shadow_atlas_size = GLOBAL_DEF("rendering/shadow_atlas/size", 2048);
- int shadow_atlas_q0_subdiv = GLOBAL_DEF("rendering/shadow_atlas/quadrant_0_subdiv", 2);
- int shadow_atlas_q1_subdiv = GLOBAL_DEF("rendering/shadow_atlas/quadrant_1_subdiv", 2);
- int shadow_atlas_q2_subdiv = GLOBAL_DEF("rendering/shadow_atlas/quadrant_2_subdiv", 3);
- int shadow_atlas_q3_subdiv = GLOBAL_DEF("rendering/shadow_atlas/quadrant_3_subdiv", 4);
+ int shadow_atlas_size = GLOBAL_GET("rendering/quality/shadow_atlas/size");
+ int shadow_atlas_q0_subdiv = GLOBAL_GET("rendering/quality/shadow_atlas/quadrant_0_subdiv");
+ int shadow_atlas_q1_subdiv = GLOBAL_GET("rendering/quality/shadow_atlas/quadrant_1_subdiv");
+ int shadow_atlas_q2_subdiv = GLOBAL_GET("rendering/quality/shadow_atlas/quadrant_2_subdiv");
+ int shadow_atlas_q3_subdiv = GLOBAL_GET("rendering/quality/shadow_atlas/quadrant_3_subdiv");
sml->get_root()->set_shadow_atlas_size(shadow_atlas_size);
sml->get_root()->set_shadow_atlas_quadrant_subdiv(0, Viewport::ShadowAtlasQuadrantSubdiv(shadow_atlas_q0_subdiv));
sml->get_root()->set_shadow_atlas_quadrant_subdiv(1, Viewport::ShadowAtlasQuadrantSubdiv(shadow_atlas_q1_subdiv));
sml->get_root()->set_shadow_atlas_quadrant_subdiv(2, Viewport::ShadowAtlasQuadrantSubdiv(shadow_atlas_q2_subdiv));
sml->get_root()->set_shadow_atlas_quadrant_subdiv(3, Viewport::ShadowAtlasQuadrantSubdiv(shadow_atlas_q3_subdiv));
+ Viewport::Usage usage = Viewport::Usage(int(GLOBAL_GET("rendering/quality/intended_usage/framebuffer_allocation")));
+ sml->get_root()->set_usage(usage);
} else {
- GLOBAL_DEF("display/stretch/mode", "disabled");
- GlobalConfig::get_singleton()->set_custom_property_info("display/stretch/mode", PropertyInfo(Variant::STRING, "display/stretch/mode", PROPERTY_HINT_ENUM, "disabled,2d,viewport"));
- GLOBAL_DEF("display/stretch/aspect", "ignore");
- GlobalConfig::get_singleton()->set_custom_property_info("display/stretch/aspect", PropertyInfo(Variant::STRING, "display/stretch/aspect", PROPERTY_HINT_ENUM, "ignore,keep,keep_width,keep_height"));
- sml->set_auto_accept_quit(GLOBAL_DEF("application/auto_accept_quit", true));
- sml->set_quit_on_go_back(GLOBAL_DEF("application/quit_on_go_back", true));
-
- GLOBAL_DEF("rendering/shadow_atlas/size", 2048);
- GlobalConfig::get_singleton()->set_custom_property_info("rendering/shadow_atlas/size", PropertyInfo(Variant::INT, "rendering/shadow_atlas/size", PROPERTY_HINT_RANGE, "256,16384"));
-
- GLOBAL_DEF("rendering/shadow_atlas/quadrant_0_subdiv", 2);
- GLOBAL_DEF("rendering/shadow_atlas/quadrant_1_subdiv", 2);
- GLOBAL_DEF("rendering/shadow_atlas/quadrant_2_subdiv", 3);
- GLOBAL_DEF("rendering/shadow_atlas/quadrant_3_subdiv", 4);
- GlobalConfig::get_singleton()->set_custom_property_info("rendering/shadow_atlas/quadrant_0_subdiv", PropertyInfo(Variant::INT, "rendering/shadow_atlas/quadrant_0_subdiv", PROPERTY_HINT_ENUM, "Disabled,1 Shadow,4 Shadows,16 Shadows,64 Shadows,256 Shadows,1024 Shadows"));
- GlobalConfig::get_singleton()->set_custom_property_info("rendering/shadow_atlas/quadrant_1_subdiv", PropertyInfo(Variant::INT, "rendering/shadow_atlas/quadrant_1_subdiv", PROPERTY_HINT_ENUM, "Disabled,1 Shadow,4 Shadows,16 Shadows,64 Shadows,256 Shadows,1024 Shadows"));
- GlobalConfig::get_singleton()->set_custom_property_info("rendering/shadow_atlas/quadrant_2_subdiv", PropertyInfo(Variant::INT, "rendering/shadow_atlas/quadrant_2_subdiv", PROPERTY_HINT_ENUM, "Disabled,1 Shadow,4 Shadows,16 Shadows,64 Shadows,256 Shadows,1024 Shadows"));
- GlobalConfig::get_singleton()->set_custom_property_info("rendering/shadow_atlas/quadrant_3_subdiv", PropertyInfo(Variant::INT, "rendering/shadow_atlas/quadrant_3_subdiv", PROPERTY_HINT_ENUM, "Disabled,1 Shadow,4 Shadows,16 Shadows,64 Shadows,256 Shadows,1024 Shadows"));
+ GLOBAL_DEF("display/window/stretch/mode", "disabled");
+ ProjectSettings::get_singleton()->set_custom_property_info("display/window/stretch/mode", PropertyInfo(Variant::STRING, "display/window/stretch/mode", PROPERTY_HINT_ENUM, "disabled,2d,viewport"));
+ GLOBAL_DEF("display/window/stretch/aspect", "ignore");
+ ProjectSettings::get_singleton()->set_custom_property_info("display/window/stretch/aspect", PropertyInfo(Variant::STRING, "display/window/stretch/aspect", PROPERTY_HINT_ENUM, "ignore,keep,keep_width,keep_height"));
+ GLOBAL_DEF("display/window/stretch/shrink", 1);
+ ProjectSettings::get_singleton()->set_custom_property_info("display/window/stretch/shrink", PropertyInfo(Variant::STRING, "display/window/stretch/shrink", PROPERTY_HINT_RANGE, "1,8,1"));
+ sml->set_auto_accept_quit(GLOBAL_DEF("application/config/auto_accept_quit", true));
+ sml->set_quit_on_go_back(GLOBAL_DEF("application/config/quit_on_go_back", true));
}
String local_game_path;
@@ -1321,7 +1319,7 @@ bool Main::start() {
if (!absolute) {
- if (GlobalConfig::get_singleton()->is_using_datapack()) {
+ if (ProjectSettings::get_singleton()->is_using_datapack()) {
local_game_path = "res://" + local_game_path;
@@ -1344,7 +1342,7 @@ bool Main::start() {
}
}
- local_game_path = GlobalConfig::get_singleton()->localize_path(local_game_path);
+ local_game_path = ProjectSettings::get_singleton()->localize_path(local_game_path);
#ifdef TOOLS_ENABLED
if (editor) {
@@ -1370,7 +1368,7 @@ bool Main::start() {
if (game_path != "" || script != "") {
//autoload
List<PropertyInfo> props;
- GlobalConfig::get_singleton()->get_property_list(&props);
+ ProjectSettings::get_singleton()->get_property_list(&props);
//first pass, add the constants so they exist before any script is loaded
for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) {
@@ -1379,7 +1377,7 @@ bool Main::start() {
if (!s.begins_with("autoload/"))
continue;
String name = s.get_slicec('/', 1);
- String path = GlobalConfig::get_singleton()->get(s);
+ String path = ProjectSettings::get_singleton()->get(s);
bool global_var = false;
if (path.begins_with("*")) {
global_var = true;
@@ -1400,7 +1398,7 @@ bool Main::start() {
if (!s.begins_with("autoload/"))
continue;
String name = s.get_slicec('/', 1);
- String path = GlobalConfig::get_singleton()->get(s);
+ String path = ProjectSettings::get_singleton()->get(s);
bool global_var = false;
if (path.begins_with("*")) {
global_var = true;
@@ -1463,7 +1461,7 @@ bool Main::start() {
//sml->get_root()->add_child(scene);
sml->add_current_scene(scene);
- String iconpath = GLOBAL_DEF("application/icon", "Variant()");
+ String iconpath = GLOBAL_DEF("application/config/icon", "Variant()");
if (iconpath != "") {
Ref<Image> icon;
if (icon->load(iconpath) == OK)
@@ -1525,11 +1523,15 @@ static uint64_t idle_process_max = 0;
bool Main::iteration() {
uint64_t ticks = OS::get_singleton()->get_ticks_usec();
+ Engine::get_singleton()->_frame_ticks = ticks;
+
uint64_t ticks_elapsed = ticks - last_ticks;
double step = (double)ticks_elapsed / 1000000.0;
float frame_slice = 1.0 / Engine::get_singleton()->get_iterations_per_second();
+ Engine::get_singleton()->_frame_step = step;
+
/*
if (time_accum+step < frame_slice)
return false;
@@ -1637,7 +1639,7 @@ bool Main::iteration() {
if (frame > 1000000) {
- if (GLOBAL_DEF("debug/stdout/print_fps", OS::get_singleton()->is_stdout_verbose())) {
+ if (GLOBAL_DEF("debug/settings/stdout/print_fps", OS::get_singleton()->is_stdout_verbose())) {
print_line("FPS: " + itos(frames));
};
@@ -1695,14 +1697,16 @@ void Main::cleanup() {
OS::get_singleton()->_execpath = "";
OS::get_singleton()->_local_clipboard = "";
- if (audio_server) {
- memdelete(audio_server);
- }
+ ScriptServer::finish_languages();
#ifdef TOOLS_ENABLED
EditorNode::unregister_editor_types();
#endif
+ if (audio_server) {
+ memdelete(audio_server);
+ }
+
unregister_driver_types();
unregister_module_types();
unregister_scene_types();
diff --git a/main/tests/test_io.cpp b/main/tests/test_io.cpp
index 6986576081..f7c49c9249 100644
--- a/main/tests/test_io.cpp
+++ b/main/tests/test_io.cpp
@@ -31,7 +31,7 @@
#ifdef MINIZIP_ENABLED
-#include "core/global_config.h"
+#include "core/project_settings.h"
#include "io/resource_loader.h"
#include "io/resource_saver.h"
#include "os/dir_access.h"
@@ -91,10 +91,10 @@ MainLoop *test() {
ResourceSaver::save("test_data/rock.xml", texture);
print_line("localize paths");
- print_line(GlobalConfig::get_singleton()->localize_path("algo.xml"));
- print_line(GlobalConfig::get_singleton()->localize_path("c:\\windows\\algo.xml"));
- print_line(GlobalConfig::get_singleton()->localize_path(GlobalConfig::get_singleton()->get_resource_path() + "/something/something.xml"));
- print_line(GlobalConfig::get_singleton()->localize_path("somedir/algo.xml"));
+ print_line(ProjectSettings::get_singleton()->localize_path("algo.xml"));
+ print_line(ProjectSettings::get_singleton()->localize_path("c:\\windows\\algo.xml"));
+ print_line(ProjectSettings::get_singleton()->localize_path(ProjectSettings::get_singleton()->get_resource_path() + "/something/something.xml"));
+ print_line(ProjectSettings::get_singleton()->localize_path("somedir/algo.xml"));
{
diff --git a/methods.py b/methods.py
index 4d3d5ae343..abd87c07d7 100644
--- a/methods.py
+++ b/methods.py
@@ -1176,6 +1176,20 @@ def update_version():
f.write("#define VERSION_STATUS " + str(version.status) + "\n")
import datetime
f.write("#define VERSION_YEAR " + str(datetime.datetime.now().year) + "\n")
+ f.close()
+
+ fhash = open("core/version_hash.gen.h", "wb")
+ githash = ""
+ if os.path.isfile(".git/HEAD"):
+ head = open(".git/HEAD", "rb").readline().strip()
+ if head.startswith("ref: "):
+ head = ".git/" + head[5:]
+ if os.path.isfile(head):
+ githash = open(head, "rb").readline().strip()
+ else:
+ githash = head
+ fhash.write("#define VERSION_HASH \"" + githash + "\"")
+ fhash.close()
def parse_cg_file(fname, uniforms, sizes, conditionals):
diff --git a/misc/scripts/svgs_2_pngs.py b/misc/scripts/svgs_2_pngs.py
index b24324dcd7..ff6d6d851f 100644
--- a/misc/scripts/svgs_2_pngs.py
+++ b/misc/scripts/svgs_2_pngs.py
@@ -16,7 +16,7 @@ last_svg_data = None
SCRIPT_FOLDER = dirname(realpath(__file__)) + '/'
theme_dir_base = SCRIPT_FOLDER + '../../scene/resources/default_theme/'
theme_dir_source = theme_dir_base + 'source/'
-icons_dir_base = SCRIPT_FOLDER + '../editor/icons/'
+icons_dir_base = SCRIPT_FOLDER + '../../editor/icons/'
icons_dir_2x = icons_dir_base + '2x/'
icons_dir_source = icons_dir_base + 'source/'
@@ -108,8 +108,10 @@ special_icons = {
theme_output_names=['icon_reload']
),
'icon_multi_edit': dict(output_names=['icon_multi_node_edit']),
+ 'icon_load': dict(
+ output_names=['icon_open']
+ ),
'icon_folder': dict(
- output_names=['icon_load', 'icon_open'],
theme_output_names=['icon_folder']
),
'icon_file_list': dict(output_names=['icon_enum']),
diff --git a/modules/etc/config.py b/modules/etc/config.py
index fb920482f5..4b0b01b78e 100644
--- a/modules/etc/config.py
+++ b/modules/etc/config.py
@@ -4,4 +4,8 @@ def can_build(platform):
def configure(env):
- pass
+ # Tools only, disabled for non-tools
+ # TODO: Find a cleaner way to achieve that
+ if (env["tools"] == "no"):
+ env["module_etc_enabled"] = "no"
+ env.disabled_modules.append("etc")
diff --git a/modules/etc/image_etc.cpp b/modules/etc/image_etc.cpp
index d9daffc59e..353bd1274a 100644
--- a/modules/etc/image_etc.cpp
+++ b/modules/etc/image_etc.cpp
@@ -153,6 +153,9 @@ static void _compress_etc(Image *p_img, float p_lossy_quality, bool force_etc1_f
Etc::Image::Format etc2comp_etc_format = _image_format_to_etc2comp_format(etc_format);
int wofs = 0;
+
+ print_line("begin encoding, format: " + Image::get_format_name(etc_format));
+ uint64_t t = OS::get_singleton()->get_ticks_msec();
for (int i = 0; i < mmc + 1; i++) {
// convert source image to internal etc2comp format (which is equivalent to Image::FORMAT_RGBAF)
// NOTE: We can alternatively add a case to Image::convert to handle Image::FORMAT_RGBAF conversion.
@@ -177,6 +180,7 @@ static void _compress_etc(Image *p_img, float p_lossy_quality, bool force_etc1_f
delete[] etc_data;
delete[] src_rgba_f;
}
+ print_line("time encoding: " + rtos(OS::get_singleton()->get_ticks_msec() - t));
p_img->create(imgw, imgh, mmc > 1 ? true : false, etc_format, dst_data);
}
diff --git a/modules/gdnative/gdnative.cpp b/modules/gdnative/gdnative.cpp
index dad9a54df6..158f7fd94d 100644
--- a/modules/gdnative/gdnative.cpp
+++ b/modules/gdnative/gdnative.cpp
@@ -29,732 +29,70 @@
/*************************************************************************/
#include "gdnative.h"
-#include "global_config.h"
#include "global_constants.h"
#include "io/file_access_encrypted.h"
#include "os/file_access.h"
#include "os/os.h"
+#include "project_settings.h"
#include "scene/main/scene_tree.h"
-#include "scene/resources/scene_format_text.h"
-#if defined(TOOLS_ENABLED) && defined(DEBUG_METHODS_ENABLED)
-#include "api_generator.h"
-#endif
-
-#ifdef TOOLS_ENABLED
-#include "editor/editor_node.h"
-#endif
-
-Error NativeLibrary::initialize(NativeLibrary *&p_native_lib, const StringName p_path) {
-
- if (GDNativeScriptLanguage::get_singleton()->initialized_libraries.has(p_path)) {
- p_native_lib = GDNativeScriptLanguage::get_singleton()->initialized_libraries[p_path];
- return OK;
- }
-
- NativeLibrary *lib = memnew(NativeLibrary);
- lib->path = p_path;
-
- p_native_lib = lib;
-
- // Open the file
-
- Error error;
- error = OS::get_singleton()->open_dynamic_library(p_path, lib->handle);
- if (error) return error;
- ERR_FAIL_COND_V(!lib->handle, ERR_BUG);
-
- // Get the method
-
- void *library_init;
- error = OS::get_singleton()->get_dynamic_library_symbol_handle(lib->handle, GDNativeScriptLanguage::get_init_symbol_name(), library_init);
- if (error) return error;
- ERR_FAIL_COND_V(!library_init, ERR_BUG);
-
- void (*library_init_fpointer)(godot_native_init_options *) = (void (*)(godot_native_init_options *))library_init;
-
- godot_native_init_options options;
-
- options.in_editor = SceneTree::get_singleton()->is_editor_hint();
- options.core_api_hash = ClassDB::get_api_hash(ClassDB::API_CORE);
- options.editor_api_hash = ClassDB::get_api_hash(ClassDB::API_EDITOR);
- options.no_api_hash = ClassDB::get_api_hash(ClassDB::API_NONE);
-
- library_init_fpointer(&options); // Catch errors?
-
- GDNativeScriptLanguage::get_singleton()->initialized_libraries[p_path] = lib;
-
- return OK;
-}
-
-Error NativeLibrary::terminate(NativeLibrary *&p_native_lib) {
-
- if (!GDNativeScriptLanguage::get_singleton()->initialized_libraries.has(p_native_lib->path)) {
- OS::get_singleton()->close_dynamic_library(p_native_lib->handle);
- p_native_lib->handle = 0;
- return OK;
- }
-
- Error error = OK;
- void *library_terminate;
- error = OS::get_singleton()->get_dynamic_library_symbol_handle(p_native_lib->handle, GDNativeScriptLanguage::get_terminate_symbol_name(), library_terminate);
- if (!error) {
-
- void (*library_terminate_pointer)(godot_native_terminate_options *) = (void (*)(godot_native_terminate_options *))library_terminate;
-
- godot_native_terminate_options options;
- options.in_editor = SceneTree::get_singleton()->is_editor_hint();
-
- library_terminate_pointer(&options);
- }
-
- GDNativeScriptLanguage::get_singleton()->initialized_libraries.erase(p_native_lib->path);
-
- OS::get_singleton()->close_dynamic_library(p_native_lib->handle);
- p_native_lib->handle = 0;
-
- return OK;
-}
-
-// Script
-#ifdef TOOLS_ENABLED
-
-void GDNativeScript::_update_placeholder(PlaceHolderScriptInstance *p_placeholder) {
- ERR_FAIL_COND(!script_data);
-
- List<PropertyInfo> pinfo;
- Map<StringName, Variant> values;
-
- for (Map<StringName, GDNativeScriptData::Property>::Element *E = script_data->properties.front(); E; E = E->next()) {
- PropertyInfo p = E->get().info;
- p.name = String(E->key());
- pinfo.push_back(p);
- values[p.name] = E->get().default_value;
- }
-
- p_placeholder->update(pinfo, values);
-}
-
-void GDNativeScript::_placeholder_erased(PlaceHolderScriptInstance *p_placeholder) {
-
- placeholders.erase(p_placeholder);
-}
-
-#endif
-
-bool GDNativeScript::can_instance() const {
-#ifdef TOOLS_ENABLED
- return script_data || (!is_tool() && !ScriptServer::is_scripting_enabled());
-#else
- // allow defaultlibrary without editor features
- if (!library.is_valid()) {
- String path = GLOBAL_GET("gdnative/default_gdnativelibrary");
-
- RES lib = ResourceLoader::load(path);
-
- if (lib.is_valid() && lib->cast_to<GDNativeLibrary>()) {
- return true;
- }
- }
+const String init_symbol = "godot_gdnative_init";
+const String terminate_symbol = "godot_gdnative_terminate";
- return script_data;
-#endif
- //return script_data || (!tool && !ScriptServer::is_scripting_enabled());
- // change to true enable in editor stuff.
-}
-
-Ref<Script> GDNativeScript::get_base_script() const {
- Ref<GDNativeScript> base_script;
- base_script->library = library;
- base_script->script_data = script_data;
- base_script->script_name = script_data->base;
- return base_script;
-}
-
-StringName GDNativeScript::get_instance_base_type() const {
- return script_data->base_native_type;
-}
-
-ScriptInstance *GDNativeScript::instance_create(Object *p_this) {
-
-#ifdef TOOLS_ENABLED
-
- // find a good way to initialize stuff in the editor
- if (!ScriptServer::is_scripting_enabled() && !is_tool()) {
- // placeholder, for nodes. But for tools we want the real thing
-
- PlaceHolderScriptInstance *sins = memnew(PlaceHolderScriptInstance(GDNativeScriptLanguage::singleton, Ref<Script>((Script *)this), p_this));
- placeholders.insert(sins);
-
- if (!library.is_valid())
- return sins;
-
- if (!library->native_library) {
- Error err = library->_initialize();
- if (err != OK) {
- return sins;
- }
- }
-
- if (!script_data) {
- script_data = library->get_script_data(script_name);
- }
- if (script_data && script_data->create_func.create_func) {
- script_data->create_func.create_func((godot_object *)p_this, script_data->create_func.method_data);
- }
-
- _update_placeholder(sins);
-
- return sins;
- }
-
-#endif
+String GDNativeLibrary::platform_names[NUM_PLATFORMS] = {
+ "X11_32bit",
+ "X11_64bit",
+ "Windows_32bit",
+ "Windows_64bit",
+ "OSX",
- if (!library.is_valid()) {
- String path = GLOBAL_GET("gdnative/default_gdnativelibrary");
+ "Android",
+ "iOS",
- RES lib = ResourceLoader::load(path);
-
- if (lib.is_valid() && lib->cast_to<GDNativeLibrary>()) {
- set_library(lib);
- }
- }
+ "WebAssembly"
+};
+String GDNativeLibrary::platform_lib_ext[NUM_PLATFORMS] = {
+ "so",
+ "so",
+ "dll",
+ "dll",
+ "dylib",
- GDNativeInstance *new_instance = memnew(GDNativeInstance);
+ "so",
+ "dylib",
- new_instance->owner = p_this;
- new_instance->script = Ref<GDNativeScript>(this);
+ "wasm"
+};
-#ifndef TOOLS_ENABLED
- if (!ScriptServer::is_scripting_enabled()) {
- new_instance->userdata = 0;
- } else {
- new_instance->userdata = script_data->create_func.create_func((godot_object *)p_this, script_data->create_func.method_data);
- }
+// TODO(karroffel): make this actually do the right thing.
+GDNativeLibrary::Platform GDNativeLibrary::current_platform =
+#if defined(X11_ENABLED)
+ X11_64BIT;
+#elif defined(WINDOWS_ENABLED)
+ WINDOWS_64BIT;
+#elif defined(OSX_ENABLED)
+ OSX;
#else
- new_instance->userdata = script_data->create_func.create_func((godot_object *)p_this, script_data->create_func.method_data);
+ X11_64BIT; // need a sensible default..
#endif
- instances.insert(p_this);
- return new_instance;
-}
-
-bool GDNativeScript::instance_has(const Object *p_this) const {
- return instances.has((Object *)p_this); // TODO
-}
-
-bool GDNativeScript::has_source_code() const {
- return false;
-}
-
-String GDNativeScript::get_source_code() const {
- return "";
-}
-
-Error GDNativeScript::reload(bool p_keep_state) {
- return FAILED;
-}
-
-bool GDNativeScript::has_method(const StringName &p_method) const {
- if (!script_data)
- return false;
- GDNativeScriptData *data = script_data;
-
- while (data) {
- if (data->methods.has(p_method))
- return true;
-
- data = data->base_data;
- }
-
- return false;
-}
-
-MethodInfo GDNativeScript::get_method_info(const StringName &p_method) const {
- if (!script_data)
- return MethodInfo();
- GDNativeScriptData *data = script_data;
-
- while (data) {
- if (data->methods.has(p_method))
- return data->methods[p_method].info;
-
- data = data->base_data;
- }
-
- ERR_FAIL_COND_V(!script_data->methods.has(p_method), MethodInfo());
- return MethodInfo();
-}
-
-void GDNativeScript::get_script_method_list(List<MethodInfo> *p_list) const {
- if (!script_data) return;
-
- Set<MethodInfo> methods;
- GDNativeScriptData *data = script_data;
-
- while (data) {
- for (Map<StringName, GDNativeScriptData::Method>::Element *E = data->methods.front(); E; E = E->next()) {
- methods.insert(E->get().info);
- }
- data = data->base_data;
- }
-
- for (Set<MethodInfo>::Element *E = methods.front(); E; E = E->next()) {
- p_list->push_back(E->get());
- }
-}
-
-void GDNativeScript::get_script_property_list(List<PropertyInfo> *p_list) const {
- if (!script_data) return;
-
- Set<PropertyInfo> properties;
- GDNativeScriptData *data = script_data;
-
- while (data) {
- for (Map<StringName, GDNativeScriptData::Property>::Element *E = data->properties.front(); E; E = E->next()) {
- properties.insert(E->get().info);
- }
- data = data->base_data;
- }
-
- for (Set<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) {
- p_list->push_back(E->get());
- }
-}
-
-bool GDNativeScript::get_property_default_value(const StringName &p_property, Variant &r_value) const {
- if (!script_data) return false;
-
- GDNativeScriptData *data = script_data;
-
- while (data) {
- if (data->properties.has(p_property)) {
- r_value = data->properties[p_property].default_value;
- return true;
- }
-
- data = data->base_data;
- }
-
- return false;
-}
-
-bool GDNativeScript::is_tool() const {
- ERR_FAIL_COND_V(!script_data, false);
- return script_data->is_tool;
-}
-
-String GDNativeScript::get_node_type() const {
- return ""; // ?
-}
-
-ScriptLanguage *GDNativeScript::get_language() const {
- return GDNativeScriptLanguage::singleton;
-}
-
-bool GDNativeScript::has_script_signal(const StringName &p_signal) const {
- if (!script_data)
- return false;
-
- GDNativeScriptData *data = script_data;
-
- while (data) {
- if (data->signals_.has(p_signal)) {
- return true;
- }
-
- data = data->base_data;
- }
-
- return false;
-}
-
-void GDNativeScript::get_script_signal_list(List<MethodInfo> *r_signals) const {
- if (!script_data)
- return;
-
- Set<MethodInfo> signals_;
- GDNativeScriptData *data = script_data;
-
- while (data) {
-
- for (Map<StringName, GDNativeScriptData::Signal>::Element *S = data->signals_.front(); S; S = S->next()) {
- signals_.insert(S->get().signal);
- }
-
- data = data->base_data;
- }
-
- for (Set<MethodInfo>::Element *E = signals_.front(); E; E = E->next()) {
- r_signals->push_back(E->get());
- }
-}
-
-Variant GDNativeScript::_new(const Variant **p_args, int p_argcount, Variant::CallError &r_error) {
-
- /* STEP 1, CREATE */
-
- if (!library.is_valid() || ((String)script_name).empty() || !script_data) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
- return Variant();
- }
-
- r_error.error = Variant::CallError::CALL_OK;
- REF ref;
- Object *owner = NULL;
-
- GDNativeScriptData *_baseptr = script_data;
- while (_baseptr->base_data) {
- _baseptr = _baseptr->base_data;
- }
-
- if (!(_baseptr->base_native_type == "")) {
- owner = ClassDB::instance(_baseptr->base_native_type);
- } else {
- owner = memnew(Reference); //by default, no base means use reference
- }
-
- Reference *r = owner->cast_to<Reference>();
- if (r) {
- ref = REF(r);
- }
-
- // GDScript does it like this: _create_instance(p_args, p_argcount, owner, r != NULL, r_error);
- // @Todo support varargs for constructors.
- GDNativeInstance *instance = (GDNativeInstance *)instance_create(owner);
-
- owner->set_script_instance(instance);
- if (!instance) {
- if (ref.is_null()) {
- memdelete(owner); //no owner, sorry
- }
- return Variant();
- }
-
- if (ref.is_valid()) {
- return ref;
- } else {
- return owner;
- }
-}
-
-Ref<GDNativeLibrary> GDNativeScript::get_library() const {
- return library;
-}
-
-void GDNativeScript::set_library(Ref<GDNativeLibrary> p_library) {
- library = p_library;
-
-#ifdef TOOLS_ENABLED
- if (!ScriptServer::is_scripting_enabled())
- return;
-#endif
- if (library.is_valid()) {
- Error initalize_status = library->_initialize();
- ERR_FAIL_COND(initalize_status != OK);
- if (script_name) {
- script_data = library->native_library->scripts[script_name];
- ERR_FAIL_COND(!script_data);
- }
- }
-}
-
-StringName GDNativeScript::get_script_name() const {
- return script_name;
-}
-
-void GDNativeScript::set_script_name(StringName p_script_name) {
- script_name = p_script_name;
-
- if (library.is_valid()) {
-#ifdef TOOLS_ENABLED
- if (!library->native_library) {
- library->_initialize();
- }
-#endif
- if (library->native_library) {
- script_data = library->get_script_data(script_name);
- ERR_FAIL_COND(!script_data);
- }
- }
-}
-
-void GDNativeScript::_bind_methods() {
- ClassDB::bind_method(D_METHOD("get_library"), &GDNativeScript::get_library);
- ClassDB::bind_method(D_METHOD("set_library", "library"), &GDNativeScript::set_library);
- ClassDB::bind_method(D_METHOD("get_script_name"), &GDNativeScript::get_script_name);
- ClassDB::bind_method(D_METHOD("set_script_name", "script_name"), &GDNativeScript::set_script_name);
-
- ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "new", &GDNativeScript::_new, MethodInfo(Variant::OBJECT, "new"));
-
- ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT, "library", PROPERTY_HINT_RESOURCE_TYPE, "GDNativeLibrary"), "set_library", "get_library");
- ADD_PROPERTYNZ(PropertyInfo(Variant::STRING, "script_name"), "set_script_name", "get_script_name");
-}
-
-GDNativeScript::GDNativeScript() {
- script_data = NULL;
- GDNativeScriptLanguage::get_singleton()->script_list.insert(this);
-}
-
-GDNativeScript::~GDNativeScript() {
- //hmm
- GDNativeScriptLanguage::get_singleton()->script_list.erase(this);
-}
-
-// Library
-
-GDNativeLibrary *GDNativeLibrary::currently_initialized_library = NULL;
-
-GDNativeLibrary *GDNativeLibrary::get_currently_initialized_library() {
- return currently_initialized_library;
-}
-
-static const char *_dl_platforms_info[] = {
- "|unix|so|Unix",
- "unix|x11|so|X11",
- "unix|server|so|Server",
- "unix|android|so|Android",
- "unix|haiku|so|Haiku", // Right?
- "|mac|dylib|Mac",
- "mac|ios|dylib|iOS",
- "mac|osx|dylib|OSX",
- "|html5|js|HTML5",
- "|windows|dll|Windows",
- "windows|uwp|dll|UWP",
- NULL // Finishing condition
-};
-
-void GDNativeLibrary::set_platform_file(StringName p_platform, String p_file) {
- if (p_file.empty()) {
- platform_files.erase(p_platform);
- } else {
- platform_files[p_platform] = p_file;
- }
-}
-
-String GDNativeLibrary::get_platform_file(StringName p_platform) const {
- if (platform_files.has(p_platform)) {
- return platform_files[p_platform];
- } else {
- return "";
- }
-}
-
-Error GDNativeLibrary::_initialize() {
- _THREAD_SAFE_METHOD_
-
- // Get the file
-
- const String platform_name = OS::get_singleton()->get_name();
- String platform_file("");
- char **platform_info = (char **)_dl_platforms_info;
-
- if (platform_files.has(platform_name.to_lower())) {
- platform_file = platform_files[platform_name.to_lower()];
- }
-
- while (*platform_info) {
- String platform_info_string(*platform_info);
-
- if (platform_name == platform_info_string.get_slicec('|', 3)) {
- String platform_key = platform_info_string.get_slicec('|', 1);
- String fallback_platform_key = platform_info_string.get_slicec('|', 0);
-
- if (platform_files.has(platform_key)) {
- platform_file = platform_files[platform_key];
- } else if (!fallback_platform_key.empty() && platform_files.has(fallback_platform_key)) {
- platform_file = platform_files[fallback_platform_key];
- } else {
- return ERR_UNAVAILABLE;
- }
- }
- platform_info++;
- }
- ERR_FAIL_COND_V(platform_file == "", ERR_DOES_NOT_EXIST);
-
- StringName path = GlobalConfig::get_singleton()->globalize_path(platform_file);
-
- GDNativeLibrary::currently_initialized_library = this;
-
- Error ret = NativeLibrary::initialize(native_library, path);
- native_library->dllib = this;
-
- GDNativeLibrary::currently_initialized_library = NULL;
-
- return ret;
-}
-
-Error GDNativeLibrary::_terminate() {
- ERR_FAIL_COND_V(!native_library, ERR_BUG);
- ERR_FAIL_COND_V(!native_library->handle, ERR_BUG);
-
- // de-init stuff
-
- for (Map<StringName, GDNativeScriptData *>::Element *E = native_library->scripts.front(); E; E = E->next()) {
- for (Map<StringName, GDNativeScriptData::Method>::Element *M = E->get()->methods.front(); M; M = M->next()) {
- if (M->get().method.free_func) {
- M->get().method.free_func(M->get().method.method_data);
- }
- }
- if (E->get()->create_func.free_func) {
- E->get()->create_func.free_func(E->get()->create_func.method_data);
- }
- if (E->get()->destroy_func.free_func) {
- E->get()->destroy_func.free_func(E->get()->destroy_func.method_data);
- }
-
- for (Set<GDNativeScript *>::Element *S = GDNativeScriptLanguage::get_singleton()->script_list.front(); S; S = S->next()) {
- if (S->get()->script_data == E->get()) {
- S->get()->script_data = NULL;
- }
- }
-
- memdelete(E->get());
- }
-
- Error ret = NativeLibrary::terminate(native_library);
- native_library->scripts.clear();
-
- return ret;
-}
-
-void GDNativeLibrary::_register_script(const StringName p_name, const StringName p_base, godot_instance_create_func p_instance_func, godot_instance_destroy_func p_destroy_func) {
- ERR_FAIL_COND(!native_library);
- ERR_FAIL_COND(native_library->scripts.has(p_name));
-
- GDNativeScriptData *s = memnew(GDNativeScriptData);
- s->base = p_base;
- s->create_func = p_instance_func;
- s->destroy_func = p_destroy_func;
- Map<StringName, GDNativeScriptData *>::Element *E = native_library->scripts.find(p_base);
- if (E) {
- s->base_data = E->get();
- s->base_native_type = s->base_data->base_native_type;
- } else {
- if (!ClassDB::class_exists(p_base)) {
- memdelete(s);
- ERR_EXPLAIN("Invalid base for registered type '" + p_name + "'");
- ERR_FAIL();
- }
- s->base_native_type = p_base;
- }
-
- native_library->scripts.insert(p_name, s);
-}
-
-void GDNativeLibrary::_register_tool_script(const StringName p_name, const StringName p_base, godot_instance_create_func p_instance_func, godot_instance_destroy_func p_destroy_func) {
- ERR_FAIL_COND(!native_library);
- ERR_FAIL_COND(native_library->scripts.has(p_name));
-
- GDNativeScriptData *s = memnew(GDNativeScriptData);
- s->base = p_base;
- s->create_func = p_instance_func;
- s->destroy_func = p_destroy_func;
- s->is_tool = true;
- Map<StringName, GDNativeScriptData *>::Element *E = native_library->scripts.find(p_base);
- if (E) {
- s->base_data = E->get();
- s->base_native_type = s->base_data->base_native_type;
- } else {
- if (!ClassDB::class_exists(p_base)) {
- memdelete(s);
- ERR_EXPLAIN("Invalid base for registered type '" + p_name + "'");
- ERR_FAIL();
- }
- s->base_native_type = p_base;
- }
-
- native_library->scripts.insert(p_name, s);
-}
-
-void GDNativeLibrary::_register_script_method(const StringName p_name, const StringName p_method, godot_method_attributes p_attr, godot_instance_method p_func, MethodInfo p_info) {
- ERR_FAIL_COND(!native_library);
- ERR_FAIL_COND(!native_library->scripts.has(p_name));
-
- p_info.name = p_method;
- GDNativeScriptData::Method method;
-
- method = GDNativeScriptData::Method(p_func, p_info, p_attr.rpc_type);
-
- native_library->scripts[p_name]->methods.insert(p_method, method);
-}
-
-void GDNativeLibrary::_register_script_property(const StringName p_name, const String p_path, godot_property_attributes *p_attr, godot_property_set_func p_setter, godot_property_get_func p_getter) {
- ERR_FAIL_COND(!native_library);
- ERR_FAIL_COND(!native_library->scripts.has(p_name));
-
- GDNativeScriptData::Property p;
-
- PropertyInfo pi;
- pi.name = p_path;
-
- if (p_attr != NULL) {
- pi = PropertyInfo((Variant::Type)p_attr->type, p_path, (PropertyHint)p_attr->hint, *(String *)&p_attr->hint_string, p_attr->usage);
-
- p = GDNativeScriptData::Property(p_setter, p_getter, pi, *(Variant *)&p_attr->default_value, p_attr->rset_type);
- }
-
- native_library->scripts[p_name]->properties.insert(p_path, p);
+GDNativeLibrary::GDNativeLibrary()
+ : library_paths() {
}
-void GDNativeLibrary::_register_script_signal(const StringName p_name, const godot_signal *p_signal) {
- ERR_FAIL_COND(!native_library);
- ERR_FAIL_COND(!native_library->scripts.has(p_name));
- ERR_FAIL_COND(!p_signal);
-
- GDNativeScriptData::Signal signal;
-
- signal.signal.name = *(String *)&p_signal->name;
-
- {
- List<PropertyInfo> arguments;
- for (int i = 0; i < p_signal->num_args; i++) {
- PropertyInfo info;
- godot_signal_argument attrib = p_signal->args[i];
-
- String *name = (String *)&attrib.name;
- info.name = *name;
- info.type = (Variant::Type)attrib.type;
- info.hint = (PropertyHint)attrib.hint;
- info.hint_string = *(String *)&attrib.hint_string;
- info.usage = attrib.usage;
-
- arguments.push_back(info);
- }
-
- signal.signal.arguments = arguments;
- }
-
- {
- Vector<Variant> default_arguments;
- for (int i = 0; i < p_signal->num_default_args; i++) {
- Variant *v;
- godot_signal_argument attrib = p_signal->args[i];
-
- v = (Variant *)&attrib.default_value;
-
- default_arguments.push_back(*v);
- }
-
- signal.signal.default_arguments = default_arguments;
- }
-
- native_library->scripts[p_name]->signals_.insert(*(String *)&p_signal->name, signal);
+GDNativeLibrary::~GDNativeLibrary() {
}
-GDNativeScriptData *GDNativeLibrary::get_script_data(const StringName p_name) {
- ERR_FAIL_COND_V(!native_library, NULL);
-
- ERR_FAIL_COND_V(!native_library->scripts.has(p_name), NULL);
-
- return native_library->scripts[p_name];
+void GDNativeLibrary::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("set_library_path", "platform", "path"), &GDNativeLibrary::set_library_path);
+ ClassDB::bind_method(D_METHOD("get_library_path", "platform"), &GDNativeLibrary::get_library_path);
}
bool GDNativeLibrary::_set(const StringName &p_name, const Variant &p_value) {
String name = p_name;
if (name.begins_with("platform/")) {
- set_platform_file(name.get_slice("/", 1), p_value);
+ set_library_path(name.get_slice("/", 1), p_value);
return true;
}
return false;
@@ -763,517 +101,234 @@ bool GDNativeLibrary::_set(const StringName &p_name, const Variant &p_value) {
bool GDNativeLibrary::_get(const StringName &p_name, Variant &r_ret) const {
String name = p_name;
if (name.begins_with("platform/")) {
- r_ret = get_platform_file(name.get_slice("/", 1));
+ r_ret = get_library_path(name.get_slice("/", 1));
return true;
}
return false;
}
void GDNativeLibrary::_get_property_list(List<PropertyInfo> *p_list) const {
- char **platform_info = (char **)_dl_platforms_info;
-
- Set<String> registered_platform_names;
- {
- List<StringName> ep;
- // ep.push_back("X11");
- // EditorImportExport::get_singleton()->get_export_platforms(&ep);
-
- // @Todo
- // get export platforms with the new export system somehow.
- for (List<StringName>::Element *E = ep.front(); E; E = E->next()) {
- registered_platform_names.insert(String(E->get()).to_lower());
- }
+ for (int i = 0; i < NUM_PLATFORMS; i++) {
+ p_list->push_back(PropertyInfo(Variant::STRING,
+ "platform/" + platform_names[i],
+ PROPERTY_HINT_FILE,
+ "*." + platform_lib_ext[i]));
}
+}
- while (*platform_info) {
- String platform_info_string(*platform_info);
- String fallback_platform_key = platform_info_string.get_slicec('|', 0);
- String platform_key = platform_info_string.get_slicec('|', 1);
- String platform_extension = platform_info_string.get_slicec('|', 2);
- String platform_name = platform_info_string.get_slicec('|', 3);
-
- registered_platform_names.erase(platform_name);
-
- if (fallback_platform_key.empty()) {
- p_list->push_back(PropertyInfo(Variant::STRING, "platform/" + platform_key, PROPERTY_HINT_FILE, "*." + platform_extension));
-
- } else {
- if (platform_files.has(platform_key)) {
- p_list->push_back(PropertyInfo(Variant::STRING, "platform/" + platform_key, PROPERTY_HINT_FILE, "*." + platform_extension, PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_CHECKABLE | PROPERTY_USAGE_CHECKED));
- } else {
- p_list->push_back(PropertyInfo(Variant::STRING, "platform/" + platform_key, PROPERTY_HINT_FILE, "*." + platform_extension, PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_CHECKABLE));
- }
+void GDNativeLibrary::set_library_path(StringName p_platform, String p_path) {
+ int i;
+ for (i = 0; i <= NUM_PLATFORMS; i++) {
+ if (i == NUM_PLATFORMS) break;
+ if (platform_names[i] == p_platform) {
+ break;
}
- platform_info++;
- }
-
- while (registered_platform_names.size()) {
- const String platform_name = registered_platform_names.front()->get();
- registered_platform_names.erase(platform_name);
- p_list->push_back(PropertyInfo(Variant::STRING, "platform/" + platform_name.to_lower(), PROPERTY_HINT_FILE, "*"));
}
-}
-
-void GDNativeLibrary::_notification(int what) {
- // TODO
-}
-
-void GDNativeLibrary::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_platform_file", "platform", "file"), &GDNativeLibrary::set_platform_file);
- ClassDB::bind_method(D_METHOD("get_platform_file", "platform"), &GDNativeLibrary::get_platform_file);
-}
-
-GDNativeLibrary::GDNativeLibrary() {
- native_library = NULL;
-}
-
-GDNativeLibrary::~GDNativeLibrary() {
- if (!native_library) {
- return;
+ if (i == NUM_PLATFORMS) {
+ ERR_EXPLAIN(String("No such platform: ") + p_platform);
+ ERR_FAIL();
}
- if (native_library->handle) {
- _terminate();
- }
+ library_paths[i] = p_path;
}
-// Instance
-
-bool GDNativeInstance::set(const StringName &p_name, const Variant &p_value) {
- if (!script->script_data)
- return false;
- if (script->script_data->properties.has(p_name)) {
- script->script_data->properties[p_name].setter.set_func((godot_object *)owner, script->script_data->properties[p_name].setter.method_data, userdata, *(godot_variant *)&p_value);
- return true;
+String GDNativeLibrary::get_library_path(StringName p_platform) const {
+ int i;
+ for (i = 0; i <= NUM_PLATFORMS; i++) {
+ if (i == NUM_PLATFORMS) break;
+ if (platform_names[i] == p_platform) {
+ break;
+ }
}
- return false;
-}
-bool GDNativeInstance::get(const StringName &p_name, Variant &r_ret) const {
- if (!script->script_data)
- return false;
- if (script->script_data->properties.has(p_name)) {
- godot_variant value = script->script_data->properties[p_name].getter.get_func((godot_object *)owner, script->script_data->properties[p_name].getter.method_data, userdata);
- r_ret = *(Variant *)&value;
- return true;
+ if (i == NUM_PLATFORMS) {
+ ERR_EXPLAIN(String("No such platform: ") + p_platform);
+ ERR_FAIL_V("");
}
- return false;
-}
-
-void GDNativeInstance::get_property_list(List<PropertyInfo> *p_properties) const {
- script->get_script_property_list(p_properties);
- // TODO: dynamic properties
-}
-Variant::Type GDNativeInstance::get_property_type(const StringName &p_name, bool *r_is_valid) const {
- if (script->script_data->properties.has(p_name)) {
- *r_is_valid = true;
- return script->script_data->properties[p_name].info.type;
- }
- *r_is_valid = false;
- return Variant::NIL;
+ return library_paths[i];
}
-void GDNativeInstance::get_method_list(List<MethodInfo> *p_list) const {
- script->get_script_method_list(p_list);
+String GDNativeLibrary::get_active_library_path() const {
+ return library_paths[GDNativeLibrary::current_platform];
}
-bool GDNativeInstance::has_method(const StringName &p_method) const {
- return script->has_method(p_method);
+GDNative::GDNative() {
+ initialized = false;
+ native_handle = NULL;
}
-Variant GDNativeInstance::call(const StringName &p_method, const Variant **p_args, int p_argcount, Variant::CallError &r_error) {
- // TODO: validated methods & errors
-
- GDNativeScriptData *data_ptr = script->script_data;
- while (data_ptr) {
- Map<StringName, GDNativeScriptData::Method>::Element *E = data_ptr->methods.find(p_method);
- if (E) {
- godot_variant result = E->get().method.method((godot_object *)owner, E->get().method.method_data, userdata, p_argcount, (godot_variant **)p_args);
- return *(Variant *)&result;
- }
- data_ptr = data_ptr->base_data;
- }
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
- return Variant();
+GDNative::~GDNative() {
+ // TODO(karroffel): implement ALL the things!
}
-void GDNativeInstance::call_multilevel(const StringName &p_method, const Variant **p_args, int p_argcount) {
- // TODO: validated methods & errors
+extern "C" void _api_anchor();
- GDNativeScriptData *data_ptr = script->script_data;
- while (data_ptr) {
- Map<StringName, GDNativeScriptData::Method>::Element *E = data_ptr->methods.find(p_method);
- if (E) {
- E->get().method.method((godot_object *)owner, E->get().method.method_data, userdata, p_argcount, (godot_variant **)p_args);
- }
- data_ptr = data_ptr->base_data;
- }
+void GDNative::_compile_dummy_for_api() {
+ _api_anchor();
}
-void GDNativeInstance::_ml_call_reversed(GDNativeScriptData *data_ptr, const StringName &p_method, const Variant **p_args, int p_argcount) {
- // TODO: validated methods & errors
+void GDNative::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("set_library", "library:GDNativeLibrary"), &GDNative::set_library);
+ ClassDB::bind_method(D_METHOD("get_library:GDNativeLibrary"), &GDNative::get_library);
- if (data_ptr->base_data)
- _ml_call_reversed(data_ptr->base_data, p_method, p_args, p_argcount);
+ ClassDB::bind_method(D_METHOD("initialize"), &GDNative::initialize);
+ ClassDB::bind_method(D_METHOD("terminate"), &GDNative::terminate);
- // Variant::CallError ce;
+ // TODO(karroffel): get_native_(raw_)call_types binding?
- Map<StringName, GDNativeScriptData::Method>::Element *E = data_ptr->methods.find(p_method);
- if (E) {
- E->get().method.method((godot_object *)owner, E->get().method.method_data, userdata, p_argcount, (godot_variant **)p_args);
- }
-}
+ // TODO(karroffel): make this a varargs function?
+ ClassDB::bind_method(D_METHOD("call_native:Variant", "procedure_name", "arguments:Array"), &GDNative::call_native);
-void GDNativeInstance::call_multilevel_reversed(const StringName &p_method, const Variant **p_args, int p_argcount) {
- if (script.ptr() && script->script_data) {
- _ml_call_reversed(script->script_data, p_method, p_args, p_argcount);
- }
-}
-
-void GDNativeInstance::notification(int p_notification) {
- Variant value = p_notification;
- const Variant *args[1] = { &value };
- call_multilevel(GDNativeScriptLanguage::singleton->strings._notification, args, 1);
+ ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT, "library", PROPERTY_HINT_RESOURCE_TYPE, "GDNativeLibrary"), "set_library", "get_library");
}
-Ref<Script> GDNativeInstance::get_script() const {
- return script;
+void GDNative::set_library(Ref<GDNativeLibrary> p_library) {
+ ERR_EXPLAIN("Tried to change library of GDNative when it is already set");
+ ERR_FAIL_COND(library.is_valid());
+ library = p_library;
}
-ScriptLanguage *GDNativeInstance::get_language() {
- return GDNativeScriptLanguage::singleton;
+Ref<GDNativeLibrary> GDNative::get_library() {
+ return library;
}
-ScriptInstance::RPCMode GDNativeInstance::get_rpc_mode(const StringName &p_method) const {
- GDNativeScriptData::Method m = script->script_data->methods[p_method];
- switch (m.rpc_mode) {
- case GODOT_METHOD_RPC_MODE_DISABLED:
- return RPC_MODE_DISABLED;
- case GODOT_METHOD_RPC_MODE_REMOTE:
- return RPC_MODE_REMOTE;
- case GODOT_METHOD_RPC_MODE_SYNC:
- return RPC_MODE_SYNC;
- case GODOT_METHOD_RPC_MODE_MASTER:
- return RPC_MODE_MASTER;
- case GODOT_METHOD_RPC_MODE_SLAVE:
- return RPC_MODE_SLAVE;
- default:
- return RPC_MODE_DISABLED;
+bool GDNative::initialize() {
+ if (library.is_null()) {
+ ERR_PRINT("No library set, can't initialize GDNative object");
+ return false;
}
-}
-ScriptInstance::RPCMode GDNativeInstance::get_rset_mode(const StringName &p_variable) const {
- GDNativeScriptData::Property p = script->script_data->properties[p_variable];
- switch (p.rset_mode) {
- case GODOT_METHOD_RPC_MODE_DISABLED:
- return RPC_MODE_DISABLED;
- case GODOT_METHOD_RPC_MODE_REMOTE:
- return RPC_MODE_REMOTE;
- case GODOT_METHOD_RPC_MODE_SYNC:
- return RPC_MODE_SYNC;
- case GODOT_METHOD_RPC_MODE_MASTER:
- return RPC_MODE_MASTER;
- case GODOT_METHOD_RPC_MODE_SLAVE:
- return RPC_MODE_SLAVE;
- default:
- return RPC_MODE_DISABLED;
+ String lib_path = library->get_active_library_path();
+ if (lib_path.empty()) {
+ ERR_PRINT("No library set for this platform");
+ return false;
}
-}
-
-GDNativeInstance::GDNativeInstance() {
- owner = NULL;
- userdata = NULL;
-}
-GDNativeInstance::~GDNativeInstance() {
- if (script.is_valid()) {
- if (owner) {
- script->instances.erase(owner);
- }
- if (!script->script_data)
- return;
- script->script_data->destroy_func.destroy_func((godot_object *)owner, script->script_data->destroy_func.method_data, userdata);
- if (script->script_data->destroy_func.free_func)
- script->script_data->destroy_func.free_func(script->script_data->destroy_func.method_data);
- if (script->script_data->create_func.free_func)
- script->script_data->create_func.free_func(script->script_data->create_func.method_data);
+ String path = ProjectSettings::get_singleton()->globalize_path(lib_path);
+ Error err = OS::get_singleton()->open_dynamic_library(path, native_handle);
+ if (err != OK) {
+ return false;
}
-}
-
-// Language
-
-GDNativeScriptLanguage *GDNativeScriptLanguage::singleton = NULL;
-
-String GDNativeScriptLanguage::get_name() const {
- return "Native";
-}
-
-void _add_reload_node() {
-#ifdef TOOLS_ENABLED
- GDNativeReloadNode *rn = memnew(GDNativeReloadNode);
- EditorNode::get_singleton()->add_child(rn);
-#endif
-}
-
-void GDNativeScriptLanguage::init() {
- // TODO: Expose globals
- GLOBAL_DEF("gdnative/default_gdnativelibrary", "");
- PropertyInfo prop_info(Variant::STRING, "gdnative/default_gdnativelibrary", PROPERTY_HINT_FILE, "tres,res,dllib");
- GlobalConfig::get_singleton()->set_custom_property_info("gdnative/default_gdnativelibrary", prop_info);
-
-// generate bindings
-#if defined(TOOLS_ENABLED) && defined(DEBUG_METHODS_ENABLED)
-
- List<String> args = OS::get_singleton()->get_cmdline_args();
- List<String>::Element *E = args.find("--gdnative-generate-json-api");
+ void *library_init;
+ err = OS::get_singleton()->get_dynamic_library_symbol_handle(
+ native_handle,
+ init_symbol,
+ library_init);
- if (E && E->next()) {
- if (generate_c_api(E->next()->get()) != OK) {
- ERR_PRINT("Failed to generate C API\n");
- }
+ if (err || !library_init) {
+ return false;
}
-#endif
-
-#ifdef TOOLS_ENABLED
- // if (SceneTree::get_singleton()->is_editor_hint()) {
- EditorNode::add_init_callback(&_add_reload_node);
-// }
-#endif
-}
-String GDNativeScriptLanguage::get_type() const {
- return "Native";
-}
-
-String GDNativeScriptLanguage::get_extension() const {
- return "gdn";
-}
-
-Error GDNativeScriptLanguage::execute_file(const String &p_path) {
- return OK; // ??
-}
-
-void GDNativeScriptLanguage::finish() {
- // cleanup is for noobs
-}
+ godot_gdnative_init_fn library_init_fpointer;
+ library_init_fpointer = (godot_gdnative_init_fn)library_init;
-// scons doesn't want to link in the api source so we need to call a dummy function to cause it to link
-extern "C" void _api_anchor();
-
-void GDNativeScriptLanguage::_compile_dummy_for_the_api() {
- _api_anchor();
-}
+ godot_gdnative_init_options options;
-Ref<Script> GDNativeScriptLanguage::get_template(const String &p_class_name, const String &p_base_class_name) const {
- GDNativeScript *src = memnew(GDNativeScript);
- src->set_script_name(p_class_name);
- return Ref<GDNativeScript>(src);
-}
-
-bool GDNativeScriptLanguage::validate(const String &p_script, int &r_line_error, int &r_col_error, String &r_test_error, const String &p_path, List<String> *r_functions) const {
- return false; // TODO
-}
+ options.in_editor = SceneTree::get_singleton()->is_editor_hint();
+ options.core_api_hash = ClassDB::get_api_hash(ClassDB::API_CORE);
+ options.editor_api_hash = ClassDB::get_api_hash(ClassDB::API_EDITOR);
+ options.no_api_hash = ClassDB::get_api_hash(ClassDB::API_NONE);
+ options.gd_native_library = (godot_object *)(get_library().ptr());
-Script *GDNativeScriptLanguage::create_script() const {
- GDNativeScript *scr = memnew(GDNativeScript);
- return scr;
-}
+ library_init_fpointer(&options);
-bool GDNativeScriptLanguage::has_named_classes() const {
return true;
}
-int GDNativeScriptLanguage::find_function(const String &p_function, const String &p_code) const {
- return -1; // No source code!
-}
-
-String GDNativeScriptLanguage::make_function(const String &p_class, const String &p_name, const PoolStringArray &p_args) const {
- return ""; // No source code!
-}
-
-void GDNativeScriptLanguage::add_global_constant(const StringName &p_variable, const Variant &p_value) {
- // TODO TODO TODO
-}
-
-// TODO: Any debugging? (research)
-String GDNativeScriptLanguage::debug_get_error() const {
- return "";
-}
-
-int GDNativeScriptLanguage::debug_get_stack_level_count() const {
- return 1; // ?
-}
+bool GDNative::terminate() {
-int GDNativeScriptLanguage::debug_get_stack_level_line(int p_level) const {
- return -1;
-}
-
-String GDNativeScriptLanguage::debug_get_stack_level_function(int p_level) const {
- return "[native code]"; // ?
-}
-
-String GDNativeScriptLanguage::debug_get_stack_level_source(int p_level) const {
- return "";
-}
-
-void GDNativeScriptLanguage::debug_get_stack_level_members(int p_level, List<String> *p_members, List<Variant> *p_values, int p_max_subitems, int p_max_depth) {}
-
-void GDNativeScriptLanguage::debug_get_globals(List<String> *p_locals, List<Variant> *p_values, int p_max_subitems, int p_max_depth) {}
-
-String GDNativeScriptLanguage::debug_parse_stack_level_expression(int p_level, const String &p_expression, int p_max_subitems, int p_max_depth) {
- return ""; // ??
-}
+ if (native_handle == NULL) {
+ ERR_PRINT("No valid library handle, can't terminate GDNative object");
+ return false;
+ }
-void GDNativeScriptLanguage::reload_all_scripts() {
- // @Todo
-}
+ Error error = OK;
+ void *library_terminate;
+ error = OS::get_singleton()->get_dynamic_library_symbol_handle(
+ native_handle,
+ terminate_symbol,
+ library_terminate);
+ if (error) {
+ OS::get_singleton()->close_dynamic_library(native_handle);
+ native_handle = NULL;
+ return true;
+ }
-void GDNativeScriptLanguage::reload_tool_script(const Ref<Script> &p_script, bool p_soft_reload) {
- // @Todo
- OS::get_singleton()->print("reload tool scripts\n");
-}
+ godot_gdnative_terminate_fn library_terminate_pointer;
+ library_terminate_pointer = (godot_gdnative_terminate_fn)library_terminate;
-void GDNativeScriptLanguage::get_recognized_extensions(List<String> *p_extensions) const {
- p_extensions->push_back("gdn"); // Container file format
-}
+ // TODO(karroffel): remove this? Should be part of NativeScript, not
+ // GDNative IMO
+ godot_gdnative_terminate_options options;
+ options.in_editor = SceneTree::get_singleton()->is_editor_hint();
-void GDNativeScriptLanguage::get_public_functions(List<MethodInfo> *p_functions) const {
-}
+ library_terminate_pointer(&options);
-void GDNativeScriptLanguage::get_public_constants(List<Pair<String, Variant> > *p_constants) const {
-}
+ // GDNativeScriptLanguage::get_singleton()->initialized_libraries.erase(p_native_lib->path);
-// TODO: all profilling
-void GDNativeScriptLanguage::profiling_start() {
-}
+ OS::get_singleton()->close_dynamic_library(native_handle);
+ native_handle = NULL;
-void GDNativeScriptLanguage::profiling_stop() {
+ return false;
}
-int GDNativeScriptLanguage::profiling_get_accumulated_data(ProfilingInfo *p_info_arr, int p_info_max) {
- return 0;
+void GDNativeCallRegistry::register_native_call_type(StringName p_call_type, native_call_cb p_callback) {
+ native_calls.insert(p_call_type, p_callback);
}
-int GDNativeScriptLanguage::profiling_get_frame_data(ProfilingInfo *p_info_arr, int p_info_max) {
- return 0;
+void GDNativeCallRegistry::register_native_raw_call_type(StringName p_raw_call_type, native_raw_call_cb p_callback) {
+ native_raw_calls.insert(p_raw_call_type, p_callback);
}
-void GDNativeScriptLanguage::frame() {
-}
+Vector<StringName> GDNativeCallRegistry::get_native_call_types() {
+ Vector<StringName> call_types;
+ call_types.resize(native_calls.size());
-String GDNativeScriptLanguage::get_init_symbol_name() {
- return "godot_native_init"; // TODO: Maybe make some internal function which would do the actual stuff
-}
+ size_t idx = 0;
+ for (Map<StringName, native_call_cb>::Element *E = native_calls.front(); E; E = E->next(), idx++) {
+ call_types[idx] = E->key();
+ }
-String GDNativeScriptLanguage::get_terminate_symbol_name() {
- return "godot_native_terminate";
+ return call_types;
}
-GDNativeScriptLanguage::GDNativeScriptLanguage() {
- ERR_FAIL_COND(singleton);
- strings._notification = StringName("_notification");
- singleton = this;
- initialized_libraries = Map<StringName, NativeLibrary *>();
-}
+Vector<StringName> GDNativeCallRegistry::get_native_raw_call_types() {
+ Vector<StringName> call_types;
+ call_types.resize(native_raw_calls.size());
-GDNativeScriptLanguage::~GDNativeScriptLanguage() {
- singleton = NULL;
-}
-
-// DLReloadNode
+ size_t idx = 0;
+ for (Map<StringName, native_raw_call_cb>::Element *E = native_raw_calls.front(); E; E = E->next(), idx++) {
+ call_types[idx] = E->key();
+ }
-void GDNativeReloadNode::_bind_methods() {
- ClassDB::bind_method("_notification", &GDNativeReloadNode::_notification);
+ return call_types;
}
-void GDNativeReloadNode::_notification(int p_what) {
-#ifdef TOOLS_ENABLED
-
- switch (p_what) {
- case MainLoop::NOTIFICATION_WM_FOCUS_IN: {
-
- Set<NativeLibrary *> libs_to_reload;
-
- for (Map<StringName, NativeLibrary *>::Element *L = GDNativeScriptLanguage::get_singleton()->initialized_libraries.front(); L; L = L->next()) {
- // check if file got modified at all
- // @Todo
-
- libs_to_reload.insert(L->get());
- }
-
- for (Set<NativeLibrary *>::Element *L = libs_to_reload.front(); L; L = L->next()) {
-
- GDNativeLibrary *lib = L->get()->dllib;
-
- lib->_terminate();
- lib->_initialize();
-
- // update placeholders (if any)
-
- Set<GDNativeScript *> scripts;
-
- for (Set<GDNativeScript *>::Element *S = GDNativeScriptLanguage::get_singleton()->script_list.front(); S; S = S->next()) {
-
- if (lib->native_library->scripts.has(S->get()->get_script_name())) {
- GDNativeScript *script = S->get();
- script->script_data = lib->get_script_data(script->get_script_name());
- scripts.insert(script);
- }
- }
-
- for (Set<GDNativeScript *>::Element *S = scripts.front(); S; S = S->next()) {
- GDNativeScript *script = S->get();
- if (script->placeholders.size() == 0)
- continue;
+Variant GDNative::call_native(StringName p_native_call_type, StringName p_procedure_name, Array p_arguments) {
- for (Set<PlaceHolderScriptInstance *>::Element *P = script->placeholders.front(); P; P = P->next()) {
- PlaceHolderScriptInstance *p = P->get();
- script->_update_placeholder(p);
- }
- }
- }
-
- } break;
- default: {
- };
+ Map<StringName, native_call_cb>::Element *E = GDNativeCallRegistry::singleton->native_calls.find(p_native_call_type);
+ if (!E) {
+ ERR_PRINT((String("No handler for native call type \"" + p_native_call_type) + "\" found").utf8().get_data());
+ return Variant();
}
-#endif
-}
-// Resource loader/saver
+ String procedure_name = p_procedure_name;
+ godot_variant result = E->get()(native_handle, (godot_string *)&procedure_name, (godot_array *)&p_arguments);
-RES ResourceFormatLoaderGDNativeScript::load(const String &p_path, const String &p_original_path, Error *r_error) {
- ResourceFormatLoaderText rsflt;
- return rsflt.load(p_path, p_original_path, r_error);
+ return *(Variant *)&result;
}
-void ResourceFormatLoaderGDNativeScript::get_recognized_extensions(List<String> *p_extensions) const {
- p_extensions->push_back("gdn");
-}
-bool ResourceFormatLoaderGDNativeScript::handles_type(const String &p_type) const {
- return (p_type == "Script" || p_type == "Native");
-}
-String ResourceFormatLoaderGDNativeScript::get_resource_type(const String &p_path) const {
- String el = p_path.get_extension().to_lower();
- if (el == "gdn")
- return "Native";
- return "";
-}
+void GDNative::call_native_raw(StringName p_raw_call_type, StringName p_procedure_name, void *data, int num_args, void **args, void *r_return) {
-Error ResourceFormatSaverGDNativeScript::save(const String &p_path, const RES &p_resource, uint32_t p_flags) {
- ResourceFormatSaverText rfst;
- return rfst.save(p_path, p_resource, p_flags);
-}
-
-bool ResourceFormatSaverGDNativeScript::recognize(const RES &p_resource) const {
- return p_resource->cast_to<GDNativeScript>() != NULL;
-}
-
-void ResourceFormatSaverGDNativeScript::get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const {
- if (p_resource->cast_to<GDNativeScript>()) {
- p_extensions->push_back("gdn");
+ Map<StringName, native_raw_call_cb>::Element *E = GDNativeCallRegistry::singleton->native_raw_calls.find(p_raw_call_type);
+ if (!E) {
+ ERR_PRINT((String("No handler for native raw call type \"" + p_raw_call_type) + "\" found").utf8().get_data());
+ return;
}
+
+ String procedure_name = p_procedure_name;
+ E->get()(native_handle, (godot_string *)&procedure_name, data, num_args, args, r_return);
}
diff --git a/modules/gdnative/gdnative.h b/modules/gdnative/gdnative.h
index 650f999192..dd845cab7a 100644
--- a/modules/gdnative/gdnative.h
+++ b/modules/gdnative/gdnative.h
@@ -34,382 +34,112 @@
#include "io/resource_saver.h"
#include "os/thread_safe.h"
#include "resource.h"
-#include "scene/main/node.h"
-#include "script_language.h"
-#include "self_list.h"
-#include "godot.h"
+#include "godot/gdnative.h"
-struct GDNativeScriptData;
-class GDNativeLibrary;
-
-struct NativeLibrary {
- StringName path;
- void *handle;
-
- GDNativeLibrary *dllib;
-
- Map<StringName, GDNativeScriptData *> scripts;
-
- static Error initialize(NativeLibrary *&p_native_lib, const StringName p_path);
- static Error terminate(NativeLibrary *&p_native_lib);
-};
-
-struct GDNativeScriptData {
- /* typedef void* (InstanceFunc)(godot_object* instance);
- typedef void (DestroyFunc)(godot_object* instance,void* userdata);
- typedef godot_variant (MethodFunc)(godot_object *instance, void *userdata, void *method_data, int arg_count,godot_variant **args);
- typedef void (MethodDataFreeFunc)(void *method_data);
- typedef void (SetterFunc)(godot_object* instance,void* userdata,godot_variant value);
- typedef godot_variant (GetterFunc)(godot_object* instance,void* userdata);*/
-
- struct Method {
- godot_instance_method method;
- MethodInfo info;
- int rpc_mode;
-
- Method() {
- }
- Method(godot_instance_method p_method, MethodInfo p_info, int p_rpc_mode) {
- method = p_method;
- info = p_info;
- rpc_mode = p_rpc_mode;
- }
- };
- struct Property {
- godot_property_set_func setter;
- godot_property_get_func getter;
- PropertyInfo info;
- Variant default_value;
- int rset_mode;
-
- Property() {
- }
- Property(godot_property_set_func p_setter, godot_property_get_func p_getter) {
- setter = p_setter;
- getter = p_getter;
- }
- Property(godot_property_set_func p_setter, godot_property_get_func p_getter, PropertyInfo p_info, Variant p_default_value, int p_rset_mode) {
- setter = p_setter;
- getter = p_getter;
- info = p_info;
- default_value = p_default_value;
- rset_mode = p_rset_mode;
- }
- };
-
- struct Signal {
- MethodInfo signal;
- };
-
- Map<StringName, Method> methods;
- Map<StringName, Property> properties;
- Map<StringName, Signal> signals_; // QtCreator doesn't like the name signals
- StringName base;
- StringName base_native_type;
- GDNativeScriptData *base_data;
- godot_instance_create_func create_func;
- godot_instance_destroy_func destroy_func;
-
- bool is_tool;
-
- GDNativeScriptData() {
- base = StringName();
- base_data = NULL;
- is_tool = false;
- }
- GDNativeScriptData(StringName p_base, godot_instance_create_func p_instance, godot_instance_destroy_func p_free) {
- base = p_base;
- base_data = NULL;
- create_func = p_instance;
- destroy_func = p_free;
- is_tool = false;
- }
-};
-
-class GDNativeScript : public Script {
- GDCLASS(GDNativeScript, Script);
-
- Ref<GDNativeLibrary> library;
- StringName script_name;
- StringName base_native_type;
- Set<Object *> instances;
- GDNativeScriptData *script_data;
-
-#ifdef TOOLS_ENABLED
- Set<PlaceHolderScriptInstance *> placeholders;
- void _update_placeholder(PlaceHolderScriptInstance *p_placeholder);
- virtual void _placeholder_erased(PlaceHolderScriptInstance *p_placeholder);
-#endif
-
- friend class GDNativeInstance;
- friend class GDNativeScriptLanguage;
- friend class GDNativeReloadNode;
- friend class GDNativeLibrary;
-
-protected:
- static void _bind_methods();
-
-public:
- virtual bool can_instance() const;
-
- virtual Ref<Script> get_base_script() const; //for script inheritance
-
- virtual StringName get_instance_base_type() const; // this may not work in all scripts, will return empty if so
- virtual ScriptInstance *instance_create(Object *p_this);
- virtual bool instance_has(const Object *p_this) const;
-
- virtual bool has_source_code() const;
- virtual String get_source_code() const;
- virtual void set_source_code(const String &p_code) {}
- virtual Error reload(bool p_keep_state = false);
-
- virtual bool has_method(const StringName &p_method) const;
- virtual MethodInfo get_method_info(const StringName &p_method) const;
-
- virtual bool is_tool() const;
-
- virtual String get_node_type() const;
+class GDNativeLibrary : public Resource {
+ GDCLASS(GDNativeLibrary, Resource)
- virtual ScriptLanguage *get_language() const;
+ enum Platform {
+ X11_32BIT,
+ X11_64BIT,
+ WINDOWS_32BIT,
+ WINDOWS_64BIT,
+ // NOTE(karroffel): I heard OSX 32 bit is dead, so 64 only
+ OSX,
- virtual bool has_script_signal(const StringName &p_signal) const;
- virtual void get_script_signal_list(List<MethodInfo> *r_signals) const;
+ // TODO(karroffel): all different android versions and archs
+ ANDROID,
- virtual bool get_property_default_value(const StringName &p_property, Variant &r_value) const;
+ // TODO(karroffe): all different iOS versions and archs
+ IOS,
- virtual void update_exports() {} //editor tool
- virtual void get_script_method_list(List<MethodInfo> *p_list) const;
- virtual void get_script_property_list(List<PropertyInfo> *p_list) const;
+ // TODO(karroffel): figure out how to deal with web stuff at all...
+ WASM,
- Variant _new(const Variant **p_args, int p_argcount, Variant::CallError &r_error);
+ // TODO(karroffel): does UWP have different libs??
+ // UWP,
- Ref<GDNativeLibrary> get_library() const;
- void set_library(Ref<GDNativeLibrary> p_library);
+ NUM_PLATFORMS
- StringName get_script_name() const;
- void set_script_name(StringName p_script_name);
+ };
- GDNativeScript();
- ~GDNativeScript();
-};
+ static String platform_names[NUM_PLATFORMS];
+ static String platform_lib_ext[NUM_PLATFORMS];
-class GDNativeLibrary : public Resource {
- _THREAD_SAFE_CLASS_
+ // TODO(karroffel): make this actually do something lol.
+ static Platform current_platform;
- GDCLASS(GDNativeLibrary, Resource);
- OBJ_SAVE_TYPE(GDNativeLibrary);
-
- Map<StringName, String> platform_files;
- NativeLibrary *native_library;
- static GDNativeLibrary *currently_initialized_library;
+ String library_paths[NUM_PLATFORMS];
protected:
- friend class GDNativeScript;
- friend struct NativeLibrary;
- friend class GDNativeReloadNode;
-
- GDNativeScriptData *get_script_data(const StringName p_name);
-
bool _set(const StringName &p_name, const Variant &p_value);
bool _get(const StringName &p_name, Variant &r_ret) const;
void _get_property_list(List<PropertyInfo> *p_list) const;
- void _notification(int p_what);
- static void _bind_methods();
public:
- Error _initialize();
- Error _terminate();
-
- static GDNativeLibrary *get_currently_initialized_library();
-
- void _register_script(const StringName p_name, const StringName p_base, godot_instance_create_func p_instance_func, godot_instance_destroy_func p_destroy_func);
- void _register_tool_script(const StringName p_name, const StringName p_base, godot_instance_create_func p_instance_func, godot_instance_destroy_func p_destroy_func);
- void _register_script_method(const StringName p_name, const StringName p_method, godot_method_attributes p_attr, godot_instance_method p_func, MethodInfo p_info);
- void _register_script_property(const StringName p_name, const String p_path, godot_property_attributes *p_attr, godot_property_set_func p_setter, godot_property_get_func p_getter);
- void _register_script_signal(const StringName p_name, const godot_signal *p_signal);
-
- void set_platform_file(StringName p_platform, String p_file);
- String get_platform_file(StringName p_platform) const;
-
GDNativeLibrary();
~GDNativeLibrary();
-};
-
-class GDNativeInstance : public ScriptInstance {
- friend class GDNativeScript;
- Object *owner;
- Ref<GDNativeScript> script;
- void *userdata;
-
- void _ml_call_reversed(GDNativeScriptData *data_ptr, const StringName &p_method, const Variant **p_args, int p_argcount);
-
-public:
- _FORCE_INLINE_ Object *get_owner() { return owner; }
-
- _FORCE_INLINE_ void *get_userdata() { return userdata; }
-
- virtual bool set(const StringName &p_name, const Variant &p_value);
- virtual bool get(const StringName &p_name, Variant &r_ret) const;
- virtual void get_property_list(List<PropertyInfo> *p_properties) const;
- virtual Variant::Type get_property_type(const StringName &p_name, bool *r_is_valid = NULL) const;
-
- virtual void get_method_list(List<MethodInfo> *p_list) const;
- virtual bool has_method(const StringName &p_method) const;
- virtual Variant call(const StringName &p_method, const Variant **p_args, int p_argcount, Variant::CallError &r_error);
- virtual void call_multilevel(const StringName &p_method, const Variant **p_args, int p_argcount);
- virtual void call_multilevel_reversed(const StringName &p_method, const Variant **p_args, int p_argcount);
-
- Variant debug_get_member_by_index(int p_idx) const { return Variant(); }
-
- virtual void notification(int p_notification);
-
- virtual Ref<Script> get_script() const;
-
- virtual ScriptLanguage *get_language();
-
- void set_path(const String &p_path);
-
- void reload_members();
+ static void _bind_methods();
- virtual RPCMode get_rpc_mode(const StringName &p_method) const;
- virtual RPCMode get_rset_mode(const StringName &p_variable) const;
+ void set_library_path(StringName p_platform, String p_path);
+ String get_library_path(StringName p_platform) const;
- GDNativeInstance();
- ~GDNativeInstance();
+ String get_active_library_path() const;
};
-class GDNativeReloadNode;
+typedef godot_variant (*native_call_cb)(void *, godot_string *, godot_array *);
+typedef void (*native_raw_call_cb)(void *, godot_string *, void *, int, void **, void *);
-class GDNativeScriptLanguage : public ScriptLanguage {
- friend class GDNativeScript;
- friend class GDNativeInstance;
- friend class GDNativeReloadNode;
- friend class GDNativeLibrary;
+struct GDNativeCallRegistry {
+ static GDNativeCallRegistry *singleton;
- static GDNativeScriptLanguage *singleton;
+ inline GDNativeCallRegistry *get_singleton() {
+ return singleton;
+ }
- Variant *_global_array; // @Unused necessary?
- Vector<Variant> global_array; // @Unused necessary?
- Map<StringName, int> globals; // @Unused necessary?
+ inline GDNativeCallRegistry()
+ : native_calls(),
+ native_raw_calls() {}
- // @Unused necessary?
- void _add_global(const StringName &p_name, const Variant &p_value);
+ Map<StringName, native_call_cb> native_calls;
+ Map<StringName, native_raw_call_cb> native_raw_calls;
- Mutex *lock;
+ void register_native_call_type(StringName p_call_type, native_call_cb p_callback);
+ void register_native_raw_call_type(StringName p_raw_call_type, native_raw_call_cb p_callback);
- Set<GDNativeScript *> script_list;
+ Vector<StringName> get_native_call_types();
+ Vector<StringName> get_native_raw_call_types();
+};
- bool profiling;
- uint64_t script_frame_time;
+class GDNative : public Reference {
+ GDCLASS(GDNative, Reference)
- struct {
+ Ref<GDNativeLibrary> library;
+ bool initialized;
- StringName _notification;
+ // TODO(karroffel): different platforms? WASM????
+ void *native_handle;
- } strings;
+ void _compile_dummy_for_api();
public:
- Map<StringName, NativeLibrary *> initialized_libraries;
-
- _FORCE_INLINE_ static GDNativeScriptLanguage *get_singleton() { return singleton; }
-
- virtual String get_name() const;
-
- /* LANGUAGE FUNCTIONS */
- virtual void init();
- virtual String get_type() const;
- virtual String get_extension() const;
- virtual Error execute_file(const String &p_path);
- virtual void finish();
-
- /* EDITOR FUNCTIONS */
-
- virtual void get_reserved_words(List<String> *p_words) const {};
- virtual void get_comment_delimiters(List<String> *p_delimiters) const {};
- virtual void get_string_delimiters(List<String> *p_delimiters) const {};
- virtual Ref<Script> get_template(const String &p_class_name, const String &p_base_class_name) const;
- virtual bool validate(const String &p_script, int &r_line_error, int &r_col_error, String &r_test_error, const String &p_path = "", List<String> *r_functions = NULL) const;
- virtual Script *create_script() const;
- virtual bool has_named_classes() const;
- virtual int find_function(const String &p_function, const String &p_code) const;
- virtual String make_function(const String &p_class, const String &p_name, const PoolStringArray &p_args) const;
- virtual Error open_in_external_editor(const Ref<Script> &p_script, int p_line, int p_col) { return ERR_UNAVAILABLE; }
- virtual Error complete_code(const String &p_code, const String &p_base_path, Object *p_owner, List<String> *r_options, String &r_call_hint) { return ERR_UNAVAILABLE; }
-
- virtual Error lookup_code(const String &p_code, const String &p_symbol, const String &p_base_path, Object *p_owner, LookupResult &r_result) { return ERR_UNAVAILABLE; }
+ GDNative();
+ ~GDNative();
- virtual void auto_indent_code(String &p_code, int p_from_line, int p_to_line) const {};
- virtual void add_global_constant(const StringName &p_variable, const Variant &p_value);
-
- /* MULTITHREAD FUNCTIONS */
-
- //some VMs need to be notified of thread creation/exiting to allocate a stack
- virtual void thread_enter() {}
- virtual void thread_exit() {}
-
- /* DEBUGGER FUNCTIONS */
-
- virtual String debug_get_error() const;
- virtual int debug_get_stack_level_count() const;
- virtual int debug_get_stack_level_line(int p_level) const;
- virtual String debug_get_stack_level_function(int p_level) const;
- virtual String debug_get_stack_level_source(int p_level) const;
- virtual void debug_get_stack_level_locals(int p_level, List<String> *p_locals, List<Variant> *p_values, int p_max_subitems = -1, int p_max_depth = -1){};
- virtual void debug_get_stack_level_members(int p_level, List<String> *p_members, List<Variant> *p_values, int p_max_subitems = -1, int p_max_depth = -1);
- virtual void debug_get_globals(List<String> *p_locals, List<Variant> *p_values, int p_max_subitems = -1, int p_max_depth = -1);
- virtual String debug_parse_stack_level_expression(int p_level, const String &p_expression, int p_max_subitems = -1, int p_max_depth = -1);
-
- virtual Vector<StackInfo> debug_get_current_stack_info() { return Vector<StackInfo>(); }
-
- virtual void reload_all_scripts();
- virtual void reload_tool_script(const Ref<Script> &p_script, bool p_soft_reload);
- /* LOADER FUNCTIONS */
-
- virtual void get_recognized_extensions(List<String> *p_extensions) const;
- virtual void get_public_functions(List<MethodInfo> *p_functions) const;
- virtual void get_public_constants(List<Pair<String, Variant> > *p_constants) const;
-
- /* PROFILLER FUNCTIONS */
-
- virtual void profiling_start();
- virtual void profiling_stop();
-
- virtual int profiling_get_accumulated_data(ProfilingInfo *p_info_arr, int p_info_max);
- virtual int profiling_get_frame_data(ProfilingInfo *p_info_arr, int p_info_max);
-
- virtual void frame();
-
- static String get_init_symbol_name();
- static String get_terminate_symbol_name();
-
- /* HACKER FUNCTIONS */
- void _compile_dummy_for_the_api();
+ static void _bind_methods();
- GDNativeScriptLanguage();
- ~GDNativeScriptLanguage();
-};
+ void set_library(Ref<GDNativeLibrary> p_library);
+ Ref<GDNativeLibrary> get_library();
-class GDNativeReloadNode : public Node {
- GDCLASS(GDNativeReloadNode, Node)
-public:
- static void _bind_methods();
- void _notification(int p_what);
-};
+ bool is_initialized();
-class ResourceFormatLoaderGDNativeScript : public ResourceFormatLoader {
-public:
- virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL);
- virtual void get_recognized_extensions(List<String> *p_extensions) const;
- virtual bool handles_type(const String &p_type) const;
- virtual String get_resource_type(const String &p_path) const;
-};
+ bool initialize();
+ bool terminate();
-class ResourceFormatSaverGDNativeScript : public ResourceFormatSaver {
- virtual Error save(const String &p_path, const RES &p_resource, uint32_t p_flags = 0);
- virtual bool recognize(const RES &p_resource) const;
- virtual void get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const;
+ Variant call_native(StringName p_call_type, StringName p_procedure_name, Array p_arguments = Array());
+ void call_native_raw(StringName p_raw_call_type, StringName p_procedure_name, void *data, int num_args, void **args, void *r_return);
};
#endif // GDNATIVE_H
diff --git a/modules/gdnative/godot/godot_array.cpp b/modules/gdnative/godot/array.cpp
index 5497dde520..c068eecf8f 100644
--- a/modules/gdnative/godot/godot_array.cpp
+++ b/modules/gdnative/godot/array.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot_array.cpp */
+/* array.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,7 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "godot_array.h"
+#include "array.h"
#include "core/array.h"
#include "core/os/memory.h"
diff --git a/modules/gdnative/godot/godot_array.h b/modules/gdnative/godot/array.h
index bf8bc61977..cbdbfbdde3 100644
--- a/modules/gdnative/godot/godot_array.h
+++ b/modules/gdnative/godot/array.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot_array.h */
+/* array.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -37,16 +37,19 @@ extern "C" {
#include <stdint.h>
+#define GODOT_ARRAY_SIZE 8
+
#ifndef GODOT_CORE_API_GODOT_ARRAY_TYPE_DEFINED
-typedef struct godot_array {
- uint8_t _dont_touch_that[8];
+#define GODOT_CORE_API_GODOT_ARRAY_TYPE_DEFINED
+typedef struct {
+ uint8_t _dont_touch_that[GODOT_ARRAY_SIZE];
} godot_array;
#endif
-#include "godot_pool_arrays.h"
-#include "godot_variant.h"
+#include "pool_arrays.h"
+#include "variant.h"
-#include "../godot.h"
+#include "gdnative.h"
void GDAPI godot_array_new(godot_array *r_dest);
void GDAPI godot_array_new_copy(godot_array *r_dest, const godot_array *p_src);
diff --git a/modules/gdnative/godot/godot_basis.cpp b/modules/gdnative/godot/basis.cpp
index 46464932c5..7188215d04 100644
--- a/modules/gdnative/godot/godot_basis.cpp
+++ b/modules/gdnative/godot/basis.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot_basis.cpp */
+/* basis.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,7 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "godot_basis.h"
+#include "basis.h"
#include "core/variant.h"
#include "core/math/matrix3.h"
diff --git a/modules/gdnative/godot/godot_basis.h b/modules/gdnative/godot/basis.h
index a096a8cc08..79b2b45fdd 100644
--- a/modules/gdnative/godot/godot_basis.h
+++ b/modules/gdnative/godot/basis.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot_basis.h */
+/* basis.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -36,15 +36,18 @@ extern "C" {
#include <stdint.h>
+#define GODOT_BASIS_SIZE 36
+
#ifndef GODOT_CORE_API_GODOT_BASIS_TYPE_DEFINED
#define GODOT_CORE_API_GODOT_BASIS_TYPE_DEFINED
-typedef struct godot_basis {
- uint8_t _dont_touch_that[36];
+typedef struct {
+ uint8_t _dont_touch_that[GODOT_BASIS_SIZE];
} godot_basis;
#endif
-#include "../godot.h"
-#include "godot_vector3.h"
+#include "gdnative.h"
+#include "quat.h"
+#include "vector3.h"
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);
diff --git a/modules/gdnative/godot/godot_color.cpp b/modules/gdnative/godot/color.cpp
index 6dedf2ab10..eac966ca1f 100644
--- a/modules/gdnative/godot/godot_color.cpp
+++ b/modules/gdnative/godot/color.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot_color.cpp */
+/* color.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,7 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "godot_color.h"
+#include "color.h"
#include "core/variant.h"
#include "core/color.h"
diff --git a/modules/gdnative/godot/godot_color.h b/modules/gdnative/godot/color.h
index 10dc228b1c..77e709fbe3 100644
--- a/modules/gdnative/godot/godot_color.h
+++ b/modules/gdnative/godot/color.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot_color.h */
+/* color.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -36,15 +36,17 @@ extern "C" {
#include <stdint.h>
+#define GODOT_COLOR_SIZE 16
+
#ifndef GODOT_CORE_API_GODOT_COLOR_TYPE_DEFINED
#define GODOT_CORE_API_GODOT_COLOR_TYPE_DEFINED
-typedef struct godot_color {
- uint8_t _dont_touch_that[16];
+typedef struct {
+ uint8_t _dont_touch_that[GODOT_COLOR_SIZE];
} godot_color;
#endif
-#include "../godot.h"
-#include "godot_string.h"
+#include "gdnative.h"
+#include "string.h"
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/godot/godot_dictionary.cpp b/modules/gdnative/godot/dictionary.cpp
index 12c40f0564..1c0761edfd 100644
--- a/modules/gdnative/godot/godot_dictionary.cpp
+++ b/modules/gdnative/godot/dictionary.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot_dictionary.cpp */
+/* dictionary.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,7 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "godot_dictionary.h"
+#include "dictionary.h"
#include "core/variant.h"
#include "core/dictionary.h"
@@ -124,11 +124,17 @@ void GDAPI godot_dictionary_set(godot_dictionary *p_self, const godot_variant *p
}
godot_variant GDAPI *godot_dictionary_operator_index(godot_dictionary *p_self, const godot_variant *p_key) {
- Array *self = (Array *)p_self;
+ Dictionary *self = (Dictionary *)p_self;
const Variant *key = (const Variant *)p_key;
return (godot_variant *)&self->operator[](*key);
}
+godot_variant GDAPI *godot_dictionary_next(const godot_dictionary *p_self, const godot_variant *p_key) {
+ Dictionary *self = (Dictionary *)p_self;
+ const Variant *key = (const Variant *)p_key;
+ return (godot_variant *)self->next(key);
+}
+
godot_bool GDAPI godot_dictionary_operator_equal(const godot_dictionary *p_self, const godot_dictionary *p_b) {
const Dictionary *self = (const Dictionary *)p_self;
const Dictionary *b = (const Dictionary *)p_b;
diff --git a/modules/gdnative/godot/godot_dictionary.h b/modules/gdnative/godot/dictionary.h
index 0325670b15..a08deb27df 100644
--- a/modules/gdnative/godot/godot_dictionary.h
+++ b/modules/gdnative/godot/dictionary.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot_dictionary.h */
+/* dictionary.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -36,16 +36,18 @@ extern "C" {
#include <stdint.h>
+#define GODOT_DICTIONARY_SIZE 8
+
#ifndef GODOT_CORE_API_GODOT_DICTIONARY_TYPE_DEFINED
#define GODOT_CORE_API_GODOT_DICTIONARY_TYPE_DEFINED
-typedef struct godot_dictionary {
- uint8_t _dont_touch_that[8];
+typedef struct {
+ uint8_t _dont_touch_that[GODOT_DICTIONARY_SIZE];
} godot_dictionary;
#endif
-#include "../godot.h"
-#include "godot_array.h"
-#include "godot_variant.h"
+#include "array.h"
+#include "gdnative.h"
+#include "variant.h"
void GDAPI godot_dictionary_new(godot_dictionary *r_dest);
void GDAPI godot_dictionary_new_copy(godot_dictionary *r_dest, const godot_dictionary *p_src);
@@ -74,6 +76,8 @@ void GDAPI godot_dictionary_set(godot_dictionary *p_self, const godot_variant *p
godot_variant GDAPI *godot_dictionary_operator_index(godot_dictionary *p_self, const godot_variant *p_key);
+godot_variant GDAPI *godot_dictionary_next(const godot_dictionary *p_self, const godot_variant *p_key);
+
godot_bool GDAPI godot_dictionary_operator_equal(const godot_dictionary *p_self, const godot_dictionary *p_b);
godot_string GDAPI godot_dictionary_to_json(const godot_dictionary *p_self);
diff --git a/modules/gdnative/godot.cpp b/modules/gdnative/godot/gdnative.cpp
index 4dbb72bba1..29b499ebab 100644
--- a/modules/gdnative/godot.cpp
+++ b/modules/gdnative/godot/gdnative.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot.cpp */
+/* gdnative.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,13 +27,14 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "godot.h"
+#include "gdnative.h"
#include "class_db.h"
#include "error_macros.h"
#include "gdnative.h"
-#include "global_config.h"
#include "global_constants.h"
+#include "os/os.h"
+#include "project_settings.h"
#include "variant.h"
#ifdef __cplusplus
@@ -79,13 +80,6 @@ void _api_anchor() {
_variant_api_anchor();
}
-extern "C++" {
-template <class a, class b>
-_FORCE_INLINE_ a memcast(b v) {
- return *((a *)&v);
-}
-}
-
void GDAPI godot_object_destroy(godot_object *p_o) {
memdelete((Object *)p_o);
}
@@ -93,9 +87,13 @@ void GDAPI godot_object_destroy(godot_object *p_o) {
// Singleton API
godot_object GDAPI *godot_global_get_singleton(char *p_name) {
- return (godot_object *)GlobalConfig::get_singleton()->get_singleton_object(String(p_name));
+ return (godot_object *)ProjectSettings::get_singleton()->get_singleton_object(String(p_name));
} // result shouldn't be freed
+void GDAPI *godot_get_stack_bottom() {
+ return OS::get_singleton()->get_stack_bottom();
+}
+
// MethodBind API
godot_method_bind GDAPI *godot_method_bind_get_method(const char *p_classname, const char *p_methodname) {
@@ -142,65 +140,6 @@ void GDAPI godot_method_bind_varcall(godot_method_bind *p_method_bind)
}
*/
-// Script API
-
-void GDAPI godot_script_register_class(const char *p_name, const char *p_base, godot_instance_create_func p_create_func, godot_instance_destroy_func p_destroy_func) {
- GDNativeLibrary *library = GDNativeLibrary::get_currently_initialized_library();
- if (!library) {
- ERR_EXPLAIN("Attempt to register script after initializing library!");
- ERR_FAIL();
- }
- library->_register_script(p_name, p_base, p_create_func, p_destroy_func);
-}
-
-void GDAPI godot_script_register_tool_class(const char *p_name, const char *p_base, godot_instance_create_func p_create_func, godot_instance_destroy_func p_destroy_func) {
- GDNativeLibrary *library = GDNativeLibrary::get_currently_initialized_library();
- if (!library) {
- ERR_EXPLAIN("Attempt to register script after initializing library!");
- ERR_FAIL();
- }
- library->_register_tool_script(p_name, p_base, p_create_func, p_destroy_func);
-}
-
-void GDAPI godot_script_register_method(const char *p_name, const char *p_function_name, godot_method_attributes p_attr, godot_instance_method p_method) {
- GDNativeLibrary *library = GDNativeLibrary::get_currently_initialized_library();
- if (!library) {
- ERR_EXPLAIN("Attempt to register script after initializing library!");
- ERR_FAIL();
- }
- library->_register_script_method(p_name, p_function_name, p_attr, p_method, MethodInfo());
-}
-
-void GDAPI godot_script_register_property(const char *p_name, const char *p_path, godot_property_attributes *p_attr, godot_property_set_func p_set_func, godot_property_get_func p_get_func) {
- GDNativeLibrary *library = GDNativeLibrary::get_currently_initialized_library();
- if (!library) {
- ERR_EXPLAIN("Attempt to register script after initializing library!");
- ERR_FAIL();
- }
-
- library->_register_script_property(p_name, p_path, p_attr, p_set_func, p_get_func);
-}
-
-void GDAPI godot_script_register_signal(const char *p_name, const godot_signal *p_signal) {
- GDNativeLibrary *library = GDNativeLibrary::get_currently_initialized_library();
- if (!library) {
- ERR_EXPLAIN("Attempt to register script after initializing library!");
- ERR_FAIL();
- }
-
- library->_register_script_signal(p_name, p_signal);
-}
-
-void GDAPI *godot_native_get_userdata(godot_object *p_instance) {
- Object *instance = (Object *)p_instance;
- if (!instance)
- return NULL;
- if (instance->get_script_instance() && instance->get_script_instance()->get_language() == GDNativeScriptLanguage::get_singleton()) {
- return ((GDNativeInstance *)instance->get_script_instance())->get_userdata();
- }
- return NULL;
-}
-
godot_class_constructor GDAPI godot_get_class_constructor(const char *p_classname) {
ClassDB::ClassInfo *class_info = ClassDB::classes.getptr(StringName(p_classname));
if (class_info)
diff --git a/modules/gdnative/godot/gdnative.h b/modules/gdnative/godot/gdnative.h
new file mode 100644
index 0000000000..b0343272ef
--- /dev/null
+++ b/modules/gdnative/godot/gdnative.h
@@ -0,0 +1,303 @@
+/*************************************************************************/
+/* gdnative.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+#ifndef GODOT_GDNATIVE_H
+#define GODOT_GDNATIVE_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef GDAPI_BUILT_IN
+#define GDAPI_EXPORT
+#endif
+
+#ifdef _WIN32
+#if defined(GDAPI_EXPORT)
+#define GDCALLINGCONV
+#define GDAPI __declspec(dllexport) GDCALLINGCONV
+#else
+#define GDCALLINGCONV
+#define GDAPI __declspec(dllimport) GDCALLINGCONV
+#endif
+#elif defined(__APPLE__)
+#include "TargetConditionals.h"
+#if TARGET_OS_IPHONE
+#define GDCALLINGCONV
+#define GDAPI
+#elif TARGET_OS_MAC
+#define GDCALLINGCONV __attribute__((sysv_abi))
+#define GDAPI GDCALLINGCONV
+#endif
+#else
+#define GDCALLINGCONV __attribute__((sysv_abi))
+#define GDAPI GDCALLINGCONV
+#endif
+
+// This is for libraries *using* the header, NOT GODOT EXPOSING STUFF!!
+#ifdef _WIN32
+#define GDN_EXPORT __declspec(dllexport)
+#else
+#define GDN_EXPORT
+#endif
+
+#include <stdbool.h>
+#include <stdint.h>
+
+#define GODOT_API_VERSION 1
+
+////// Error
+
+typedef enum {
+ GODOT_OK,
+ GODOT_FAILED, ///< Generic fail error
+ GODOT_ERR_UNAVAILABLE, ///< What is requested is unsupported/unavailable
+ GODOT_ERR_UNCONFIGURED, ///< The object being used hasnt been properly set up yet
+ GODOT_ERR_UNAUTHORIZED, ///< Missing credentials for requested resource
+ GODOT_ERR_PARAMETER_RANGE_ERROR, ///< Parameter given out of range (5)
+ GODOT_ERR_OUT_OF_MEMORY, ///< Out of memory
+ GODOT_ERR_FILE_NOT_FOUND,
+ GODOT_ERR_FILE_BAD_DRIVE,
+ GODOT_ERR_FILE_BAD_PATH,
+ GODOT_ERR_FILE_NO_PERMISSION, // (10)
+ GODOT_ERR_FILE_ALREADY_IN_USE,
+ GODOT_ERR_FILE_CANT_OPEN,
+ GODOT_ERR_FILE_CANT_WRITE,
+ GODOT_ERR_FILE_CANT_READ,
+ GODOT_ERR_FILE_UNRECOGNIZED, // (15)
+ GODOT_ERR_FILE_CORRUPT,
+ GODOT_ERR_FILE_MISSING_DEPENDENCIES,
+ GODOT_ERR_FILE_EOF,
+ GODOT_ERR_CANT_OPEN, ///< Can't open a resource/socket/file
+ GODOT_ERR_CANT_CREATE, // (20)
+ GODOT_ERR_QUERY_FAILED,
+ GODOT_ERR_ALREADY_IN_USE,
+ GODOT_ERR_LOCKED, ///< resource is locked
+ GODOT_ERR_TIMEOUT,
+ GODOT_ERR_CANT_CONNECT, // (25)
+ GODOT_ERR_CANT_RESOLVE,
+ GODOT_ERR_CONNECTION_ERROR,
+ GODOT_ERR_CANT_AQUIRE_RESOURCE,
+ GODOT_ERR_CANT_FORK,
+ GODOT_ERR_INVALID_DATA, ///< Data passed is invalid (30)
+ GODOT_ERR_INVALID_PARAMETER, ///< Parameter passed is invalid
+ GODOT_ERR_ALREADY_EXISTS, ///< When adding, item already exists
+ GODOT_ERR_DOES_NOT_EXIST, ///< When retrieving/erasing, it item does not exist
+ GODOT_ERR_DATABASE_CANT_READ, ///< database is full
+ GODOT_ERR_DATABASE_CANT_WRITE, ///< database is full (35)
+ GODOT_ERR_COMPILATION_FAILED,
+ GODOT_ERR_METHOD_NOT_FOUND,
+ GODOT_ERR_LINK_FAILED,
+ GODOT_ERR_SCRIPT_FAILED,
+ GODOT_ERR_CYCLIC_LINK, // (40)
+ GODOT_ERR_INVALID_DECLARATION,
+ GODOT_ERR_DUPLICATE_SYMBOL,
+ GODOT_ERR_PARSE_ERROR,
+ GODOT_ERR_BUSY,
+ GODOT_ERR_SKIP, // (45)
+ GODOT_ERR_HELP, ///< user requested help!!
+ GODOT_ERR_BUG, ///< a bug in the software certainly happened, due to a double check failing or unexpected behavior.
+ GODOT_ERR_PRINTER_ON_FIRE, /// the parallel port printer is engulfed in flames
+ GODOT_ERR_OMFG_THIS_IS_VERY_VERY_BAD, ///< shit happens, has never been used, though
+ GODOT_ERR_WTF = GODOT_ERR_OMFG_THIS_IS_VERY_VERY_BAD ///< short version of the above
+} godot_error;
+
+////// bool
+
+typedef bool godot_bool;
+
+#define GODOT_TRUE 1
+#define GODOT_FALSE 0
+
+/////// int
+
+typedef int godot_int;
+
+/////// real
+
+typedef float godot_real;
+
+/////// Object (forward declared)
+typedef void godot_object;
+
+/////// Brute force forward declarations for the rest
+/*
+typedef struct godot_variant godot_variant;
+typedef struct godot_string godot_string;
+typedef struct godot_vector2 godot_vector2;
+typedef struct godot_rect2 godot_rect2;
+typedef struct godot_vector3 godot_vector3;
+typedef struct godot_transform2d godot_transform2d;
+typedef struct godot_plane godot_plane;
+typedef struct godot_quat godot_quat;
+typedef struct godot_rect3 godot_rect3;
+typedef struct godot_basis godot_basis;
+typedef struct godot_transform godot_transform;
+typedef struct godot_color godot_color;
+typedef struct godot_node_path godot_node_path;
+typedef struct godot_rid godot_rid;
+typedef struct godot_dictionary godot_dictionary;
+typedef struct godot_array godot_array;
+typedef struct godot_pool_byte_array godot_pool_byte_array;
+typedef struct godot_pool_int_array godot_pool_int_array;
+typedef struct godot_pool_real_array godot_pool_real_array;
+typedef struct godot_pool_string_array godot_pool_string_array;
+typedef struct godot_pool_vector2_array godot_pool_vector2_array;
+typedef struct godot_pool_vector3_array godot_pool_vector3_array;
+typedef struct godot_pool_color_array godot_pool_color_array;
+*/
+/////// String
+
+#include "string.h"
+
+////// Vector2
+
+#include "vector2.h"
+
+////// Rect2
+
+#include "rect2.h"
+
+////// Vector3
+
+#include "vector3.h"
+
+////// Transform2D
+
+#include "transform2d.h"
+
+/////// Plane
+
+#include "plane.h"
+
+/////// Quat
+
+#include "quat.h"
+
+/////// Rect3
+
+#include "rect3.h"
+
+/////// Basis
+
+#include "basis.h"
+
+/////// Transform
+
+#include "transform.h"
+
+/////// Color
+
+#include "color.h"
+
+/////// NodePath
+
+#include "node_path.h"
+
+/////// RID
+
+#include "rid.h"
+
+/////// Dictionary
+
+#include "dictionary.h"
+
+/////// Array
+
+#include "array.h"
+
+// single API file for Pool*Array
+#include "pool_arrays.h"
+
+void GDAPI godot_object_destroy(godot_object *p_o);
+
+////// Variant
+
+#include "variant.h"
+
+////// Singleton API
+
+godot_object GDAPI *godot_global_get_singleton(char *p_name); // result shouldn't be freed
+
+////// OS API
+
+void GDAPI *godot_get_stack_bottom(); // returns stack bottom of the main thread
+
+////// MethodBind API
+
+typedef struct {
+ uint8_t _dont_touch_that[1]; // TODO
+} godot_method_bind;
+
+godot_method_bind GDAPI *godot_method_bind_get_method(const char *p_classname, const char *p_methodname);
+void GDAPI godot_method_bind_ptrcall(godot_method_bind *p_method_bind, godot_object *p_instance, const void **p_args, void *p_ret);
+godot_variant GDAPI godot_method_bind_call(godot_method_bind *p_method_bind, godot_object *p_instance, const godot_variant **p_args, const int p_arg_count, godot_variant_call_error *p_call_error);
+////// Script API
+
+typedef struct {
+ godot_bool in_editor;
+ uint64_t core_api_hash;
+ uint64_t editor_api_hash;
+ uint64_t no_api_hash;
+ godot_object *gd_native_library; // pointer to GDNativeLibrary that is being initialized
+} godot_gdnative_init_options;
+
+typedef struct {
+ godot_bool in_editor;
+} godot_gdnative_terminate_options;
+
+// Calling convention?
+typedef godot_object *(*godot_class_constructor)();
+
+godot_class_constructor GDAPI godot_get_class_constructor(const char *p_classname);
+
+godot_dictionary GDAPI godot_get_global_constants();
+
+////// GDNative procedure types
+typedef void (*godot_gdnative_init_fn)(godot_gdnative_init_options *);
+typedef void (*godot_gdnative_terminate_fn)(godot_gdnative_terminate_options *);
+typedef godot_variant (*godot_gdnative_procedure_fn)(void *, godot_array *);
+
+////// System Functions
+
+//using these will help Godot track how much memory is in use in debug mode
+void GDAPI *godot_alloc(int p_bytes);
+void GDAPI *godot_realloc(void *p_ptr, int p_bytes);
+void GDAPI godot_free(void *p_ptr);
+
+//print using Godot's error handler list
+void GDAPI godot_print_error(const char *p_description, const char *p_function, const char *p_file, int p_line);
+void GDAPI godot_print_warning(const char *p_description, const char *p_function, const char *p_file, int p_line);
+void GDAPI godot_print(const godot_string *p_message);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // GODOT_C_H
diff --git a/modules/gdnative/godot/icon.png.import b/modules/gdnative/godot/icon.png.import
new file mode 100644
index 0000000000..27920124f9
--- /dev/null
+++ b/modules/gdnative/godot/icon.png.import
@@ -0,0 +1,23 @@
+[remap]
+
+importer="texture"
+type="StreamTexture"
+path="res://.import/icon.png-aa47d037a37fb38b3b7e7828e4eec407.stex"
+
+[params]
+
+compress/mode=0
+compress/lossy_quality=0.7
+compress/hdr_mode=0
+compress/normal_map=0
+flags/repeat=0
+flags/filter=true
+flags/mipmaps=false
+flags/anisotropic=false
+flags/srgb=2
+process/fix_alpha_border=true
+process/premult_alpha=false
+process/HDR_as_SRGB=false
+stream=false
+size_limit=0
+detect_3d=true
diff --git a/modules/gdnative/godot/godot_node_path.cpp b/modules/gdnative/godot/node_path.cpp
index c8eacd05af..a9edbc8352 100644
--- a/modules/gdnative/godot/godot_node_path.cpp
+++ b/modules/gdnative/godot/node_path.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot_node_path.cpp */
+/* node_path.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,7 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "godot_node_path.h"
+#include "node_path.h"
#include "core/variant.h"
#include "core/path_db.h"
diff --git a/modules/gdnative/godot/godot_node_path.h b/modules/gdnative/godot/node_path.h
index b0c9d44859..06955a052e 100644
--- a/modules/gdnative/godot/godot_node_path.h
+++ b/modules/gdnative/godot/node_path.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot_node_path.h */
+/* node_path.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -36,15 +36,17 @@ extern "C" {
#include <stdint.h>
+#define GODOT_NODE_PATH_SIZE 8
+
#ifndef GODOT_CORE_API_GODOT_NODE_PATH_TYPE_DEFINED
#define GODOT_CORE_API_GODOT_NODE_PATH_TYPE_DEFINED
-typedef struct godot_node_path {
- uint8_t _dont_touch_that[8];
+typedef struct {
+ uint8_t _dont_touch_that[GODOT_NODE_PATH_SIZE];
} godot_node_path;
#endif
-#include "../godot.h"
-#include "godot_string.h"
+#include "gdnative.h"
+#include "string.h"
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);
diff --git a/modules/gdnative/godot/godot_plane.cpp b/modules/gdnative/godot/plane.cpp
index 68adbd4a98..e9e659e5da 100644
--- a/modules/gdnative/godot/godot_plane.cpp
+++ b/modules/gdnative/godot/plane.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot_plane.cpp */
+/* plane.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,7 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "godot_plane.h"
+#include "plane.h"
#include "core/variant.h"
#include "core/math/plane.h"
diff --git a/modules/gdnative/godot/godot_plane.h b/modules/gdnative/godot/plane.h
index cfc955f277..e9e3b71e03 100644
--- a/modules/gdnative/godot/godot_plane.h
+++ b/modules/gdnative/godot/plane.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot_plane.h */
+/* plane.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -36,15 +36,17 @@ extern "C" {
#include <stdint.h>
+#define GODOT_PLANE_SIZE 16
+
#ifndef GODOT_CORE_API_GODOT_PLANE_TYPE_DEFINED
#define GODOT_CORE_API_GODOT_PLANE_TYPE_DEFINED
-typedef struct godot_plane {
- uint8_t _dont_touch_that[16];
+typedef struct {
+ uint8_t _dont_touch_that[GODOT_PLANE_SIZE];
} godot_plane;
#endif
-#include "../godot.h"
-#include "godot_vector3.h"
+#include "gdnative.h"
+#include "vector3.h"
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);
diff --git a/modules/gdnative/godot/godot_pool_arrays.cpp b/modules/gdnative/godot/pool_arrays.cpp
index ea9aceea81..6a6ee0f126 100644
--- a/modules/gdnative/godot/godot_pool_arrays.cpp
+++ b/modules/gdnative/godot/pool_arrays.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot_pool_arrays.cpp */
+/* pool_arrays.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,11 +27,15 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "godot_pool_arrays.h"
+#include "pool_arrays.h"
#include "array.h"
+#include "core/variant.h"
#include "dvector.h"
-#include "variant.h"
+
+#include "core/color.h"
+#include "core/math/math_2d.h"
+#include "core/math/vector3.h"
#ifdef __cplusplus
extern "C" {
diff --git a/modules/gdnative/godot/godot_pool_arrays.h b/modules/gdnative/godot/pool_arrays.h
index a794d03f01..1e2916cea9 100644
--- a/modules/gdnative/godot/godot_pool_arrays.h
+++ b/modules/gdnative/godot/pool_arrays.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot_pool_arrays.h */
+/* pool_arrays.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -38,66 +38,87 @@ extern "C" {
/////// PoolByteArray
+#define GODOT_POOL_BYTE_ARRAY_SIZE 8
+
#ifndef GODOT_CORE_API_GODOT_POOL_BYTE_ARRAY_TYPE_DEFINED
-typedef struct godot_pool_byte_array {
- uint8_t _dont_touch_that[8];
+#define GODOT_CORE_API_GODOT_POOL_BYTE_ARRAY_TYPE_DEFINED
+typedef struct {
+ uint8_t _dont_touch_that[GODOT_POOL_BYTE_ARRAY_SIZE];
} godot_pool_byte_array;
#endif
/////// PoolIntArray
+#define GODOT_POOL_INT_ARRAY_SIZE 8
+
#ifndef GODOT_CORE_API_GODOT_POOL_INT_ARRAY_TYPE_DEFINED
-typedef struct godot_pool_int_array {
- uint8_t _dont_touch_that[8];
+#define GODOT_CORE_API_GODOT_POOL_INT_ARRAY_TYPE_DEFINED
+typedef struct {
+ uint8_t _dont_touch_that[GODOT_POOL_INT_ARRAY_SIZE];
} godot_pool_int_array;
#endif
/////// PoolRealArray
+#define GODOT_POOL_REAL_ARRAY_SIZE 8
+
#ifndef GODOT_CORE_API_GODOT_POOL_REAL_ARRAY_TYPE_DEFINED
-typedef struct godot_pool_real_array {
- uint8_t _dont_touch_that[8];
+#define GODOT_CORE_API_GODOT_POOL_REAL_ARRAY_TYPE_DEFINED
+typedef struct {
+ uint8_t _dont_touch_that[GODOT_POOL_REAL_ARRAY_SIZE];
} godot_pool_real_array;
#endif
/////// PoolStringArray
+#define GODOT_POOL_STRING_ARRAY_SIZE 8
+
#ifndef GODOT_CORE_API_GODOT_POOL_STRING_ARRAY_TYPE_DEFINED
-typedef struct godot_pool_string_array {
- uint8_t _dont_touch_that[8];
+#define GODOT_CORE_API_GODOT_POOL_STRING_ARRAY_TYPE_DEFINED
+typedef struct {
+ uint8_t _dont_touch_that[GODOT_POOL_STRING_ARRAY_SIZE];
} godot_pool_string_array;
#endif
/////// PoolVector2Array
+#define GODOT_POOL_VECTOR2_ARRAY_SIZE 8
+
#ifndef GODOT_CORE_API_GODOT_POOL_VECTOR2_ARRAY_TYPE_DEFINED
-typedef struct godot_pool_vector2_array {
- uint8_t _dont_touch_that[8];
+#define GODOT_CORE_API_GODOT_POOL_VECTOR2_ARRAY_TYPE_DEFINED
+typedef struct {
+ uint8_t _dont_touch_that[GODOT_POOL_VECTOR2_ARRAY_SIZE];
} godot_pool_vector2_array;
#endif
/////// PoolVector3Array
+#define GODOT_POOL_VECTOR3_ARRAY_SIZE 8
+
#ifndef GODOT_CORE_API_GODOT_POOL_VECTOR3_ARRAY_TYPE_DEFINED
-typedef struct godot_pool_vector3_array {
- uint8_t _dont_touch_that[8];
+#define GODOT_CORE_API_GODOT_POOL_VECTOR3_ARRAY_TYPE_DEFINED
+typedef struct {
+ uint8_t _dont_touch_that[GODOT_POOL_VECTOR3_ARRAY_SIZE];
} godot_pool_vector3_array;
#endif
/////// PoolColorArray
+#define GODOT_POOL_COLOR_ARRAY_SIZE 8
+
#ifndef GODOT_CORE_API_GODOT_POOL_COLOR_ARRAY_TYPE_DEFINED
-typedef struct godot_pool_color_array {
- uint8_t _dont_touch_that[8];
+#define GODOT_CORE_API_GODOT_POOL_COLOR_ARRAY_TYPE_DEFINED
+typedef struct {
+ uint8_t _dont_touch_that[GODOT_POOL_COLOR_ARRAY_SIZE];
} godot_pool_color_array;
#endif
-#include "godot_array.h"
-#include "godot_color.h"
-#include "godot_vector2.h"
-#include "godot_vector3.h"
+#include "array.h"
+#include "color.h"
+#include "vector2.h"
+#include "vector3.h"
-#include "../godot.h"
+#include "gdnative.h"
// byte
diff --git a/modules/gdnative/godot/godot_quat.cpp b/modules/gdnative/godot/quat.cpp
index 7235e4fcec..6800f7fc7e 100644
--- a/modules/gdnative/godot/godot_quat.cpp
+++ b/modules/gdnative/godot/quat.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot_quat.cpp */
+/* quat.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,7 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "godot_quat.h"
+#include "quat.h"
#include "core/variant.h"
#include "core/math/quat.h"
diff --git a/modules/gdnative/godot/godot_quat.h b/modules/gdnative/godot/quat.h
index 2289b6cbab..b86cbacc62 100644
--- a/modules/gdnative/godot/godot_quat.h
+++ b/modules/gdnative/godot/quat.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot_quat.h */
+/* quat.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -36,15 +36,17 @@ extern "C" {
#include <stdint.h>
+#define GODOT_QUAT_SIZE 16
+
#ifndef GODOT_CORE_API_GODOT_QUAT_TYPE_DEFINED
#define GODOT_CORE_API_GODOT_QUAT_TYPE_DEFINED
-typedef struct godot_quat {
- uint8_t _dont_touch_that[16];
+typedef struct {
+ uint8_t _dont_touch_that[GODOT_QUAT_SIZE];
} godot_quat;
#endif
-#include "../godot.h"
-#include "godot_vector3.h"
+#include "gdnative.h"
+#include "vector3.h"
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/godot/godot_rect2.cpp b/modules/gdnative/godot/rect2.cpp
index 0e456ea3ba..830d7bb496 100644
--- a/modules/gdnative/godot/godot_rect2.cpp
+++ b/modules/gdnative/godot/rect2.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot_rect2.cpp */
+/* rect2.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,7 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "godot_rect2.h"
+#include "rect2.h"
#include "core/variant.h"
#include "core/math/math_2d.h"
diff --git a/modules/gdnative/godot/godot_rect2.h b/modules/gdnative/godot/rect2.h
index 488a1204f7..7b6613d9dd 100644
--- a/modules/gdnative/godot/godot_rect2.h
+++ b/modules/gdnative/godot/rect2.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot_rect2.h */
+/* rect2.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -43,8 +43,8 @@ typedef struct godot_rect2 {
} godot_rect2;
#endif
-#include "../godot.h"
-#include "godot_vector2.h"
+#include "gdnative.h"
+#include "vector2.h"
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/godot/godot_rect3.cpp b/modules/gdnative/godot/rect3.cpp
index e524fa8463..0fabba5b7b 100644
--- a/modules/gdnative/godot/godot_rect3.cpp
+++ b/modules/gdnative/godot/rect3.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot_rect3.cpp */
+/* rect3.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,7 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "godot_rect3.h"
+#include "rect3.h"
#include "core/variant.h"
#include "core/math/rect3.h"
diff --git a/modules/gdnative/godot/godot_rect3.h b/modules/gdnative/godot/rect3.h
index 9e9a49ac27..638d89f76f 100644
--- a/modules/gdnative/godot/godot_rect3.h
+++ b/modules/gdnative/godot/rect3.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot_rect3.h */
+/* rect3.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -36,16 +36,18 @@ extern "C" {
#include <stdint.h>
+#define GODOT_RECT3_SIZE 24
+
#ifndef GODOT_CORE_API_GODOT_RECT3_TYPE_DEFINED
#define GODOT_CORE_API_GODOT_RECT3_TYPE_DEFINED
-typedef struct godot_rect3 {
- uint8_t _dont_touch_that[24];
+typedef struct {
+ uint8_t _dont_touch_that[GODOT_RECT3_SIZE];
} godot_rect3;
#endif
-#include "../godot.h"
-#include "godot_plane.h"
-#include "godot_vector3.h"
+#include "gdnative.h"
+#include "plane.h"
+#include "vector3.h"
void GDAPI godot_rect3_new(godot_rect3 *r_dest, const godot_vector3 *p_pos, const godot_vector3 *p_size);
diff --git a/modules/gdnative/godot/godot_rid.cpp b/modules/gdnative/godot/rid.cpp
index 343c004bff..2b724e554d 100644
--- a/modules/gdnative/godot/godot_rid.cpp
+++ b/modules/gdnative/godot/rid.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot_rid.cpp */
+/* rid.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,7 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "godot_rid.h"
+#include "rid.h"
#include "core/variant.h"
#include "core/resource.h"
diff --git a/modules/gdnative/godot/godot_rid.h b/modules/gdnative/godot/rid.h
index 25dc8d965e..92e101fd2e 100644
--- a/modules/gdnative/godot/godot_rid.h
+++ b/modules/gdnative/godot/rid.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot_rid.h */
+/* rid.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -36,14 +36,16 @@ extern "C" {
#include <stdint.h>
+#define GODOT_RID_SIZE 8
+
#ifndef GODOT_CORE_API_GODOT_RID_TYPE_DEFINED
#define GODOT_CORE_API_GODOT_RID_TYPE_DEFINED
-typedef struct godot_rid {
- uint8_t _dont_touch_that[8];
+typedef struct {
+ uint8_t _dont_touch_that[GODOT_RID_SIZE];
} godot_rid;
#endif
-#include "../godot.h"
+#include "gdnative.h"
void GDAPI godot_rid_new(godot_rid *r_dest);
diff --git a/modules/gdnative/godot/godot_string.cpp b/modules/gdnative/godot/string.cpp
index 679011e715..e54ef3655f 100644
--- a/modules/gdnative/godot/godot_string.cpp
+++ b/modules/gdnative/godot/string.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot_string.cpp */
+/* string.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,7 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "godot_string.h"
+#include "string.h"
#include "string_db.h"
#include "ustring.h"
diff --git a/modules/gdnative/godot/godot_string.h b/modules/gdnative/godot/string.h
index df848abb76..d4d6d6c1d0 100644
--- a/modules/gdnative/godot/godot_string.h
+++ b/modules/gdnative/godot/string.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot_string.h */
+/* string.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -37,13 +37,16 @@ extern "C" {
#include <stdint.h>
#include <wchar.h>
+#define GODOT_STRING_SIZE 8
+
#ifndef GODOT_CORE_API_GODOT_STRING_TYPE_DEFINED
-typedef struct godot_string {
- uint8_t _dont_touch_that[8];
+#define GODOT_CORE_API_GODOT_STRING_TYPE_DEFINED
+typedef struct {
+ uint8_t _dont_touch_that[GODOT_STRING_SIZE];
} godot_string;
#endif
-#include "../godot.h"
+#include "gdnative.h"
void GDAPI godot_string_new(godot_string *r_dest);
void GDAPI godot_string_new_copy(godot_string *r_dest, const godot_string *p_src);
diff --git a/modules/gdnative/godot/godot_transform.cpp b/modules/gdnative/godot/transform.cpp
index eb9e1e207b..e566ed0b6e 100644
--- a/modules/gdnative/godot/godot_transform.cpp
+++ b/modules/gdnative/godot/transform.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot_transform.cpp */
+/* transform.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,7 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "godot_transform.h"
+#include "transform.h"
#include "core/variant.h"
#include "core/math/transform.h"
diff --git a/modules/gdnative/godot/godot_transform.h b/modules/gdnative/godot/transform.h
index ee87e1d33f..d14190ec49 100644
--- a/modules/gdnative/godot/godot_transform.h
+++ b/modules/gdnative/godot/transform.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot_transform.h */
+/* transform.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -36,17 +36,19 @@ extern "C" {
#include <stdint.h>
+#define GODOT_TRANSFORM_SIZE 48
+
#ifndef GODOT_CORE_API_GODOT_TRANSFORM_TYPE_DEFINED
#define GODOT_CORE_API_GODOT_TRANSFORM_TYPE_DEFINED
-typedef struct godot_transform {
- uint8_t _dont_touch_that[48];
+typedef struct {
+ uint8_t _dont_touch_that[GODOT_TRANSFORM_SIZE];
} godot_transform;
#endif
-#include "../godot.h"
-#include "godot_basis.h"
-#include "godot_variant.h"
-#include "godot_vector3.h"
+#include "basis.h"
+#include "gdnative.h"
+#include "variant.h"
+#include "vector3.h"
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/godot/godot_transform2d.cpp b/modules/gdnative/godot/transform2d.cpp
index bdb5476f7d..01db3f7ae0 100644
--- a/modules/gdnative/godot/godot_transform2d.cpp
+++ b/modules/gdnative/godot/transform2d.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot_transform2d.cpp */
+/* transform2d.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,7 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "godot_transform2d.h"
+#include "transform2d.h"
#include "core/variant.h"
#include "core/math/math_2d.h"
diff --git a/modules/gdnative/godot/godot_transform2d.h b/modules/gdnative/godot/transform2d.h
index c375e90af7..7171e528f2 100644
--- a/modules/gdnative/godot/godot_transform2d.h
+++ b/modules/gdnative/godot/transform2d.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot_transform2d.h */
+/* transform2d.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -36,16 +36,18 @@ extern "C" {
#include <stdint.h>
+#define GODOT_TRANSFORM2D_SIZE 24
+
#ifndef GODOT_CORE_API_GODOT_TRANSFORM2D_TYPE_DEFINED
#define GODOT_CORE_API_GODOT_TRANSFORM2D_TYPE_DEFINED
-typedef struct godot_transform2d {
- uint8_t _dont_touch_that[24];
+typedef struct {
+ uint8_t _dont_touch_that[GODOT_TRANSFORM2D_SIZE];
} godot_transform2d;
#endif
-#include "../godot.h"
-#include "godot_variant.h"
-#include "godot_vector2.h"
+#include "gdnative.h"
+#include "variant.h"
+#include "vector2.h"
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/godot/godot_variant.cpp b/modules/gdnative/godot/variant.cpp
index c9607fb21a..3469058cfd 100644
--- a/modules/gdnative/godot/godot_variant.cpp
+++ b/modules/gdnative/godot/variant.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot_variant.cpp */
+/* variant.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,7 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "godot_variant.h"
+#include "variant.h"
#include "core/variant.h"
#ifdef __cplusplus
diff --git a/modules/gdnative/godot/godot_variant.h b/modules/gdnative/godot/variant.h
index 9b6d287249..b56d5824fa 100644
--- a/modules/gdnative/godot/godot_variant.h
+++ b/modules/gdnative/godot/variant.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot_variant.h */
+/* variant.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -36,9 +36,12 @@ extern "C" {
#include <stdint.h>
+#define GODOT_VARIANT_SIZE 24
+
#ifndef GODOT_CORE_API_GODOT_VARIANT_TYPE_DEFINED
-typedef struct godot_variant {
- uint8_t _dont_touch_that[24];
+#define GODOT_CORE_API_GODOT_VARIANT_TYPE_DEFINED
+typedef struct {
+ uint8_t _dont_touch_that[GODOT_VARIANT_SIZE];
} godot_variant;
#endif
@@ -96,25 +99,25 @@ typedef struct godot_variant_call_error {
godot_variant_type expected;
} godot_variant_call_error;
-#include "godot_array.h"
-#include "godot_basis.h"
-#include "godot_color.h"
-#include "godot_dictionary.h"
-#include "godot_node_path.h"
-#include "godot_plane.h"
-#include "godot_pool_arrays.h"
-#include "godot_quat.h"
-#include "godot_rect2.h"
-#include "godot_rect3.h"
-#include "godot_rid.h"
-#include "godot_string.h"
-#include "godot_transform.h"
-#include "godot_transform2d.h"
-#include "godot_variant.h"
-#include "godot_vector2.h"
-#include "godot_vector3.h"
-
-#include "../godot.h"
+#include "array.h"
+#include "basis.h"
+#include "color.h"
+#include "dictionary.h"
+#include "node_path.h"
+#include "plane.h"
+#include "pool_arrays.h"
+#include "quat.h"
+#include "rect2.h"
+#include "rect3.h"
+#include "rid.h"
+#include "string.h"
+#include "transform.h"
+#include "transform2d.h"
+#include "variant.h"
+#include "vector2.h"
+#include "vector3.h"
+
+#include "gdnative.h"
godot_variant_type GDAPI godot_variant_get_type(const godot_variant *p_v);
diff --git a/modules/gdnative/godot/godot_vector2.cpp b/modules/gdnative/godot/vector2.cpp
index 0ced800872..6b40e31a89 100644
--- a/modules/gdnative/godot/godot_vector2.cpp
+++ b/modules/gdnative/godot/vector2.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot_vector2.cpp */
+/* vector2.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,7 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "godot_vector2.h"
+#include "vector2.h"
#include "core/variant.h"
#include "core/math/math_2d.h"
diff --git a/modules/gdnative/godot/godot_vector2.h b/modules/gdnative/godot/vector2.h
index 9c7590fedf..9934ddadbb 100644
--- a/modules/gdnative/godot/godot_vector2.h
+++ b/modules/gdnative/godot/vector2.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot_vector2.h */
+/* vector2.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -36,14 +36,16 @@ extern "C" {
#include <stdint.h>
+#define GODOT_VECTOR2_SIZE 8
+
#ifndef GODOT_CORE_API_GODOT_VECTOR2_TYPE_DEFINED
#define GODOT_CORE_API_GODOT_VECTOR2_TYPE_DEFINED
-typedef struct godot_vector2 {
- uint8_t _dont_touch_that[8];
+typedef struct {
+ uint8_t _dont_touch_that[GODOT_VECTOR2_SIZE];
} godot_vector2;
#endif
-#include "../godot.h"
+#include "gdnative.h"
void GDAPI godot_vector2_new(godot_vector2 *r_dest, const godot_real p_x, const godot_real p_y);
diff --git a/modules/gdnative/godot/godot_vector3.cpp b/modules/gdnative/godot/vector3.cpp
index f9942af6e5..904cdad9d0 100644
--- a/modules/gdnative/godot/godot_vector3.cpp
+++ b/modules/gdnative/godot/vector3.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot_vector3.cpp */
+/* vector3.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,7 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "godot_vector3.h"
+#include "vector3.h"
#include "core/variant.h"
#include "core/vector.h"
@@ -90,11 +90,12 @@ godot_vector3 GDAPI godot_vector3_inverse(const godot_vector3 *p_self) {
return dest;
}
-godot_vector3 GDAPI godot_vector3_snapped(const godot_vector3 *p_self, const godot_real p_by) {
+godot_vector3 GDAPI godot_vector3_snapped(const godot_vector3 *p_self, const godot_vector3 *p_by) {
godot_vector3 dest;
const Vector3 *self = (const Vector3 *)p_self;
+ const Vector3 *snap_axis = (const Vector3 *)p_by;
- *((Vector3 *)&dest) = self->snapped(p_by);
+ *((Vector3 *)&dest) = self->snapped(*snap_axis);
return dest;
}
diff --git a/modules/gdnative/godot/godot_vector3.h b/modules/gdnative/godot/vector3.h
index 8e2aed8173..b5f8d0f49a 100644
--- a/modules/gdnative/godot/godot_vector3.h
+++ b/modules/gdnative/godot/vector3.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot_vector3.h */
+/* vector3.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -36,15 +36,17 @@ extern "C" {
#include <stdint.h>
+#define GODOT_VECTOR3_SIZE 12
+
#ifndef GODOT_CORE_API_GODOT_VECTOR3_TYPE_DEFINED
#define GODOT_CORE_API_GODOT_VECTOR3_TYPE_DEFINED
-typedef struct godot_vector3 {
- uint8_t _dont_touch_that[12];
+typedef struct {
+ uint8_t _dont_touch_that[GODOT_VECTOR3_SIZE];
} godot_vector3;
#endif
-#include "../godot.h"
-#include "godot_basis.h"
+#include "basis.h"
+#include "gdnative.h"
typedef enum {
GODOT_VECTOR3_AXIS_X,
@@ -70,7 +72,7 @@ godot_vector3 GDAPI godot_vector3_normalized(const godot_vector3 *p_self);
godot_vector3 GDAPI godot_vector3_inverse(const godot_vector3 *p_self);
-godot_vector3 GDAPI godot_vector3_snapped(const godot_vector3 *p_self, const godot_real p_by);
+godot_vector3 GDAPI godot_vector3_snapped(const godot_vector3 *p_self, const godot_vector3 *p_by);
godot_vector3 GDAPI godot_vector3_rotated(const godot_vector3 *p_self, const godot_vector3 *p_axis, const godot_real p_phi);
diff --git a/modules/gdnative/register_types.cpp b/modules/gdnative/register_types.cpp
index 8789c9a267..d180d5aada 100644
--- a/modules/gdnative/register_types.cpp
+++ b/modules/gdnative/register_types.cpp
@@ -33,34 +33,47 @@
#include "io/resource_loader.h"
#include "io/resource_saver.h"
-GDNativeScriptLanguage *script_language_gdn = NULL;
-ResourceFormatLoaderGDNativeScript *resource_loader_gdn = NULL;
-ResourceFormatSaverGDNativeScript *resource_saver_gdn = NULL;
-//ResourceFormatLoaderDLLibrary *resource_loader_dllib=NULL;
+#include "core/os/os.h"
-void register_gdnative_types() {
+godot_variant cb_standard_varcall(void *handle, godot_string *p_procedure, godot_array *p_args) {
+ if (handle == NULL) {
+ ERR_PRINT("No valid library handle, can't call standard varcall procedure");
+ godot_variant ret;
+ godot_variant_new_nil(&ret);
+ return ret;
+ }
- ClassDB::register_class<GDNativeLibrary>();
- ClassDB::register_class<GDNativeScript>();
+ void *library_proc;
+ Error err = OS::get_singleton()->get_dynamic_library_symbol_handle(
+ handle,
+ *(String *)p_procedure,
+ library_proc,
+ true); // we roll our own message
+ if (err != OK) {
+ ERR_PRINT((String("GDNative procedure \"" + *(String *)p_procedure) + "\" does not exists and can't be called").utf8().get_data());
+ godot_variant ret;
+ godot_variant_new_nil(&ret);
+ return ret;
+ }
+
+ godot_gdnative_procedure_fn proc;
+ proc = (godot_gdnative_procedure_fn)library_proc;
- script_language_gdn = memnew(GDNativeScriptLanguage);
- ScriptServer::register_language(script_language_gdn);
- resource_loader_gdn = memnew(ResourceFormatLoaderGDNativeScript);
- ResourceLoader::add_resource_format_loader(resource_loader_gdn);
- resource_saver_gdn = memnew(ResourceFormatSaverGDNativeScript);
- ResourceSaver::add_resource_format_saver(resource_saver_gdn);
+ return proc(NULL, p_args);
}
-void unregister_gdnative_types() {
+GDNativeCallRegistry *GDNativeCallRegistry::singleton;
- ScriptServer::unregister_language(script_language_gdn);
+void register_gdnative_types() {
- if (script_language_gdn)
- memdelete(script_language_gdn);
+ ClassDB::register_class<GDNativeLibrary>();
+ ClassDB::register_class<GDNative>();
+
+ GDNativeCallRegistry::singleton = memnew(GDNativeCallRegistry);
- if (resource_loader_gdn)
- memdelete(resource_loader_gdn);
+ GDNativeCallRegistry::singleton->register_native_call_type("standard_varcall", cb_standard_varcall);
+}
- if (resource_saver_gdn)
- memdelete(resource_saver_gdn);
+void unregister_gdnative_types() {
+ memdelete(GDNativeCallRegistry::singleton);
}
diff --git a/modules/gdscript/gd_editor.cpp b/modules/gdscript/gd_editor.cpp
index adf3c8edc4..c88889767c 100644
--- a/modules/gdscript/gd_editor.cpp
+++ b/modules/gdscript/gd_editor.cpp
@@ -30,8 +30,8 @@
#include "editor/editor_settings.h"
#include "gd_compiler.h"
#include "gd_script.h"
-#include "global_config.h"
#include "os/file_access.h"
+#include "project_settings.h"
#ifdef TOOLS_ENABLED
#include "editor/editor_file_system.h"
#include "editor/editor_settings.h"
@@ -638,7 +638,7 @@ static bool _guess_expression_type(GDCompletionContext &context, const GDParser:
String which = arg1.get_slice("/", 2);
if (which != "") {
List<PropertyInfo> props;
- GlobalConfig::get_singleton()->get_property_list(&props);
+ ProjectSettings::get_singleton()->get_property_list(&props);
//print_line("find singleton");
for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) {
@@ -650,7 +650,7 @@ static bool _guess_expression_type(GDCompletionContext &context, const GDParser:
String name = s.get_slice("/", 1);
//print_line("name: "+name+", which: "+which);
if (name == which) {
- String script = GlobalConfig::get_singleton()->get(s);
+ String script = ProjectSettings::get_singleton()->get(s);
if (!script.begins_with("res://")) {
script = "res://" + script;
@@ -1105,7 +1105,7 @@ static bool _guess_identifier_type(GDCompletionContext &context, int p_line, con
//autoloads as singletons
List<PropertyInfo> props;
- GlobalConfig::get_singleton()->get_property_list(&props);
+ ProjectSettings::get_singleton()->get_property_list(&props);
for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) {
@@ -1115,7 +1115,7 @@ static bool _guess_identifier_type(GDCompletionContext &context, int p_line, con
String name = s.get_slice("/", 1);
if (name == String(p_identifier)) {
- String path = GlobalConfig::get_singleton()->get(s);
+ String path = ProjectSettings::get_singleton()->get(s);
if (path.begins_with("*")) {
String script = path.substr(1, path.length());
@@ -1334,8 +1334,8 @@ static void _find_identifiers(GDCompletionContext &context, int p_line, bool p_o
static const char *_type_names[Variant::VARIANT_MAX] = {
"null", "bool", "int", "float", "String", "Vector2", "Rect2", "Vector3", "Transform2D", "Plane", "Quat", "AABB", "Basis", "Transform",
- "Color", "NodePath", "RID", "Object", "Dictionary", "Array", "RawArray", "IntArray", "FloatArray", "StringArray",
- "Vector2Array", "Vector3Array", "ColorArray"
+ "Color", "NodePath", "RID", "Object", "Dictionary", "Array", "PoolByteArray", "PoolIntArray", "PoolRealArray", "PoolStringArray",
+ "PoolVector2Array", "PoolVector3Array", "PoolColorArray"
};
for (int i = 0; i < Variant::VARIANT_MAX; i++) {
@@ -1344,7 +1344,7 @@ static void _find_identifiers(GDCompletionContext &context, int p_line, bool p_o
//autoload singletons
List<PropertyInfo> props;
- GlobalConfig::get_singleton()->get_property_list(&props);
+ ProjectSettings::get_singleton()->get_property_list(&props);
for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) {
@@ -1352,7 +1352,7 @@ static void _find_identifiers(GDCompletionContext &context, int p_line, bool p_o
if (!s.begins_with("autoload/"))
continue;
String name = s.get_slice("/", 1);
- String path = GlobalConfig::get_singleton()->get(s);
+ String path = ProjectSettings::get_singleton()->get(s);
if (path.begins_with("*")) {
result.insert(name);
}
@@ -1685,7 +1685,7 @@ static void _find_type_arguments(GDCompletionContext &context, const GDParser::N
if (p_argidx == 0 && (String(p_method) == "get_node" || String(p_method) == "has_node") && ClassDB::is_parent_class(id.obj_type, "Node")) {
List<PropertyInfo> props;
- GlobalConfig::get_singleton()->get_property_list(&props);
+ ProjectSettings::get_singleton()->get_property_list(&props);
for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) {
@@ -2660,7 +2660,7 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol
//guess in autoloads as singletons
List<PropertyInfo> props;
- GlobalConfig::get_singleton()->get_property_list(&props);
+ ProjectSettings::get_singleton()->get_property_list(&props);
for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) {
@@ -2670,7 +2670,7 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol
String name = s.get_slice("/", 1);
if (name == String(p_symbol)) {
- String path = GlobalConfig::get_singleton()->get(s);
+ String path = ProjectSettings::get_singleton()->get(s);
if (path.begins_with("*")) {
String script = path.substr(1, path.length());
diff --git a/modules/gdscript/gd_function.cpp b/modules/gdscript/gd_function.cpp
index e8a8e20927..795371af60 100644
--- a/modules/gdscript/gd_function.cpp
+++ b/modules/gdscript/gd_function.cpp
@@ -1428,8 +1428,24 @@ Variant GDFunctionState::_signal_callback(const Variant **p_args, int p_argcount
state.result = arg;
Variant ret = function->call(NULL, NULL, 0, r_error, &state);
+
+ bool completed = true;
+
+ // If the return value is a GDFunctionState reference,
+ // then the function did yield again after resuming.
+ if (ret.is_ref()) {
+ GDFunctionState *gdfs = ret.operator Object *()->cast_to<GDFunctionState>();
+ if (gdfs && gdfs->function == function)
+ completed = false;
+ }
+
function = NULL; //cleaned up;
state.result = Variant();
+
+ if (completed) {
+ emit_signal("completed", ret);
+ }
+
return ret;
}
@@ -1468,8 +1484,24 @@ Variant GDFunctionState::resume(const Variant &p_arg) {
state.result = p_arg;
Variant::CallError err;
Variant ret = function->call(NULL, NULL, 0, err, &state);
+
+ bool completed = true;
+
+ // If the return value is a GDFunctionState reference,
+ // then the function did yield again after resuming.
+ if (ret.is_ref()) {
+ GDFunctionState *gdfs = ret.operator Object *()->cast_to<GDFunctionState>();
+ if (gdfs && gdfs->function == function)
+ completed = false;
+ }
+
function = NULL; //cleaned up;
state.result = Variant();
+
+ if (completed) {
+ emit_signal("completed", ret);
+ }
+
return ret;
}
@@ -1478,6 +1510,8 @@ void GDFunctionState::_bind_methods() {
ClassDB::bind_method(D_METHOD("resume:Variant", "arg"), &GDFunctionState::resume, DEFVAL(Variant()));
ClassDB::bind_method(D_METHOD("is_valid", "extended_check"), &GDFunctionState::is_valid, DEFVAL(false));
ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "_signal_callback", &GDFunctionState::_signal_callback, MethodInfo("_signal_callback"));
+
+ ADD_SIGNAL(MethodInfo("completed", PropertyInfo(Variant::NIL, "result")));
}
GDFunctionState::GDFunctionState() {
diff --git a/modules/gdscript/gd_functions.cpp b/modules/gdscript/gd_functions.cpp
index a361971ef4..8bc3b24a5e 100644
--- a/modules/gdscript/gd_functions.cpp
+++ b/modules/gdscript/gd_functions.cpp
@@ -1587,13 +1587,13 @@ MethodInfo GDFunctions::get_info(Function p_func) {
} break;
case TO_JSON: {
- MethodInfo mi("to_json", PropertyInfo(Variant::NIL, "var:Variant"));
+ MethodInfo mi("to_json", PropertyInfo(Variant::NIL, "var"));
mi.return_val.type = Variant::STRING;
return mi;
} break;
case HASH: {
- MethodInfo mi("hash", PropertyInfo(Variant::NIL, "var:Variant"));
+ MethodInfo mi("hash", PropertyInfo(Variant::NIL, "var"));
mi.return_val.type = Variant::INT;
return mi;
} break;
diff --git a/modules/gdscript/gd_parser.cpp b/modules/gdscript/gd_parser.cpp
index 75029a020b..36aa249398 100644
--- a/modules/gdscript/gd_parser.cpp
+++ b/modules/gdscript/gd_parser.cpp
@@ -185,8 +185,8 @@ void GDParser::_make_completable_call(int p_arg) {
bool GDParser::_get_completable_identifier(CompletionType p_type, StringName &identifier) {
identifier = StringName();
- if (tokenizer->get_token() == GDTokenizer::TK_IDENTIFIER) {
- identifier = tokenizer->get_token_identifier();
+ if (tokenizer->is_token_literal()) {
+ identifier = tokenizer->get_token_literal();
tokenizer->advance();
}
if (tokenizer->get_token() == GDTokenizer::TK_CURSOR) {
@@ -201,8 +201,8 @@ bool GDParser::_get_completable_identifier(CompletionType p_type, StringName &id
completion_ident_is_call = false;
tokenizer->advance();
- if (tokenizer->get_token() == GDTokenizer::TK_IDENTIFIER) {
- identifier = identifier.operator String() + tokenizer->get_token_identifier().operator String();
+ if (tokenizer->is_token_literal()) {
+ identifier = identifier.operator String() + tokenizer->get_token_literal().operator String();
tokenizer->advance();
}
@@ -296,17 +296,6 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
need_identifier = false;
} break;
- case GDTokenizer::TK_IDENTIFIER: {
- if (!need_identifier) {
- done = true;
- break;
- }
-
- path += String(tokenizer->get_token_identifier());
- tokenizer->advance();
- need_identifier = false;
-
- } break;
case GDTokenizer::TK_OP_DIV: {
if (need_identifier) {
@@ -320,7 +309,15 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
} break;
default: {
- done = true;
+ // Instead of checking for TK_IDENTIFIER, we check with is_token_literal, as this allows us to use match/sync/etc. as a name
+ if (need_identifier && tokenizer->is_token_literal()) {
+ path += String(tokenizer->get_token_literal());
+ tokenizer->advance();
+ need_identifier = false;
+ } else {
+ done = true;
+ }
+
break;
}
}
@@ -585,7 +582,8 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
cn->value = Variant::get_numeric_constant_value(bi_type, identifier);
expr = cn;
- } else if (tokenizer->get_token(1) == GDTokenizer::TK_PARENTHESIS_OPEN && (tokenizer->get_token() == GDTokenizer::TK_BUILT_IN_TYPE || tokenizer->get_token() == GDTokenizer::TK_IDENTIFIER || tokenizer->get_token() == GDTokenizer::TK_BUILT_IN_FUNC)) {
+ } else if (tokenizer->get_token(1) == GDTokenizer::TK_PARENTHESIS_OPEN && tokenizer->is_token_literal()) {
+ // We check with is_token_literal, as this allows us to use match/sync/etc. as a name
//function or constructor
OperatorNode *op = alloc_node<OperatorNode>();
@@ -627,7 +625,8 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
expr = op;
- } else if (tokenizer->get_token() == GDTokenizer::TK_IDENTIFIER) {
+ } else if (tokenizer->is_token_literal(0, true)) {
+ // We check with is_token_literal, as this allows us to use match/sync/etc. as a name
//identifier (reference)
const ClassNode *cln = current_class;
@@ -827,10 +826,11 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
if (expecting == DICT_EXPECT_KEY) {
- if (tokenizer->get_token() == GDTokenizer::TK_IDENTIFIER && tokenizer->get_token(1) == GDTokenizer::TK_OP_ASSIGN) {
+ if (tokenizer->is_token_literal() && tokenizer->get_token(1) == GDTokenizer::TK_OP_ASSIGN) {
+ // We check with is_token_literal, as this allows us to use match/sync/etc. as a name
//lua style identifier, easier to write
ConstantNode *cn = alloc_node<ConstantNode>();
- cn->value = tokenizer->get_token_identifier();
+ cn->value = tokenizer->get_token_literal();
key = cn;
tokenizer->advance(2);
expecting = DICT_EXPECT_VALUE;
@@ -870,7 +870,8 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
expr = dict;
- } else if (tokenizer->get_token() == GDTokenizer::TK_PERIOD && (tokenizer->get_token(1) == GDTokenizer::TK_IDENTIFIER || tokenizer->get_token(1) == GDTokenizer::TK_CURSOR) && tokenizer->get_token(2) == GDTokenizer::TK_PARENTHESIS_OPEN) {
+ } else if (tokenizer->get_token() == GDTokenizer::TK_PERIOD && (tokenizer->is_token_literal(1) || tokenizer->get_token(1) == GDTokenizer::TK_CURSOR) && tokenizer->get_token(2) == GDTokenizer::TK_PARENTHESIS_OPEN) {
+ // We check with is_token_literal, as this allows us to use match/sync/etc. as a name
// parent call
tokenizer->advance(); //goto identifier
@@ -922,7 +923,8 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
//indexing using "."
- if (tokenizer->get_token(1) != GDTokenizer::TK_CURSOR && tokenizer->get_token(1) != GDTokenizer::TK_IDENTIFIER && tokenizer->get_token(1) != GDTokenizer::TK_BUILT_IN_FUNC) {
+ if (tokenizer->get_token(1) != GDTokenizer::TK_CURSOR && !tokenizer->is_token_literal(1)) {
+ // We check with is_token_literal, as this allows us to use match/sync/etc. as a name
_set_error("Expected identifier as member");
return NULL;
} else if (tokenizer->get_token(2) == GDTokenizer::TK_PARENTHESIS_OPEN) {
@@ -2341,12 +2343,12 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) {
//variale declaration and (eventual) initialization
tokenizer->advance();
- if (tokenizer->get_token() != GDTokenizer::TK_IDENTIFIER) {
+ if (!tokenizer->is_token_literal(0, true)) {
_set_error("Expected identifier for local variable name.");
return;
}
- StringName n = tokenizer->get_token_identifier();
+ StringName n = tokenizer->get_token_literal();
tokenizer->advance();
if (current_function) {
for (int i = 0; i < current_function->arguments.size(); i++) {
@@ -2571,7 +2573,7 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) {
tokenizer->advance();
- if (tokenizer->get_token() != GDTokenizer::TK_IDENTIFIER) {
+ if (!tokenizer->is_token_literal(0, true)) {
_set_error("identifier expected after 'for'");
}
@@ -3108,7 +3110,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
tokenizer->advance(); //var before the identifier is allowed
}
- if (tokenizer->get_token() != GDTokenizer::TK_IDENTIFIER) {
+ if (!tokenizer->is_token_literal(0, true)) {
_set_error("Expected identifier for argument.");
return;
@@ -3260,7 +3262,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
case GDTokenizer::TK_PR_SIGNAL: {
tokenizer->advance();
- if (tokenizer->get_token() != GDTokenizer::TK_IDENTIFIER) {
+ if (!tokenizer->is_token_literal()) {
_set_error("Expected identifier after 'signal'.");
return;
}
@@ -3282,7 +3284,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
break;
}
- if (tokenizer->get_token() != GDTokenizer::TK_IDENTIFIER) {
+ if (!tokenizer->is_token_literal(0, true)) {
_set_error("Expected identifier in signal argument.");
return;
}
@@ -3847,13 +3849,13 @@ void GDParser::_parse_class(ClassNode *p_class) {
bool onready = tokenizer->get_token(-1) == GDTokenizer::TK_PR_ONREADY;
tokenizer->advance();
- if (tokenizer->get_token() != GDTokenizer::TK_IDENTIFIER) {
+ if (!tokenizer->is_token_literal(0, true)) {
_set_error("Expected identifier for member variable name.");
return;
}
- member.identifier = tokenizer->get_token_identifier();
+ member.identifier = tokenizer->get_token_literal();
member.expression = NULL;
member._export.name = member.identifier;
member.line = tokenizer->get_token_line();
@@ -3979,11 +3981,11 @@ void GDParser::_parse_class(ClassNode *p_class) {
if (tokenizer->get_token() != GDTokenizer::TK_COMMA) {
//just comma means using only getter
- if (tokenizer->get_token() != GDTokenizer::TK_IDENTIFIER) {
- _set_error("Expected identifier for setter function after 'notify'.");
+ if (!tokenizer->is_token_literal()) {
+ _set_error("Expected identifier for setter function after 'setget'.");
}
- member.setter = tokenizer->get_token_identifier();
+ member.setter = tokenizer->get_token_literal();
tokenizer->advance();
}
@@ -3992,11 +3994,11 @@ void GDParser::_parse_class(ClassNode *p_class) {
//there is a getter
tokenizer->advance();
- if (tokenizer->get_token() != GDTokenizer::TK_IDENTIFIER) {
+ if (!tokenizer->is_token_literal()) {
_set_error("Expected identifier for getter function after ','.");
}
- member.getter = tokenizer->get_token_identifier();
+ member.getter = tokenizer->get_token_literal();
tokenizer->advance();
}
}
@@ -4014,13 +4016,13 @@ void GDParser::_parse_class(ClassNode *p_class) {
ClassNode::Constant constant;
tokenizer->advance();
- if (tokenizer->get_token() != GDTokenizer::TK_IDENTIFIER) {
+ if (!tokenizer->is_token_literal(0, true)) {
_set_error("Expected name (identifier) for constant.");
return;
}
- constant.identifier = tokenizer->get_token_identifier();
+ constant.identifier = tokenizer->get_token_literal();
tokenizer->advance();
if (tokenizer->get_token() != GDTokenizer::TK_OP_ASSIGN) {
@@ -4061,8 +4063,8 @@ void GDParser::_parse_class(ClassNode *p_class) {
Dictionary enum_dict;
tokenizer->advance();
- if (tokenizer->get_token() == GDTokenizer::TK_IDENTIFIER) {
- enum_name = tokenizer->get_token_identifier();
+ if (tokenizer->is_token_literal(0, true)) {
+ enum_name = tokenizer->get_token_literal();
tokenizer->advance();
}
if (tokenizer->get_token() != GDTokenizer::TK_CURLY_BRACKET_OPEN) {
@@ -4079,7 +4081,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
tokenizer->advance();
break; // End of enum
- } else if (tokenizer->get_token() != GDTokenizer::TK_IDENTIFIER) {
+ } else if (!tokenizer->is_token_literal(0, true)) {
if (tokenizer->get_token() == GDTokenizer::TK_EOF) {
_set_error("Unexpected end of file.");
@@ -4088,10 +4090,10 @@ void GDParser::_parse_class(ClassNode *p_class) {
}
return;
- } else { // tokenizer->get_token()==GDTokenizer::TK_IDENTIFIER
+ } else { // tokenizer->is_token_literal(0, true)
ClassNode::Constant constant;
- constant.identifier = tokenizer->get_token_identifier();
+ constant.identifier = tokenizer->get_token_literal();
tokenizer->advance();
diff --git a/modules/gdscript/gd_script.cpp b/modules/gdscript/gd_script.cpp
index 1dcc442234..fe87433a89 100644
--- a/modules/gdscript/gd_script.cpp
+++ b/modules/gdscript/gd_script.cpp
@@ -29,11 +29,11 @@
/*************************************************************************/
#include "gd_script.h"
#include "gd_compiler.h"
-#include "global_config.h"
#include "global_constants.h"
#include "io/file_access_encrypted.h"
#include "os/file_access.h"
#include "os/os.h"
+#include "project_settings.h"
///////////////////////////
@@ -1454,9 +1454,9 @@ void GDScriptLanguage::init() {
//populate singletons
- List<GlobalConfig::Singleton> singletons;
- GlobalConfig::get_singleton()->get_singletons(&singletons);
- for (List<GlobalConfig::Singleton>::Element *E = singletons.front(); E; E = E->next()) {
+ List<ProjectSettings::Singleton> singletons;
+ ProjectSettings::get_singleton()->get_singletons(&singletons);
+ for (List<ProjectSettings::Singleton>::Element *E = singletons.front(); E; E = E->next()) {
_add_global(E->get().name, E->get().ptr);
}
@@ -1885,7 +1885,7 @@ GDScriptLanguage::GDScriptLanguage() {
script_frame_time = 0;
_debug_call_stack_pos = 0;
- int dmcs = GLOBAL_DEF("debug/script/max_call_stack", 1024);
+ int dmcs = GLOBAL_DEF("debug/settings/gdscript/max_call_stack", 1024);
if (ScriptDebugger::get_singleton()) {
//debugging enabled!
diff --git a/modules/gdscript/gd_tokenizer.cpp b/modules/gdscript/gd_tokenizer.cpp
index f4e0cc8e29..5803046185 100644
--- a/modules/gdscript/gd_tokenizer.cpp
+++ b/modules/gdscript/gd_tokenizer.cpp
@@ -130,12 +130,222 @@ const char *GDTokenizer::token_names[TK_MAX] = {
"Cursor"
};
+struct _bit {
+ Variant::Type type;
+ const char *text;
+};
+//built in types
+
+static const _bit _type_list[] = {
+ //types
+ { Variant::BOOL, "bool" },
+ { Variant::INT, "int" },
+ { Variant::REAL, "float" },
+ { Variant::STRING, "String" },
+ { Variant::VECTOR2, "Vector2" },
+ { Variant::RECT2, "Rect2" },
+ { Variant::TRANSFORM2D, "Transform2D" },
+ { Variant::VECTOR3, "Vector3" },
+ { Variant::RECT3, "Rect3" },
+ { Variant::PLANE, "Plane" },
+ { Variant::QUAT, "Quat" },
+ { Variant::BASIS, "Basis" },
+ { Variant::TRANSFORM, "Transform" },
+ { Variant::COLOR, "Color" },
+ { Variant::_RID, "RID" },
+ { Variant::OBJECT, "Object" },
+ { Variant::NODE_PATH, "NodePath" },
+ { Variant::DICTIONARY, "Dictionary" },
+ { Variant::ARRAY, "Array" },
+ { Variant::POOL_BYTE_ARRAY, "PoolByteArray" },
+ { Variant::POOL_INT_ARRAY, "PoolIntArray" },
+ { Variant::POOL_REAL_ARRAY, "PoolRealArray" },
+ { Variant::POOL_STRING_ARRAY, "PoolStringArray" },
+ { Variant::POOL_VECTOR2_ARRAY, "PoolVector2Array" },
+ { Variant::POOL_VECTOR3_ARRAY, "PoolVector3Array" },
+ { Variant::POOL_COLOR_ARRAY, "PoolColorArray" },
+ { Variant::VARIANT_MAX, NULL },
+};
+
+struct _kws {
+ GDTokenizer::Token token;
+ const char *text;
+};
+
+static const _kws _keyword_list[] = {
+ //ops
+ { GDTokenizer::TK_OP_IN, "in" },
+ { GDTokenizer::TK_OP_NOT, "not" },
+ { GDTokenizer::TK_OP_OR, "or" },
+ { GDTokenizer::TK_OP_AND, "and" },
+ //func
+ { GDTokenizer::TK_PR_FUNCTION, "func" },
+ { GDTokenizer::TK_PR_CLASS, "class" },
+ { GDTokenizer::TK_PR_EXTENDS, "extends" },
+ { GDTokenizer::TK_PR_IS, "is" },
+ { GDTokenizer::TK_PR_ONREADY, "onready" },
+ { GDTokenizer::TK_PR_TOOL, "tool" },
+ { GDTokenizer::TK_PR_STATIC, "static" },
+ { GDTokenizer::TK_PR_EXPORT, "export" },
+ { GDTokenizer::TK_PR_SETGET, "setget" },
+ { GDTokenizer::TK_PR_VAR, "var" },
+ { GDTokenizer::TK_PR_PRELOAD, "preload" },
+ { GDTokenizer::TK_PR_ASSERT, "assert" },
+ { GDTokenizer::TK_PR_YIELD, "yield" },
+ { GDTokenizer::TK_PR_SIGNAL, "signal" },
+ { GDTokenizer::TK_PR_BREAKPOINT, "breakpoint" },
+ { GDTokenizer::TK_PR_REMOTE, "remote" },
+ { GDTokenizer::TK_PR_MASTER, "master" },
+ { GDTokenizer::TK_PR_SLAVE, "slave" },
+ { GDTokenizer::TK_PR_SYNC, "sync" },
+ { GDTokenizer::TK_PR_CONST, "const" },
+ { GDTokenizer::TK_PR_ENUM, "enum" },
+ //controlflow
+ { GDTokenizer::TK_CF_IF, "if" },
+ { GDTokenizer::TK_CF_ELIF, "elif" },
+ { GDTokenizer::TK_CF_ELSE, "else" },
+ { GDTokenizer::TK_CF_FOR, "for" },
+ { GDTokenizer::TK_CF_WHILE, "while" },
+ { GDTokenizer::TK_CF_DO, "do" },
+ { GDTokenizer::TK_CF_SWITCH, "switch" },
+ { GDTokenizer::TK_CF_CASE, "case" },
+ { GDTokenizer::TK_CF_BREAK, "break" },
+ { GDTokenizer::TK_CF_CONTINUE, "continue" },
+ { GDTokenizer::TK_CF_RETURN, "return" },
+ { GDTokenizer::TK_CF_MATCH, "match" },
+ { GDTokenizer::TK_CF_PASS, "pass" },
+ { GDTokenizer::TK_SELF, "self" },
+ { GDTokenizer::TK_CONST_PI, "PI" },
+ { GDTokenizer::TK_WILDCARD, "_" },
+ { GDTokenizer::TK_CONST_INF, "INF" },
+ { GDTokenizer::TK_CONST_NAN, "NAN" },
+ { GDTokenizer::TK_ERROR, NULL }
+};
+
const char *GDTokenizer::get_token_name(Token p_token) {
ERR_FAIL_INDEX_V(p_token, TK_MAX, "<error>");
return token_names[p_token];
}
+bool GDTokenizer::is_token_literal(int p_offset, bool variable_safe) const {
+ switch (get_token(p_offset)) {
+ // Can always be literal:
+ case TK_IDENTIFIER:
+
+ case TK_PR_ONREADY:
+ case TK_PR_TOOL:
+ case TK_PR_STATIC:
+ case TK_PR_EXPORT:
+ case TK_PR_SETGET:
+ case TK_PR_SIGNAL:
+ case TK_PR_REMOTE:
+ case TK_PR_MASTER:
+ case TK_PR_SLAVE:
+ case TK_PR_SYNC:
+ return true;
+
+ // Literal for non-variables only:
+ case TK_BUILT_IN_TYPE:
+ case TK_BUILT_IN_FUNC:
+
+ case TK_OP_IN:
+ //case TK_OP_NOT:
+ //case TK_OP_OR:
+ //case TK_OP_AND:
+
+ case TK_PR_CLASS:
+ case TK_PR_CONST:
+ case TK_PR_ENUM:
+ case TK_PR_PRELOAD:
+ case TK_PR_FUNCTION:
+ case TK_PR_EXTENDS:
+ case TK_PR_ASSERT:
+ case TK_PR_YIELD:
+ case TK_PR_VAR:
+
+ case TK_CF_IF:
+ case TK_CF_ELIF:
+ case TK_CF_ELSE:
+ case TK_CF_FOR:
+ case TK_CF_WHILE:
+ case TK_CF_DO:
+ case TK_CF_SWITCH:
+ case TK_CF_CASE:
+ case TK_CF_BREAK:
+ case TK_CF_CONTINUE:
+ case TK_CF_RETURN:
+ case TK_CF_MATCH:
+ case TK_CF_PASS:
+ case TK_SELF:
+ case TK_CONST_PI:
+ case TK_WILDCARD:
+ case TK_CONST_INF:
+ case TK_CONST_NAN:
+ case TK_ERROR:
+ return !variable_safe;
+
+ case TK_CONSTANT: {
+ switch (get_token_constant(p_offset).get_type()) {
+ case Variant::NIL:
+ case Variant::BOOL:
+ return true;
+ default:
+ return false;
+ }
+ }
+ default:
+ return false;
+ }
+}
+
+StringName GDTokenizer::get_token_literal(int p_offset) const {
+ Token token = get_token(p_offset);
+ switch (token) {
+ case TK_IDENTIFIER:
+ return get_token_identifier(p_offset);
+ case TK_BUILT_IN_TYPE: {
+ Variant::Type type = get_token_type(p_offset);
+ int idx = 0;
+
+ while (_type_list[idx].text) {
+ if (type == _type_list[idx].type) {
+ return _type_list[idx].text;
+ }
+ idx++;
+ }
+ } break; // Shouldn't get here, stuff happens
+ case TK_BUILT_IN_FUNC:
+ return GDFunctions::get_func_name(get_token_built_in_func(p_offset));
+ case TK_CONSTANT: {
+ const Variant value = get_token_constant(p_offset);
+
+ switch (value.get_type()) {
+ case Variant::NIL:
+ return "null";
+ case Variant::BOOL:
+ return value ? "true" : "false";
+ default: {}
+ }
+ }
+ case TK_OP_AND:
+ case TK_OP_OR:
+ break; // Don't get into default, since they can be non-literal
+ default: {
+ int idx = 0;
+
+ while (_keyword_list[idx].text) {
+ if (token == _keyword_list[idx].token) {
+ return _keyword_list[idx].text;
+ }
+ idx++;
+ }
+ }
+ }
+ ERR_EXPLAIN("Failed to get token literal");
+ ERR_FAIL_V("");
+}
+
static bool _is_text_char(CharType c) {
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '_';
@@ -779,51 +989,14 @@ void GDTokenizerText::_advance() {
bool found = false;
- struct _bit {
- Variant::Type type;
- const char *text;
- };
- //built in types
-
- static const _bit type_list[] = {
- //types
- { Variant::BOOL, "bool" },
- { Variant::INT, "int" },
- { Variant::REAL, "float" },
- { Variant::STRING, "String" },
- { Variant::VECTOR2, "Vector2" },
- { Variant::RECT2, "Rect2" },
- { Variant::TRANSFORM2D, "Transform2D" },
- { Variant::VECTOR3, "Vector3" },
- { Variant::RECT3, "Rect3" },
- { Variant::PLANE, "Plane" },
- { Variant::QUAT, "Quat" },
- { Variant::BASIS, "Basis" },
- { Variant::TRANSFORM, "Transform" },
- { Variant::COLOR, "Color" },
- { Variant::_RID, "RID" },
- { Variant::OBJECT, "Object" },
- { Variant::NODE_PATH, "NodePath" },
- { Variant::DICTIONARY, "Dictionary" },
- { Variant::ARRAY, "Array" },
- { Variant::POOL_BYTE_ARRAY, "PoolByteArray" },
- { Variant::POOL_INT_ARRAY, "PoolIntArray" },
- { Variant::POOL_REAL_ARRAY, "PoolFloatArray" },
- { Variant::POOL_STRING_ARRAY, "PoolStringArray" },
- { Variant::POOL_VECTOR2_ARRAY, "PoolVector2Array" },
- { Variant::POOL_VECTOR3_ARRAY, "PoolVector3Array" },
- { Variant::POOL_COLOR_ARRAY, "PoolColorArray" },
- { Variant::VARIANT_MAX, NULL },
- };
-
{
int idx = 0;
- while (type_list[idx].text) {
+ while (_type_list[idx].text) {
- if (str == type_list[idx].text) {
- _make_type(type_list[idx].type);
+ if (str == _type_list[idx].text) {
+ _make_type(_type_list[idx].type);
found = true;
break;
}
@@ -844,74 +1017,18 @@ void GDTokenizerText::_advance() {
break;
}
}
-
- //keywor
}
if (!found) {
-
- struct _kws {
- Token token;
- const char *text;
- };
-
- static const _kws keyword_list[] = {
- //ops
- { TK_OP_IN, "in" },
- { TK_OP_NOT, "not" },
- { TK_OP_OR, "or" },
- { TK_OP_AND, "and" },
- //func
- { TK_PR_FUNCTION, "func" },
- { TK_PR_CLASS, "class" },
- { TK_PR_EXTENDS, "extends" },
- { TK_PR_IS, "is" },
- { TK_PR_ONREADY, "onready" },
- { TK_PR_TOOL, "tool" },
- { TK_PR_STATIC, "static" },
- { TK_PR_EXPORT, "export" },
- { TK_PR_SETGET, "setget" },
- { TK_PR_VAR, "var" },
- { TK_PR_PRELOAD, "preload" },
- { TK_PR_ASSERT, "assert" },
- { TK_PR_YIELD, "yield" },
- { TK_PR_SIGNAL, "signal" },
- { TK_PR_BREAKPOINT, "breakpoint" },
- { TK_PR_REMOTE, "remote" },
- { TK_PR_MASTER, "master" },
- { TK_PR_SLAVE, "slave" },
- { TK_PR_SYNC, "sync" },
- { TK_PR_CONST, "const" },
- { TK_PR_ENUM, "enum" },
- //controlflow
- { TK_CF_IF, "if" },
- { TK_CF_ELIF, "elif" },
- { TK_CF_ELSE, "else" },
- { TK_CF_FOR, "for" },
- { TK_CF_WHILE, "while" },
- { TK_CF_DO, "do" },
- { TK_CF_SWITCH, "switch" },
- { TK_CF_CASE, "case" },
- { TK_CF_BREAK, "break" },
- { TK_CF_CONTINUE, "continue" },
- { TK_CF_RETURN, "return" },
- { TK_CF_MATCH, "match" },
- { TK_CF_PASS, "pass" },
- { TK_SELF, "self" },
- { TK_CONST_PI, "PI" },
- { TK_WILDCARD, "_" },
- { TK_CONST_INF, "INF" },
- { TK_CONST_NAN, "NAN" },
- { TK_ERROR, NULL }
- };
+ //keyword
int idx = 0;
found = false;
- while (keyword_list[idx].text) {
+ while (_keyword_list[idx].text) {
- if (str == keyword_list[idx].text) {
- _make_token(keyword_list[idx].token);
+ if (str == _keyword_list[idx].text) {
+ _make_token(_keyword_list[idx].token);
found = true;
break;
}
@@ -992,6 +1109,7 @@ const Variant &GDTokenizerText::get_token_constant(int p_offset) const {
ERR_FAIL_COND_V(tk_rb[ofs].type != TK_CONSTANT, tk_rb[0].constant);
return tk_rb[ofs].constant;
}
+
StringName GDTokenizerText::get_token_identifier(int p_offset) const {
ERR_FAIL_COND_V(p_offset <= -MAX_LOOKAHEAD, StringName());
diff --git a/modules/gdscript/gd_tokenizer.h b/modules/gdscript/gd_tokenizer.h
index c051176097..4e868301a3 100644
--- a/modules/gdscript/gd_tokenizer.h
+++ b/modules/gdscript/gd_tokenizer.h
@@ -149,6 +149,9 @@ protected:
public:
static const char *get_token_name(Token p_token);
+ bool is_token_literal(int p_offset = 0, bool variable_safe = false) const;
+ StringName get_token_literal(int p_offset = 0) const;
+
virtual const Variant &get_token_constant(int p_offset = 0) const = 0;
virtual Token get_token(int p_offset = 0) const = 0;
virtual StringName get_token_identifier(int p_offset = 0) const = 0;
diff --git a/modules/gridmap/grid_map.cpp b/modules/gridmap/grid_map.cpp
index 9d3da8227c..8c2c2ea345 100644
--- a/modules/gridmap/grid_map.cpp
+++ b/modules/gridmap/grid_map.cpp
@@ -380,6 +380,7 @@ void GridMap::set_cell_item(int p_x, int p_y, int p_z, int p_item, int p_rot) {
ii.multimesh->set_mesh(ii.mesh);
ii.multimesh_instance = VS::get_singleton()->instance_create();
VS::get_singleton()->instance_set_base(ii.multimesh_instance, ii.multimesh->get_rid());
+ VS::get_singleton()->instance_geometry_set_flag(ii.multimesh_instance, VS::INSTANCE_FLAG_USE_BAKED_LIGHT, true);
g.items[p_item] = ii;
}
diff --git a/modules/nativescript/SCsub b/modules/nativescript/SCsub
new file mode 100644
index 0000000000..e980e40e8e
--- /dev/null
+++ b/modules/nativescript/SCsub
@@ -0,0 +1,10 @@
+#!/usr/bin/env python
+
+Import('env')
+
+mod_env = env.Clone()
+mod_env.add_source_files(env.modules_sources, "*.cpp")
+mod_env.Append(CPPPATH='#modules/gdnative')
+mod_env.Append(CPPFLAGS=['-DGDAPI_BUILT_IN'])
+
+Export('mod_env')
diff --git a/modules/gdnative/api_generator.cpp b/modules/nativescript/api_generator.cpp
index d5f22ee7a3..47162bfc49 100644
--- a/modules/gdnative/api_generator.cpp
+++ b/modules/nativescript/api_generator.cpp
@@ -32,8 +32,8 @@
#ifdef TOOLS_ENABLED
#include "class_db.h"
-#include "core/global_config.h"
#include "core/global_constants.h"
+#include "core/project_settings.h"
#include "os/file_access.h"
// helper stuff
@@ -150,7 +150,7 @@ List<ClassAPI> generate_c_api_classes() {
if (name.begins_with("_")) {
name.remove(0);
}
- class_api.is_singleton = GlobalConfig::get_singleton()->has_singleton(name);
+ class_api.is_singleton = ProjectSettings::get_singleton()->has_singleton(name);
}
class_api.is_instanciable = !class_api.is_singleton && ClassDB::can_instance(class_name);
@@ -268,6 +268,8 @@ List<ClassAPI> generate_c_api_classes() {
method_api.method_name = method_api.method_name.get_slice(":", 0);
} else if (m->get().return_val.type != Variant::NIL) {
method_api.return_type = m->get().return_val.hint == PROPERTY_HINT_RESOURCE_TYPE ? m->get().return_val.hint_string : Variant::get_type_name(m->get().return_val.type);
+ } else if (m->get().return_val.name != "") {
+ method_api.return_type = m->get().return_val.name;
} else {
method_api.return_type = "void";
}
diff --git a/modules/gdnative/api_generator.h b/modules/nativescript/api_generator.h
index a108d7a7b6..a108d7a7b6 100644
--- a/modules/gdnative/api_generator.h
+++ b/modules/nativescript/api_generator.h
diff --git a/modules/nativescript/config.py b/modules/nativescript/config.py
new file mode 100644
index 0000000000..9f57b9bb74
--- /dev/null
+++ b/modules/nativescript/config.py
@@ -0,0 +1,8 @@
+
+
+def can_build(platform):
+ return True
+
+
+def configure(env):
+ env.use_ptrcall = True
diff --git a/modules/nativescript/godot_nativescript.cpp b/modules/nativescript/godot_nativescript.cpp
new file mode 100644
index 0000000000..453cee3a18
--- /dev/null
+++ b/modules/nativescript/godot_nativescript.cpp
@@ -0,0 +1,205 @@
+/*************************************************************************/
+/* godot_nativescript.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+#include "godot_nativescript.h"
+
+#include "nativescript.h"
+
+#include "class_db.h"
+#include "error_macros.h"
+#include "gdnative.h"
+#include "global_constants.h"
+#include "project_settings.h"
+#include "variant.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern "C" void _native_script_hook() {
+}
+
+#define NSL NativeScriptLanguage::get_singleton()
+
+// Script API
+
+void GDAPI godot_nativescript_register_class(void *p_gdnative_handle, const char *p_name, const char *p_base, godot_instance_create_func p_create_func, godot_instance_destroy_func p_destroy_func) {
+
+ String *s = (String *)p_gdnative_handle;
+
+ Map<StringName, NativeScriptDesc> *classes = &NSL->library_classes[*s];
+
+ NativeScriptDesc desc;
+
+ desc.create_func = p_create_func;
+ desc.destroy_func = p_destroy_func;
+ desc.is_tool = false;
+
+ desc.base = p_base;
+
+ if (classes->has(p_base)) {
+ desc.base_data = &(*classes)[p_base];
+ desc.base_native_type = desc.base_data->base_native_type;
+ } else {
+ desc.base_data = NULL;
+ desc.base_native_type = p_base;
+ }
+
+ classes->insert(p_name, desc);
+}
+
+void GDAPI godot_nativescript_register_tool_class(void *p_gdnative_handle, const char *p_name, const char *p_base, godot_instance_create_func p_create_func, godot_instance_destroy_func p_destroy_func) {
+
+ String *s = (String *)p_gdnative_handle;
+
+ Map<StringName, NativeScriptDesc> *classes = &NSL->library_classes[*s];
+
+ NativeScriptDesc desc;
+
+ desc.create_func = p_create_func;
+ desc.destroy_func = p_destroy_func;
+ desc.is_tool = true;
+ desc.base = p_base;
+
+ if (classes->has(p_base)) {
+ desc.base_data = &(*classes)[p_base];
+ desc.base_native_type = desc.base_data->base_native_type;
+ } else {
+ desc.base_data = NULL;
+ desc.base_native_type = p_base;
+ }
+
+ classes->insert(p_name, desc);
+}
+
+void GDAPI godot_nativescript_register_method(void *p_gdnative_handle, const char *p_name, const char *p_function_name, godot_method_attributes p_attr, godot_instance_method p_method) {
+
+ String *s = (String *)p_gdnative_handle;
+
+ Map<StringName, NativeScriptDesc>::Element *E = NSL->library_classes[*s].find(p_name);
+
+ if (!E) {
+ ERR_EXPLAIN("Attempt to register method on non-existant class!");
+ ERR_FAIL();
+ }
+
+ NativeScriptDesc::Method method;
+ method.method = p_method;
+ method.rpc_mode = p_attr.rpc_type;
+ method.info = MethodInfo(p_function_name);
+
+ E->get().methods.insert(p_function_name, method);
+}
+
+void GDAPI godot_nativescript_register_property(void *p_gdnative_handle, const char *p_name, const char *p_path, godot_property_attributes *p_attr, godot_property_set_func p_set_func, godot_property_get_func p_get_func) {
+
+ String *s = (String *)p_gdnative_handle;
+
+ Map<StringName, NativeScriptDesc>::Element *E = NSL->library_classes[*s].find(p_name);
+
+ if (!E) {
+ ERR_EXPLAIN("Attempt to register method on non-existant class!");
+ ERR_FAIL();
+ }
+
+ NativeScriptDesc::Property property;
+ property.default_value = *(Variant *)&p_attr->default_value;
+ property.getter = p_get_func;
+ property.rset_mode = p_attr->rset_type;
+ property.setter = p_set_func;
+ property.info = PropertyInfo((Variant::Type)p_attr->type,
+ p_path,
+ (PropertyHint)p_attr->hint,
+ *(String *)&p_attr->hint_string,
+ (PropertyUsageFlags)p_attr->usage);
+
+ E->get().properties.insert(p_path, property);
+}
+
+void GDAPI godot_nativescript_register_signal(void *p_gdnative_handle, const char *p_name, const godot_signal *p_signal) {
+
+ String *s = (String *)p_gdnative_handle;
+
+ Map<StringName, NativeScriptDesc>::Element *E = NSL->library_classes[*s].find(p_name);
+
+ if (!E) {
+ ERR_EXPLAIN("Attempt to register method on non-existant class!");
+ ERR_FAIL();
+ }
+
+ List<PropertyInfo> args;
+ Vector<Variant> default_args;
+
+ for (int i = 0; i < p_signal->num_args; i++) {
+ PropertyInfo info;
+
+ godot_signal_argument arg = p_signal->args[i];
+
+ info.hint = (PropertyHint)arg.hint;
+ info.hint_string = *(String *)&arg.hint_string;
+ info.name = *(String *)&arg.name;
+ info.type = (Variant::Type)arg.type;
+ info.usage = (PropertyUsageFlags)arg.usage;
+
+ args.push_back(info);
+ }
+
+ for (int i = 0; i < p_signal->num_default_args; i++) {
+ Variant *v;
+ godot_signal_argument attrib = p_signal->args[i];
+
+ v = (Variant *)&attrib.default_value;
+
+ default_args.push_back(*v);
+ }
+
+ MethodInfo method_info;
+ method_info.name = *(String *)&p_signal->name;
+ method_info.arguments = args;
+ method_info.default_arguments = default_args;
+
+ NativeScriptDesc::Signal signal;
+ signal.signal = method_info;
+
+ E->get().signals_.insert(*(String *)&p_signal->name, signal);
+}
+
+void GDAPI *godot_nativescript_get_userdata(godot_object *p_instance) {
+ Object *instance = (Object *)p_instance;
+ if (!instance)
+ return NULL;
+ if (instance->get_script_instance() && instance->get_script_instance()->get_language() == NativeScriptLanguage::get_singleton()) {
+ return ((NativeScriptInstance *)instance->get_script_instance())->userdata;
+ }
+ return NULL;
+}
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/modules/gdnative/godot.h b/modules/nativescript/godot_nativescript.h
index 1d86998291..cfd445086b 100644
--- a/modules/gdnative/godot.h
+++ b/modules/nativescript/godot_nativescript.h
@@ -27,8 +27,10 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef GODOT_C_H
-#define GODOT_C_H
+#ifndef GODOT_NATIVESCRIPT_H
+#define GODOT_NATIVESCRIPT_H
+
+#include <godot/gdnative.h>
#ifdef __cplusplus
extern "C" {
@@ -70,203 +72,7 @@ extern "C" {
#include <stdbool.h>
#include <stdint.h>
-#define GODOT_API_VERSION 1
-
-////// Error
-
-typedef enum godot_error {
- GODOT_OK,
- GODOT_FAILED, ///< Generic fail error
- GODOT_ERR_UNAVAILABLE, ///< What is requested is unsupported/unavailable
- GODOT_ERR_UNCONFIGURED, ///< The object being used hasnt been properly set up yet
- GODOT_ERR_UNAUTHORIZED, ///< Missing credentials for requested resource
- GODOT_ERR_PARAMETER_RANGE_ERROR, ///< Parameter given out of range (5)
- GODOT_ERR_OUT_OF_MEMORY, ///< Out of memory
- GODOT_ERR_FILE_NOT_FOUND,
- GODOT_ERR_FILE_BAD_DRIVE,
- GODOT_ERR_FILE_BAD_PATH,
- GODOT_ERR_FILE_NO_PERMISSION, // (10)
- GODOT_ERR_FILE_ALREADY_IN_USE,
- GODOT_ERR_FILE_CANT_OPEN,
- GODOT_ERR_FILE_CANT_WRITE,
- GODOT_ERR_FILE_CANT_READ,
- GODOT_ERR_FILE_UNRECOGNIZED, // (15)
- GODOT_ERR_FILE_CORRUPT,
- GODOT_ERR_FILE_MISSING_DEPENDENCIES,
- GODOT_ERR_FILE_EOF,
- GODOT_ERR_CANT_OPEN, ///< Can't open a resource/socket/file
- GODOT_ERR_CANT_CREATE, // (20)
- GODOT_ERR_QUERY_FAILED,
- GODOT_ERR_ALREADY_IN_USE,
- GODOT_ERR_LOCKED, ///< resource is locked
- GODOT_ERR_TIMEOUT,
- GODOT_ERR_CANT_CONNECT, // (25)
- GODOT_ERR_CANT_RESOLVE,
- GODOT_ERR_CONNECTION_ERROR,
- GODOT_ERR_CANT_AQUIRE_RESOURCE,
- GODOT_ERR_CANT_FORK,
- GODOT_ERR_INVALID_DATA, ///< Data passed is invalid (30)
- GODOT_ERR_INVALID_PARAMETER, ///< Parameter passed is invalid
- GODOT_ERR_ALREADY_EXISTS, ///< When adding, item already exists
- GODOT_ERR_DOES_NOT_EXIST, ///< When retrieving/erasing, it item does not exist
- GODOT_ERR_DATABASE_CANT_READ, ///< database is full
- GODOT_ERR_DATABASE_CANT_WRITE, ///< database is full (35)
- GODOT_ERR_COMPILATION_FAILED,
- GODOT_ERR_METHOD_NOT_FOUND,
- GODOT_ERR_LINK_FAILED,
- GODOT_ERR_SCRIPT_FAILED,
- GODOT_ERR_CYCLIC_LINK, // (40)
- GODOT_ERR_INVALID_DECLARATION,
- GODOT_ERR_DUPLICATE_SYMBOL,
- GODOT_ERR_PARSE_ERROR,
- GODOT_ERR_BUSY,
- GODOT_ERR_SKIP, // (45)
- GODOT_ERR_HELP, ///< user requested help!!
- GODOT_ERR_BUG, ///< a bug in the software certainly happened, due to a double check failing or unexpected behavior.
- GODOT_ERR_PRINTER_ON_FIRE, /// the parallel port printer is engulfed in flames
- GODOT_ERR_OMFG_THIS_IS_VERY_VERY_BAD, ///< shit happens, has never been used, though
- GODOT_ERR_WTF = GODOT_ERR_OMFG_THIS_IS_VERY_VERY_BAD ///< short version of the above
-} godot_error;
-
-////// bool
-
-typedef bool godot_bool;
-
-#define GODOT_TRUE 1
-#define GODOT_FALSE 0
-
-/////// int
-
-typedef int godot_int;
-
-/////// real
-
-typedef float godot_real;
-
-/////// Object (forward declared)
-typedef void godot_object;
-
-/////// Brute force forward declarations for the rest
-typedef struct godot_variant godot_variant;
-typedef struct godot_string godot_string;
-typedef struct godot_vector2 godot_vector2;
-typedef struct godot_rect2 godot_rect2;
-typedef struct godot_vector3 godot_vector3;
-typedef struct godot_transform2d godot_transform2d;
-typedef struct godot_plane godot_plane;
-typedef struct godot_quat godot_quat;
-typedef struct godot_rect3 godot_rect3;
-typedef struct godot_basis godot_basis;
-typedef struct godot_transform godot_transform;
-typedef struct godot_color godot_color;
-typedef struct godot_node_path godot_node_path;
-typedef struct godot_rid godot_rid;
-typedef struct godot_dictionary godot_dictionary;
-typedef struct godot_array godot_array;
-typedef struct godot_pool_byte_array godot_pool_byte_array;
-typedef struct godot_pool_int_array godot_pool_int_array;
-typedef struct godot_pool_real_array godot_pool_real_array;
-typedef struct godot_pool_string_array godot_pool_string_array;
-typedef struct godot_pool_vector2_array godot_pool_vector2_array;
-typedef struct godot_pool_vector3_array godot_pool_vector3_array;
-typedef struct godot_pool_color_array godot_pool_color_array;
-
-/////// String
-
-#include "godot/godot_string.h"
-
-////// Vector2
-
-#include "godot/godot_vector2.h"
-
-////// Rect2
-
-#include "godot/godot_rect2.h"
-
-////// Vector3
-
-#include "godot/godot_vector3.h"
-
-////// Transform2D
-
-#include "godot/godot_transform2d.h"
-
-/////// Plane
-
-#include "godot/godot_plane.h"
-
-/////// Quat
-
-#include "godot/godot_quat.h"
-
-/////// Rect3
-
-#include "godot/godot_rect3.h"
-
-/////// Basis
-
-#include "godot/godot_basis.h"
-
-/////// Transform
-
-#include "godot/godot_transform.h"
-
-/////// Color
-
-#include "godot/godot_color.h"
-
-/////// NodePath
-
-#include "godot/godot_node_path.h"
-
-/////// RID
-
-#include "godot/godot_rid.h"
-
-/////// Dictionary
-
-#include "godot/godot_dictionary.h"
-
-/////// Array
-
-#include "godot/godot_array.h"
-
-// single API file for Pool*Array
-#include "godot/godot_pool_arrays.h"
-
-void GDAPI godot_object_destroy(godot_object *p_o);
-
-////// Variant
-
-#include "godot/godot_variant.h"
-
-////// Singleton API
-
-godot_object GDAPI *godot_global_get_singleton(char *p_name); // result shouldn't be freed
-
-////// MethodBind API
-
-typedef struct godot_method_bind {
- uint8_t _dont_touch_that[1]; // TODO
-} godot_method_bind;
-
-godot_method_bind GDAPI *godot_method_bind_get_method(const char *p_classname, const char *p_methodname);
-void GDAPI godot_method_bind_ptrcall(godot_method_bind *p_method_bind, godot_object *p_instance, const void **p_args, void *p_ret);
-godot_variant GDAPI godot_method_bind_call(godot_method_bind *p_method_bind, godot_object *p_instance, const godot_variant **p_args, const int p_arg_count, godot_variant_call_error *p_call_error);
-////// Script API
-
-typedef struct godot_native_init_options {
- godot_bool in_editor;
- uint64_t core_api_hash;
- uint64_t editor_api_hash;
- uint64_t no_api_hash;
-} godot_native_init_options;
-
-typedef struct godot_native_terminate_options {
- godot_bool in_editor;
-} godot_native_terminate_options;
-
-typedef enum godot_method_rpc_mode {
+typedef enum {
GODOT_METHOD_RPC_MODE_DISABLED,
GODOT_METHOD_RPC_MODE_REMOTE,
GODOT_METHOD_RPC_MODE_SYNC,
@@ -274,11 +80,7 @@ typedef enum godot_method_rpc_mode {
GODOT_METHOD_RPC_MODE_SLAVE,
} godot_method_rpc_mode;
-typedef struct godot_method_attributes {
- godot_method_rpc_mode rpc_type;
-} godot_method_attributes;
-
-typedef enum godot_property_hint {
+typedef enum {
GODOT_PROPERTY_HINT_NONE, ///< no hint provided.
GODOT_PROPERTY_HINT_RANGE, ///< hint_text = "min,max,step,slider; //slider is optional"
GODOT_PROPERTY_HINT_EXP_RANGE, ///< hint_text = "min,max,step", exponential edit
@@ -315,7 +117,7 @@ typedef enum godot_property_hint {
GODOT_PROPERTY_HINT_MAX,
} godot_property_hint;
-typedef enum godot_property_usage_flags {
+typedef enum {
GODOT_PROPERTY_USAGE_STORAGE = 1,
GODOT_PROPERTY_USAGE_EDITOR = 2,
@@ -340,7 +142,7 @@ typedef enum godot_property_usage_flags {
GODOT_PROPERTY_USAGE_NOEDITOR = GODOT_PROPERTY_USAGE_STORAGE | GODOT_PROPERTY_USAGE_NETWORK,
} godot_property_usage_flags;
-typedef struct godot_property_attributes {
+typedef struct {
godot_method_rpc_mode rset_type;
godot_int type;
@@ -350,50 +152,54 @@ typedef struct godot_property_attributes {
godot_variant default_value;
} godot_property_attributes;
-typedef struct godot_instance_create_func {
+typedef struct {
// instance pointer, method_data - return user data
GDCALLINGCONV void *(*create_func)(godot_object *, void *);
void *method_data;
GDCALLINGCONV void (*free_func)(void *);
} godot_instance_create_func;
-typedef struct godot_instance_destroy_func {
+typedef struct {
// instance pointer, method data, user data
GDCALLINGCONV void (*destroy_func)(godot_object *, void *, void *);
void *method_data;
GDCALLINGCONV void (*free_func)(void *);
} godot_instance_destroy_func;
-void GDAPI godot_script_register_class(const char *p_name, const char *p_base, godot_instance_create_func p_create_func, godot_instance_destroy_func p_destroy_func);
+void GDAPI godot_nativescript_register_class(void *p_gdnative_handle, const char *p_name, const char *p_base, godot_instance_create_func p_create_func, godot_instance_destroy_func p_destroy_func);
-void GDAPI godot_script_register_tool_class(const char *p_name, const char *p_base, godot_instance_create_func p_create_func, godot_instance_destroy_func p_destroy_func);
+void GDAPI godot_nativescript_register_tool_class(void *p_gdnative_handle, const char *p_name, const char *p_base, godot_instance_create_func p_create_func, godot_instance_destroy_func p_destroy_func);
+
+typedef struct {
+ godot_method_rpc_mode rpc_type;
+} godot_method_attributes;
-typedef struct godot_instance_method {
+typedef struct {
// instance pointer, method data, user data, num args, args - return result as varaint
GDCALLINGCONV godot_variant (*method)(godot_object *, void *, void *, int, godot_variant **);
void *method_data;
GDCALLINGCONV void (*free_func)(void *);
} godot_instance_method;
-void GDAPI godot_script_register_method(const char *p_name, const char *p_function_name, godot_method_attributes p_attr, godot_instance_method p_method);
+void GDAPI godot_nativescript_register_method(void *p_gdnative_handle, const char *p_name, const char *p_function_name, godot_method_attributes p_attr, godot_instance_method p_method);
-typedef struct godot_property_set_func {
+typedef struct {
// instance pointer, method data, user data, value
- GDCALLINGCONV void (*set_func)(godot_object *, void *, void *, godot_variant);
+ GDCALLINGCONV void (*set_func)(godot_object *, void *, void *, godot_variant *);
void *method_data;
GDCALLINGCONV void (*free_func)(void *);
} godot_property_set_func;
-typedef struct godot_property_get_func {
+typedef struct {
// instance pointer, method data, user data, value
GDCALLINGCONV godot_variant (*get_func)(godot_object *, void *, void *);
void *method_data;
GDCALLINGCONV void (*free_func)(void *);
} godot_property_get_func;
-void GDAPI godot_script_register_property(const char *p_name, const char *p_path, godot_property_attributes *p_attr, godot_property_set_func p_set_func, godot_property_get_func p_get_func);
+void GDAPI godot_nativescript_register_property(void *p_gdnative_handle, const char *p_name, const char *p_path, godot_property_attributes *p_attr, godot_property_set_func p_set_func, godot_property_get_func p_get_func);
-typedef struct godot_signal_argument {
+typedef struct {
godot_string name;
godot_int type;
godot_property_hint hint;
@@ -402,7 +208,7 @@ typedef struct godot_signal_argument {
godot_variant default_value;
} godot_signal_argument;
-typedef struct godot_signal {
+typedef struct {
godot_string name;
int num_args;
godot_signal_argument *args;
@@ -410,31 +216,12 @@ typedef struct godot_signal {
godot_variant *default_args;
} godot_signal;
-void GDAPI godot_script_register_signal(const char *p_name, const godot_signal *p_signal);
-
-void GDAPI *godot_native_get_userdata(godot_object *p_instance);
-
-// Calling convention?
-typedef godot_object *(*godot_class_constructor)();
-
-godot_class_constructor GDAPI godot_get_class_constructor(const char *p_classname);
+void GDAPI godot_nativescript_register_signal(void *p_gdnative_handle, const char *p_name, const godot_signal *p_signal);
-godot_dictionary GDAPI godot_get_global_constants();
-
-////// System Functions
-
-//using these will help Godot track how much memory is in use in debug mode
-void GDAPI *godot_alloc(int p_bytes);
-void GDAPI *godot_realloc(void *p_ptr, int p_bytes);
-void GDAPI godot_free(void *p_ptr);
-
-//print using Godot's error handler list
-void GDAPI godot_print_error(const char *p_description, const char *p_function, const char *p_file, int p_line);
-void GDAPI godot_print_warning(const char *p_description, const char *p_function, const char *p_file, int p_line);
-void GDAPI godot_print(const godot_string *p_message);
+void GDAPI *godot_nativescript_get_userdata(godot_object *p_instance);
#ifdef __cplusplus
}
#endif
-#endif // GODOT_C_H
+#endif
diff --git a/modules/nativescript/nativescript.cpp b/modules/nativescript/nativescript.cpp
new file mode 100644
index 0000000000..e7445e6da9
--- /dev/null
+++ b/modules/nativescript/nativescript.cpp
@@ -0,0 +1,1232 @@
+/*************************************************************************/
+/* nativescript.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+#include "nativescript.h"
+
+#include "modules/gdnative/godot/gdnative.h"
+
+#include "global_constants.h"
+#include "io/file_access_encrypted.h"
+#include "os/file_access.h"
+#include "os/os.h"
+#include "project_settings.h"
+
+#include "scene/main/scene_tree.h"
+#include "scene/resources/scene_format_text.h"
+
+#ifndef NO_THREADS
+#include "os/thread.h"
+#endif
+
+#if defined(TOOLS_ENABLED) && defined(DEBUG_METHODS_ENABLED)
+#include "api_generator.h"
+#endif
+
+#ifdef TOOLS_ENABLED
+#include "editor/editor_node.h"
+#endif
+
+////// Script stuff
+
+void NativeScript::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("set_class_name", "class_name:String"), &NativeScript::set_class_name);
+ ClassDB::bind_method(D_METHOD("get_class_name:String"), &NativeScript::get_class_name);
+
+ ClassDB::bind_method(D_METHOD("set_library", "library:GDNativeLibrary"), &NativeScript::set_library);
+ ClassDB::bind_method(D_METHOD("get_library:GDNativeLibrary"), &NativeScript::get_library);
+
+ ADD_PROPERTYNZ(PropertyInfo(Variant::STRING, "class_name"), "set_class_name", "get_class_name");
+ ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT, "library", PROPERTY_HINT_RESOURCE_TYPE, "GDNativeLibrary"), "set_library", "get_library");
+
+ ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "new", &NativeScript::_new, MethodInfo(Variant::OBJECT, "new"));
+}
+
+#define NSL NativeScriptLanguage::get_singleton()
+
+#ifdef TOOLS_ENABLED
+
+void NativeScript::_update_placeholder(PlaceHolderScriptInstance *p_placeholder) {
+ NativeScriptDesc *script_data = get_script_desc();
+
+ ERR_FAIL_COND(!script_data);
+
+ List<PropertyInfo> info;
+ Map<StringName, Variant> values;
+
+ for (Map<StringName, NativeScriptDesc::Property>::Element *E = script_data->properties.front(); E; E = E->next()) {
+ PropertyInfo p = E->get().info;
+ p.name = String(E->key());
+
+ info.push_back(p);
+ values[p.name] = E->get().default_value;
+ }
+
+ p_placeholder->update(info, values);
+}
+
+void NativeScript::_placeholder_erased(PlaceHolderScriptInstance *p_placeholder) {
+ placeholders.erase(p_placeholder);
+}
+
+#endif
+
+void NativeScript::set_class_name(String p_class_name) {
+ class_name = p_class_name;
+}
+
+String NativeScript::get_class_name() const {
+ return class_name;
+}
+
+void NativeScript::set_library(Ref<GDNativeLibrary> p_library) {
+ if (!library.is_null()) {
+ WARN_PRINT("library on NativeScript already set. Do nothing.");
+ return;
+ }
+ library = p_library;
+ lib_path = library->get_active_library_path();
+
+#ifndef NO_THREADS
+ if (Thread::get_caller_ID() != Thread::get_main_ID()) {
+ NSL->defer_init_library(p_library, this);
+ } else
+#endif
+ {
+ NSL->init_library(p_library);
+ NSL->register_script(this);
+ }
+}
+
+Ref<GDNativeLibrary> NativeScript::get_library() const {
+ return library;
+}
+
+bool NativeScript::can_instance() const {
+
+ NativeScriptDesc *script_data = get_script_desc();
+
+#ifdef TOOLS_ENABLED
+
+ return script_data || (!is_tool() && !ScriptServer::is_scripting_enabled());
+#else
+ return script_data;
+#endif
+}
+
+// TODO(karroffel): implement this
+Ref<Script> NativeScript::get_base_script() const {
+ NativeScriptDesc *script_data = get_script_desc();
+
+ if (!script_data)
+ return Ref<Script>();
+
+ Ref<NativeScript> ns = Ref<NativeScript>(NSL->create_script());
+ ns->set_class_name(script_data->base);
+ ns->set_library(get_library());
+ return ns;
+}
+
+StringName NativeScript::get_instance_base_type() const {
+ NativeScriptDesc *script_data = get_script_desc();
+
+ if (!script_data)
+ return "";
+
+ return script_data->base_native_type;
+}
+
+ScriptInstance *NativeScript::instance_create(Object *p_this) {
+
+ NativeScriptDesc *script_data = get_script_desc();
+
+ if (!script_data) {
+ return NULL;
+ }
+
+#ifdef TOOLS_ENABLED
+ if (!ScriptServer::is_scripting_enabled() && !is_tool()) {
+ // placeholder for nodes. For tools we want the rool thing.
+
+ PlaceHolderScriptInstance *sins = memnew(PlaceHolderScriptInstance(NSL, Ref<Script>(this), p_this));
+ placeholders.insert(sins);
+
+ if (script_data->create_func.create_func) {
+ script_data->create_func.create_func(
+ (godot_object *)p_this,
+ script_data->create_func.method_data);
+ }
+
+ _update_placeholder(sins);
+
+ return sins;
+ }
+#endif
+
+ NativeScriptInstance *nsi = memnew(NativeScriptInstance);
+
+ nsi->owner = p_this;
+ nsi->script = Ref<NativeScript>(this);
+
+#ifndef TOOLS_ENABLED
+ if (!ScriptServer::is_scripting_enabled()) {
+ nsi->userdata = NULL;
+ } else {
+ nsi->userdata = script_data->create_func.create_func((godot_object *)p_this, script_data->create_func.method_data);
+ }
+#else
+ nsi->userdata = script_data->create_func.create_func((godot_object *)p_this, script_data->create_func.method_data);
+#endif
+
+#ifndef NO_THREADS
+ owners_lock->lock();
+#endif
+
+ instance_owners.insert(p_this);
+
+#ifndef NO_THREADS
+ owners_lock->unlock();
+#endif
+
+ // try to call _init
+ // we don't care if it doesn't exist, so we ignore errors.
+ Variant::CallError err;
+ call("_init", NULL, 0, err);
+
+ return nsi;
+}
+
+bool NativeScript::instance_has(const Object *p_this) const {
+ return instance_owners.has((Object *)p_this);
+}
+
+bool NativeScript::has_source_code() const {
+ return false;
+}
+
+String NativeScript::get_source_code() const {
+ return "";
+}
+
+void NativeScript::set_source_code(const String &p_code) {
+}
+
+Error NativeScript::reload(bool p_keep_state) {
+ return FAILED;
+}
+
+bool NativeScript::has_method(const StringName &p_method) const {
+ NativeScriptDesc *script_data = get_script_desc();
+
+ while (script_data) {
+ if (script_data->methods.has(p_method))
+ return true;
+
+ script_data = script_data->base_data;
+ }
+ return false;
+}
+
+MethodInfo NativeScript::get_method_info(const StringName &p_method) const {
+ NativeScriptDesc *script_data = get_script_desc();
+
+ if (!script_data)
+ return MethodInfo();
+
+ while (script_data) {
+ Map<StringName, NativeScriptDesc::Method>::Element *M = script_data->methods.find(p_method);
+
+ if (M)
+ return M->get().info;
+
+ script_data = script_data->base_data;
+ }
+ return MethodInfo();
+}
+
+bool NativeScript::is_tool() const {
+ NativeScriptDesc *script_data = get_script_desc();
+
+ if (script_data)
+ return script_data->is_tool;
+
+ return false;
+}
+
+String NativeScript::get_node_type() const {
+ return ""; // NOTE(karroffel): uhm?
+}
+
+ScriptLanguage *NativeScript::get_language() const {
+ return NativeScriptLanguage::get_singleton();
+}
+
+bool NativeScript::has_script_signal(const StringName &p_signal) const {
+ NativeScriptDesc *script_data = get_script_desc();
+
+ while (script_data) {
+ if (script_data->signals_.has(p_signal))
+ return true;
+ script_data = script_data->base_data;
+ }
+ return false;
+}
+
+void NativeScript::get_script_signal_list(List<MethodInfo> *r_signals) const {
+ NativeScriptDesc *script_data = get_script_desc();
+
+ if (!script_data)
+ return;
+
+ Set<MethodInfo> signals_;
+
+ while (script_data) {
+
+ for (Map<StringName, NativeScriptDesc::Signal>::Element *S = script_data->signals_.front(); S; S = S->next()) {
+ signals_.insert(S->get().signal);
+ }
+
+ script_data = script_data->base_data;
+ }
+
+ for (Set<MethodInfo>::Element *E = signals_.front(); E; E = E->next()) {
+ r_signals->push_back(E->get());
+ }
+}
+
+bool NativeScript::get_property_default_value(const StringName &p_property, Variant &r_value) const {
+ NativeScriptDesc *script_data = get_script_desc();
+
+ if (!script_data)
+ return false;
+
+ Map<StringName, NativeScriptDesc::Property>::Element *P = script_data->properties.find(p_property);
+
+ if (!P)
+ return false;
+
+ r_value = P->get().default_value;
+ return true;
+}
+
+void NativeScript::update_exports() {
+}
+
+void NativeScript::get_script_method_list(List<MethodInfo> *p_list) const {
+ NativeScriptDesc *script_data = get_script_desc();
+
+ if (!script_data)
+ return;
+
+ Set<MethodInfo> methods;
+
+ while (script_data) {
+
+ for (Map<StringName, NativeScriptDesc::Method>::Element *E = script_data->methods.front(); E; E = E->next()) {
+ methods.insert(E->get().info);
+ }
+
+ script_data = script_data->base_data;
+ }
+
+ for (Set<MethodInfo>::Element *E = methods.front(); E; E = E->next()) {
+ p_list->push_back(E->get());
+ }
+}
+
+void NativeScript::get_script_property_list(List<PropertyInfo> *p_list) const {
+ NativeScriptDesc *script_data = get_script_desc();
+
+ if (!script_data)
+ return;
+
+ Set<PropertyInfo> properties;
+
+ while (script_data) {
+
+ for (Map<StringName, NativeScriptDesc::Property>::Element *E = script_data->properties.front(); E; E = E->next()) {
+ properties.insert(E->get().info);
+ }
+
+ script_data = script_data->base_data;
+ }
+
+ for (Set<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) {
+ p_list->push_back(E->get());
+ }
+}
+
+Variant NativeScript::_new(const Variant **p_args, int p_argcount, Variant::CallError &r_error) {
+
+ if (lib_path.empty() || class_name.empty() || library.is_null()) {
+ r_error.error = Variant::CallError::CALL_ERROR_INSTANCE_IS_NULL;
+ return Variant();
+ }
+
+ NativeScriptDesc *script_data = get_script_desc();
+
+ if (!script_data) {
+ r_error.error = Variant::CallError::CALL_ERROR_INSTANCE_IS_NULL;
+ return Variant();
+ }
+
+ r_error.error = Variant::CallError::CALL_OK;
+
+ REF ref;
+ Object *owner = NULL;
+
+ if (!(script_data->base_native_type == "")) {
+ owner = ClassDB::instance(script_data->base_native_type);
+ } else {
+ owner = memnew(Reference);
+ }
+
+ Reference *r = owner->cast_to<Reference>();
+ if (r) {
+ ref = REF(r);
+ }
+
+ NativeScriptInstance *instance = (NativeScriptInstance *)instance_create(owner);
+
+ owner->set_script_instance(instance);
+
+ if (!instance) {
+ if (ref.is_null()) {
+ memdelete(owner); //no owner, sorry
+ }
+ return Variant();
+ }
+
+ if (ref.is_valid()) {
+ return ref;
+ } else {
+ return owner;
+ }
+}
+
+// TODO(karroffel): implement this
+NativeScript::NativeScript() {
+ library = Ref<GDNative>();
+ lib_path = "";
+ class_name = "";
+#ifndef NO_THREADS
+ owners_lock = Mutex::create();
+#endif
+}
+
+// TODO(karroffel): implement this
+NativeScript::~NativeScript() {
+ NSL->unregister_script(this);
+
+#ifndef NO_THREADS
+ memdelete(owners_lock);
+#endif
+}
+
+////// ScriptInstance stuff
+
+#define GET_SCRIPT_DESC() script->get_script_desc()
+
+void NativeScriptInstance::_ml_call_reversed(NativeScriptDesc *script_data, const StringName &p_method, const Variant **p_args, int p_argcount) {
+ if (script_data->base_data) {
+ _ml_call_reversed(script_data->base_data, p_method, p_args, p_argcount);
+ }
+
+ Map<StringName, NativeScriptDesc::Method>::Element *E = script_data->methods.find(p_method);
+ if (E) {
+ godot_variant res = E->get().method.method((godot_object *)owner, E->get().method.method_data, userdata, p_argcount, (godot_variant **)p_args);
+ godot_variant_destroy(&res);
+ }
+}
+
+bool NativeScriptInstance::set(const StringName &p_name, const Variant &p_value) {
+ NativeScriptDesc *script_data = GET_SCRIPT_DESC();
+
+ while (script_data) {
+ Map<StringName, NativeScriptDesc::Property>::Element *P = script_data->properties.find(p_name);
+ if (P) {
+ P->get().setter.set_func((godot_object *)owner,
+ P->get().setter.method_data,
+ userdata,
+ (godot_variant *)&p_value);
+ return true;
+ }
+
+ Map<StringName, NativeScriptDesc::Method>::Element *E = script_data->methods.find("_set");
+ if (E) {
+ Variant name = p_name;
+ const Variant *args[2] = { &name, &p_value };
+
+ E->get().method.method((godot_object *)owner,
+ E->get().method.method_data,
+ userdata,
+ 2,
+ (godot_variant **)args);
+ return true;
+ }
+
+ script_data = script_data->base_data;
+ }
+ return false;
+}
+bool NativeScriptInstance::get(const StringName &p_name, Variant &r_ret) const {
+ NativeScriptDesc *script_data = GET_SCRIPT_DESC();
+
+ while (script_data) {
+ Map<StringName, NativeScriptDesc::Property>::Element *P = script_data->properties.find(p_name);
+ if (P) {
+ godot_variant value;
+ value = P->get().getter.get_func((godot_object *)owner,
+ P->get().getter.method_data,
+ userdata);
+ r_ret = *(Variant *)&value;
+ godot_variant_destroy(&value);
+ return true;
+ }
+
+ Map<StringName, NativeScriptDesc::Method>::Element *E = script_data->methods.find("_get");
+ if (E) {
+ Variant name = p_name;
+ const Variant *args[1] = { &name };
+
+ godot_variant result;
+ result = E->get().method.method((godot_object *)owner,
+ E->get().method.method_data,
+ userdata,
+ 1,
+ (godot_variant **)args);
+ r_ret = *(Variant *)&result;
+ godot_variant_destroy(&result);
+ if (r_ret.get_type() == Variant::NIL) {
+ return false;
+ }
+ return true;
+ }
+
+ script_data = script_data->base_data;
+ }
+ return false;
+}
+
+void NativeScriptInstance::get_property_list(List<PropertyInfo> *p_properties) const {
+ script->get_script_property_list(p_properties);
+
+ NativeScriptDesc *script_data = GET_SCRIPT_DESC();
+
+ while (script_data) {
+
+ Map<StringName, NativeScriptDesc::Method>::Element *E = script_data->methods.find("_get_property_list");
+ if (E) {
+
+ godot_variant result;
+ result = E->get().method.method((godot_object *)owner,
+ E->get().method.method_data,
+ userdata,
+ 0,
+ NULL);
+ Variant res = *(Variant *)&result;
+ godot_variant_destroy(&result);
+
+ if (res.get_type() != Variant::ARRAY) {
+ ERR_EXPLAIN("_get_property_list must return an array of dictionaries");
+ ERR_FAIL();
+ }
+
+ Array arr = res;
+ for (int i = 0; i < arr.size(); i++) {
+ Dictionary d = arr[i];
+
+ ERR_CONTINUE(!d.has("name"));
+ ERR_CONTINUE(!d.has("type"));
+
+ PropertyInfo info;
+
+ info.type = Variant::Type(d["type"].operator int64_t());
+ ERR_CONTINUE(info.type < 0 || info.type >= Variant::VARIANT_MAX);
+
+ info.name = d["name"];
+ ERR_CONTINUE(info.name == "");
+
+ if (d.has("hint")) {
+ info.hint = PropertyHint(d["hint"].operator int64_t());
+ }
+
+ if (d.has("hint_string")) {
+ info.hint_string = d["hint_string"];
+ }
+
+ if (d.has("usage")) {
+ info.usage = d["usage"];
+ }
+
+ p_properties->push_back(info);
+ }
+ }
+
+ script_data = script_data->base_data;
+ }
+ return;
+}
+
+Variant::Type NativeScriptInstance::get_property_type(const StringName &p_name, bool *r_is_valid) const {
+
+ NativeScriptDesc *script_data = GET_SCRIPT_DESC();
+
+ while (script_data) {
+
+ Map<StringName, NativeScriptDesc::Property>::Element *P = script_data->properties.find(p_name);
+ if (P) {
+ *r_is_valid = true;
+ return P->get().info.type;
+ }
+
+ script_data = script_data->base_data;
+ }
+ return Variant::NIL;
+}
+
+void NativeScriptInstance::get_method_list(List<MethodInfo> *p_list) const {
+ script->get_method_list(p_list);
+}
+
+bool NativeScriptInstance::has_method(const StringName &p_method) const {
+ return script->has_method(p_method);
+}
+
+Variant NativeScriptInstance::call(const StringName &p_method, const Variant **p_args, int p_argcount, Variant::CallError &r_error) {
+
+ NativeScriptDesc *script_data = GET_SCRIPT_DESC();
+
+ while (script_data) {
+ Map<StringName, NativeScriptDesc::Method>::Element *E = script_data->methods.find(p_method);
+ if (E) {
+ godot_variant result;
+ result = E->get().method.method((godot_object *)owner,
+ E->get().method.method_data,
+ userdata,
+ p_argcount,
+ (godot_variant **)p_args);
+ Variant res = *(Variant *)&result;
+ godot_variant_destroy(&result);
+ r_error.error = Variant::CallError::CALL_OK;
+ return res;
+ }
+
+ script_data = script_data->base_data;
+ }
+
+ r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
+ return Variant();
+}
+
+void NativeScriptInstance::notification(int p_notification) {
+ Variant value = p_notification;
+ const Variant *args[1] = { &value };
+ call_multilevel("_notification", args, 1);
+}
+
+void NativeScriptInstance::refcount_incremented() {
+ Variant::CallError err;
+ call("_refcount_incremented", NULL, 0, err);
+ if (err.error != Variant::CallError::CALL_OK && err.error != Variant::CallError::CALL_ERROR_INVALID_METHOD) {
+ ERR_PRINT("Failed to invoke _refcount_incremented - should not happen");
+ }
+}
+
+bool NativeScriptInstance::refcount_decremented() {
+ Variant::CallError err;
+ Variant ret = call("_refcount_decremented", NULL, 0, err);
+ if (err.error != Variant::CallError::CALL_OK && err.error != Variant::CallError::CALL_ERROR_INVALID_METHOD) {
+ ERR_PRINT("Failed to invoke _refcount_decremented - should not happen");
+ return true; // assume we can destroy the object
+ }
+ if (err.error == Variant::CallError::CALL_ERROR_INVALID_METHOD) {
+ // the method does not exist, default is true
+ return true;
+ }
+ return ret;
+}
+
+Ref<Script> NativeScriptInstance::get_script() const {
+ return script;
+}
+
+NativeScriptInstance::RPCMode NativeScriptInstance::get_rpc_mode(const StringName &p_method) const {
+
+ NativeScriptDesc *script_data = GET_SCRIPT_DESC();
+
+ while (script_data) {
+
+ Map<StringName, NativeScriptDesc::Method>::Element *E = script_data->methods.find(p_method);
+ if (E) {
+ switch (E->get().rpc_mode) {
+ case GODOT_METHOD_RPC_MODE_DISABLED:
+ return RPC_MODE_DISABLED;
+ case GODOT_METHOD_RPC_MODE_REMOTE:
+ return RPC_MODE_REMOTE;
+ case GODOT_METHOD_RPC_MODE_SYNC:
+ return RPC_MODE_SYNC;
+ case GODOT_METHOD_RPC_MODE_MASTER:
+ return RPC_MODE_MASTER;
+ case GODOT_METHOD_RPC_MODE_SLAVE:
+ return RPC_MODE_SLAVE;
+ default:
+ return RPC_MODE_DISABLED;
+ }
+ }
+
+ script_data = script_data->base_data;
+ }
+
+ return RPC_MODE_DISABLED;
+}
+
+// TODO(karroffel): implement this
+NativeScriptInstance::RPCMode NativeScriptInstance::get_rset_mode(const StringName &p_variable) const {
+
+ NativeScriptDesc *script_data = GET_SCRIPT_DESC();
+
+ while (script_data) {
+
+ Map<StringName, NativeScriptDesc::Property>::Element *E = script_data->properties.find(p_variable);
+ if (E) {
+ switch (E->get().rset_mode) {
+ case GODOT_METHOD_RPC_MODE_DISABLED:
+ return RPC_MODE_DISABLED;
+ case GODOT_METHOD_RPC_MODE_REMOTE:
+ return RPC_MODE_REMOTE;
+ case GODOT_METHOD_RPC_MODE_SYNC:
+ return RPC_MODE_SYNC;
+ case GODOT_METHOD_RPC_MODE_MASTER:
+ return RPC_MODE_MASTER;
+ case GODOT_METHOD_RPC_MODE_SLAVE:
+ return RPC_MODE_SLAVE;
+ default:
+ return RPC_MODE_DISABLED;
+ }
+ }
+
+ script_data = script_data->base_data;
+ }
+
+ return RPC_MODE_DISABLED;
+}
+
+ScriptLanguage *NativeScriptInstance::get_language() {
+ return NativeScriptLanguage::get_singleton();
+}
+
+void NativeScriptInstance::call_multilevel(const StringName &p_method, const Variant **p_args, int p_argcount) {
+ NativeScriptDesc *script_data = GET_SCRIPT_DESC();
+
+ while (script_data) {
+ Map<StringName, NativeScriptDesc::Method>::Element *E = script_data->methods.find(p_method);
+ if (E) {
+ godot_variant res = E->get().method.method((godot_object *)owner,
+ E->get().method.method_data,
+ userdata,
+ p_argcount,
+ (godot_variant **)p_args);
+ godot_variant_destroy(&res);
+ }
+ script_data = script_data->base_data;
+ }
+}
+
+void NativeScriptInstance::call_multilevel_reversed(const StringName &p_method, const Variant **p_args, int p_argcount) {
+ NativeScriptDesc *script_data = GET_SCRIPT_DESC();
+
+ if (script_data) {
+ _ml_call_reversed(script_data, p_method, p_args, p_argcount);
+ }
+}
+
+NativeScriptInstance::~NativeScriptInstance() {
+
+ NativeScriptDesc *script_data = GET_SCRIPT_DESC();
+
+ if (!script_data)
+ return;
+
+ script_data->destroy_func.destroy_func((godot_object *)owner, script_data->destroy_func.method_data, userdata);
+
+ if (owner) {
+
+#ifndef NO_THREADS
+ script->owners_lock->lock();
+#endif
+
+ script->instance_owners.erase(owner);
+
+#ifndef NO_THREADS
+ script->owners_lock->unlock();
+#endif
+ }
+}
+
+////// ScriptingLanguage stuff
+
+NativeScriptLanguage *NativeScriptLanguage::singleton;
+
+extern "C" void _native_script_hook();
+void NativeScriptLanguage::_hacky_api_anchor() {
+ _native_script_hook();
+}
+
+void NativeScriptLanguage::_unload_stuff() {
+ for (Map<String, Map<StringName, NativeScriptDesc> >::Element *L = library_classes.front(); L; L = L->next()) {
+ for (Map<StringName, NativeScriptDesc>::Element *C = L->get().front(); C; C = C->next()) {
+
+ // free property stuff first
+ for (Map<StringName, NativeScriptDesc::Property>::Element *P = C->get().properties.front(); P; P = P->next()) {
+ if (P->get().getter.free_func)
+ P->get().getter.free_func(P->get().getter.method_data);
+
+ if (P->get().setter.free_func)
+ P->get().setter.free_func(P->get().setter.method_data);
+ }
+
+ // free method stuff
+ for (Map<StringName, NativeScriptDesc::Method>::Element *M = C->get().methods.front(); M; M = M->next()) {
+ if (M->get().method.free_func)
+ M->get().method.free_func(M->get().method.method_data);
+ }
+
+ // free constructor/destructor
+ if (C->get().create_func.free_func)
+ C->get().create_func.free_func(C->get().create_func.method_data);
+
+ if (C->get().destroy_func.free_func)
+ C->get().destroy_func.free_func(C->get().destroy_func.method_data);
+ }
+ }
+}
+
+NativeScriptLanguage::NativeScriptLanguage() {
+ NativeScriptLanguage::singleton = this;
+#ifndef NO_THREADS
+ mutex = Mutex::create();
+#endif
+}
+
+// TODO(karroffel): implement this
+NativeScriptLanguage::~NativeScriptLanguage() {
+ // _unload_stuff(); // NOTE(karroffel): This gets called in ::finish()
+
+ for (Map<String, Ref<GDNative> >::Element *L = NSL->library_gdnatives.front(); L; L = L->next()) {
+
+ L->get()->terminate();
+ NSL->library_classes.clear();
+ NSL->library_gdnatives.clear();
+ NSL->library_script_users.clear();
+ }
+
+#ifndef NO_THREADS
+ memdelete(mutex);
+#endif
+}
+
+String NativeScriptLanguage::get_name() const {
+ return "NativeScript";
+}
+
+void _add_reload_node() {
+#ifdef TOOLS_ENABLED
+ NativeReloadNode *rn = memnew(NativeReloadNode);
+ EditorNode::get_singleton()->add_child(rn);
+#endif
+}
+
+// TODO(karroffel): implement this
+void NativeScriptLanguage::init() {
+
+#if defined(TOOLS_ENABLED) && defined(DEBUG_METHODS_ENABLED)
+
+ List<String> args = OS::get_singleton()->get_cmdline_args();
+
+ List<String>::Element *E = args.find("--gdnative-generate-json-api");
+
+ if (E && E->next()) {
+ if (generate_c_api(E->next()->get()) != OK) {
+ ERR_PRINT("Failed to generate C API\n");
+ }
+ }
+#endif
+
+#ifdef TOOLS_ENABLED
+ EditorNode::add_init_callback(&_add_reload_node);
+#endif
+}
+String NativeScriptLanguage::get_type() const {
+ return "NativeScript";
+}
+String NativeScriptLanguage::get_extension() const {
+ return "gdns";
+}
+Error NativeScriptLanguage::execute_file(const String &p_path) {
+ return OK; // Qué?
+}
+void NativeScriptLanguage::finish() {
+ _unload_stuff();
+}
+void NativeScriptLanguage::get_reserved_words(List<String> *p_words) const {
+}
+void NativeScriptLanguage::get_comment_delimiters(List<String> *p_delimiters) const {
+}
+void NativeScriptLanguage::get_string_delimiters(List<String> *p_delimiters) const {
+}
+
+// TODO(karroffel): implement this
+Ref<Script> NativeScriptLanguage::get_template(const String &p_class_name, const String &p_base_class_name) const {
+ NativeScript *s = memnew(NativeScript);
+ s->set_class_name(p_class_name);
+ // TODO(karroffel): use p_base_class_name
+ return Ref<NativeScript>(s);
+}
+bool NativeScriptLanguage::validate(const String &p_script, int &r_line_error, int &r_col_error, String &r_test_error, const String &p_path, List<String> *r_functions) const {
+ return false;
+}
+
+Script *NativeScriptLanguage::create_script() const {
+ NativeScript *script = memnew(NativeScript);
+ return script;
+}
+bool NativeScriptLanguage::has_named_classes() const {
+ return true;
+}
+int NativeScriptLanguage::find_function(const String &p_function, const String &p_code) const {
+ return -1;
+}
+String NativeScriptLanguage::make_function(const String &p_class, const String &p_name, const PoolStringArray &p_args) const {
+ return "";
+}
+void NativeScriptLanguage::auto_indent_code(String &p_code, int p_from_line, int p_to_line) const {
+}
+void NativeScriptLanguage::add_global_constant(const StringName &p_variable, const Variant &p_value) {
+}
+
+// Debugging stuff here. Not used for now.
+String NativeScriptLanguage::debug_get_error() const {
+ return "";
+}
+int NativeScriptLanguage::debug_get_stack_level_count() const {
+ return -1;
+}
+int NativeScriptLanguage::debug_get_stack_level_line(int p_level) const {
+ return -1;
+}
+String NativeScriptLanguage::debug_get_stack_level_function(int p_level) const {
+ return "";
+}
+String NativeScriptLanguage::debug_get_stack_level_source(int p_level) const {
+ return "";
+}
+void NativeScriptLanguage::debug_get_stack_level_locals(int p_level, List<String> *p_locals, List<Variant> *p_values, int p_max_subitems, int p_max_depth) {
+}
+void NativeScriptLanguage::debug_get_stack_level_members(int p_level, List<String> *p_members, List<Variant> *p_values, int p_max_subitems, int p_max_depth) {
+}
+void NativeScriptLanguage::debug_get_globals(List<String> *p_locals, List<Variant> *p_values, int p_max_subitems, int p_max_depth) {
+}
+String NativeScriptLanguage::debug_parse_stack_level_expression(int p_level, const String &p_expression, int p_max_subitems, int p_max_depth) {
+ return "";
+}
+// Debugging stuff end.
+
+void NativeScriptLanguage::reload_all_scripts() {
+}
+
+void NativeScriptLanguage::reload_tool_script(const Ref<Script> &p_script, bool p_soft_reload) {
+}
+void NativeScriptLanguage::get_recognized_extensions(List<String> *p_extensions) const {
+ p_extensions->push_back("gdns");
+}
+
+void NativeScriptLanguage::get_public_functions(List<MethodInfo> *p_functions) const {
+}
+
+void NativeScriptLanguage::get_public_constants(List<Pair<String, Variant> > *p_constants) const {
+}
+
+void NativeScriptLanguage::profiling_start() {
+}
+
+void NativeScriptLanguage::profiling_stop() {
+}
+
+int NativeScriptLanguage::profiling_get_accumulated_data(ProfilingInfo *p_info_arr, int p_info_max) {
+ return -1;
+}
+
+int NativeScriptLanguage::profiling_get_frame_data(ProfilingInfo *p_info_arr, int p_info_max) {
+ return -1;
+}
+
+#ifndef NO_THREADS
+void NativeScriptLanguage::defer_init_library(Ref<GDNativeLibrary> lib, NativeScript *script) {
+ MutexLock lock(mutex);
+ libs_to_init.insert(lib);
+ scripts_to_register.insert(script);
+ has_objects_to_register = true;
+}
+#endif
+
+void NativeScriptLanguage::init_library(const Ref<GDNativeLibrary> &lib) {
+#ifndef NO_THREADS
+ MutexLock lock(mutex);
+#endif
+ // See if this library was "registered" already.
+ const String &lib_path = lib->get_active_library_path();
+ Map<String, Ref<GDNative> >::Element *E = library_gdnatives.find(lib_path);
+
+ if (!E) {
+ Ref<GDNative> gdn;
+ gdn.instance();
+ gdn->set_library(lib);
+
+ // TODO(karroffel): check the return value?
+ gdn->initialize();
+
+ library_gdnatives.insert(lib_path, gdn);
+
+ library_classes.insert(lib_path, Map<StringName, NativeScriptDesc>());
+
+ if (!library_script_users.has(lib_path))
+ library_script_users.insert(lib_path, Set<NativeScript *>());
+
+ void *args[1] = {
+ (void *)&lib_path
+ };
+
+ // here the library registers all the classes and stuff.
+ gdn->call_native_raw(_init_call_type,
+ _init_call_name,
+ NULL,
+ 1,
+ args,
+ NULL);
+ } else {
+ // already initialized. Nice.
+ }
+}
+
+void NativeScriptLanguage::register_script(NativeScript *script) {
+#ifndef NO_THREADS
+ MutexLock lock(mutex);
+#endif
+ library_script_users[script->lib_path].insert(script);
+}
+
+void NativeScriptLanguage::unregister_script(NativeScript *script) {
+#ifndef NO_THREADS
+ MutexLock lock(mutex);
+#endif
+ Map<String, Set<NativeScript *> >::Element *S = library_script_users.find(script->lib_path);
+ if (S) {
+ S->get().erase(script);
+ if (S->get().size() == 0) {
+ library_script_users.erase(S);
+ }
+ }
+#ifndef NO_THREADS
+ scripts_to_register.erase(script);
+#endif
+}
+
+#ifndef NO_THREADS
+
+void NativeScriptLanguage::frame() {
+ if (has_objects_to_register) {
+ MutexLock lock(mutex);
+ for (Set<Ref<GDNativeLibrary> >::Element *L = libs_to_init.front(); L; L = L->next()) {
+ init_library(L->get());
+ }
+ libs_to_init.clear();
+ for (Set<NativeScript *>::Element *S = scripts_to_register.front(); S; S = S->next()) {
+ register_script(S->get());
+ }
+ scripts_to_register.clear();
+ has_objects_to_register = false;
+ }
+}
+
+void NativeScriptLanguage::thread_enter() {
+ Vector<Ref<GDNative> > libs;
+ {
+ MutexLock lock(mutex);
+ for (Map<String, Ref<GDNative> >::Element *L = library_gdnatives.front(); L; L = L->next()) {
+ libs.push_back(L->get());
+ }
+ }
+ for (int i = 0; i < libs.size(); ++i) {
+ libs[i]->call_native_raw(
+ _thread_cb_call_type,
+ _thread_enter_call_name,
+ NULL,
+ 0,
+ NULL,
+ NULL);
+ }
+}
+
+void NativeScriptLanguage::thread_exit() {
+ Vector<Ref<GDNative> > libs;
+ {
+ MutexLock lock(mutex);
+ for (Map<String, Ref<GDNative> >::Element *L = library_gdnatives.front(); L; L = L->next()) {
+ libs.push_back(L->get());
+ }
+ }
+ for (int i = 0; i < libs.size(); ++i) {
+ libs[i]->call_native_raw(
+ _thread_cb_call_type,
+ _thread_exit_call_name,
+ NULL,
+ 0,
+ NULL,
+ NULL);
+ }
+}
+
+#endif // NO_THREADS
+
+void NativeReloadNode::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("_notification"), &NativeReloadNode::_notification);
+}
+
+void NativeReloadNode::_notification(int p_what) {
+#ifdef TOOLS_ENABLED
+
+ switch (p_what) {
+ case MainLoop::NOTIFICATION_WM_FOCUS_OUT: {
+
+ if (unloaded)
+ break;
+#ifndef NO_THREADS
+ MutexLock lock(NSL->mutex);
+#endif
+ NSL->_unload_stuff();
+ for (Map<String, Ref<GDNative> >::Element *L = NSL->library_gdnatives.front(); L; L = L->next()) {
+
+ L->get()->terminate();
+ NSL->library_classes.erase(L->key());
+ }
+
+ unloaded = true;
+
+ } break;
+
+ case MainLoop::NOTIFICATION_WM_FOCUS_IN: {
+
+ if (!unloaded)
+ break;
+#ifndef NO_THREADS
+ MutexLock lock(NSL->mutex);
+#endif
+ Set<StringName> libs_to_remove;
+ for (Map<String, Ref<GDNative> >::Element *L = NSL->library_gdnatives.front(); L; L = L->next()) {
+
+ if (!L->get()->initialize()) {
+ libs_to_remove.insert(L->key());
+ continue;
+ }
+
+ NSL->library_classes.insert(L->key(), Map<StringName, NativeScriptDesc>());
+
+ void *args[1] = {
+ (void *)&L->key()
+ };
+
+ // here the library registers all the classes and stuff.
+ L->get()->call_native_raw(NSL->_init_call_type,
+ NSL->_init_call_name,
+ NULL,
+ 1,
+ args,
+ NULL);
+
+ for (Map<String, Set<NativeScript *> >::Element *U = NSL->library_script_users.front(); U; U = U->next()) {
+ for (Set<NativeScript *>::Element *S = U->get().front(); S; S = S->next()) {
+ NativeScript *script = S->get();
+
+ if (script->placeholders.size() == 0)
+ continue;
+
+ for (Set<PlaceHolderScriptInstance *>::Element *P = script->placeholders.front(); P; P = P->next()) {
+ script->_update_placeholder(P->get());
+ }
+ }
+ }
+ }
+
+ unloaded = false;
+
+ for (Set<StringName>::Element *R = libs_to_remove.front(); R; R = R->next()) {
+ NSL->library_gdnatives.erase(R->get());
+ }
+
+ } break;
+ default: {
+ };
+ }
+#endif
+}
+
+RES ResourceFormatLoaderNativeScript::load(const String &p_path, const String &p_original_path, Error *r_error) {
+ ResourceFormatLoaderText rsflt;
+ return rsflt.load(p_path, p_original_path, r_error);
+}
+
+void ResourceFormatLoaderNativeScript::get_recognized_extensions(List<String> *p_extensions) const {
+ p_extensions->push_back("gdns");
+}
+
+bool ResourceFormatLoaderNativeScript::handles_type(const String &p_type) const {
+ return (p_type == "Script" || p_type == "NativeScript");
+}
+
+String ResourceFormatLoaderNativeScript::get_resource_type(const String &p_path) const {
+ String el = p_path.get_extension().to_lower();
+ if (el == "gdns")
+ return "NativeScript";
+ return "";
+}
+
+Error ResourceFormatSaverNativeScript::save(const String &p_path, const RES &p_resource, uint32_t p_flags) {
+ ResourceFormatSaverText rfst;
+ return rfst.save(p_path, p_resource, p_flags);
+}
+
+bool ResourceFormatSaverNativeScript::recognize(const RES &p_resource) const {
+ return p_resource->cast_to<NativeScript>() != NULL;
+}
+
+void ResourceFormatSaverNativeScript::get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const {
+ if (p_resource->cast_to<NativeScript>()) {
+ p_extensions->push_back("gdns");
+ }
+}
diff --git a/modules/nativescript/nativescript.h b/modules/nativescript/nativescript.h
new file mode 100644
index 0000000000..95b4954171
--- /dev/null
+++ b/modules/nativescript/nativescript.h
@@ -0,0 +1,317 @@
+/*************************************************************************/
+/* nativescript.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+#ifndef NATIVE_SCRIPT_H
+#define NATIVE_SCRIPT_H
+
+#include "io/resource_loader.h"
+#include "io/resource_saver.h"
+#include "os/thread_safe.h"
+#include "resource.h"
+#include "scene/main/node.h"
+#include "script_language.h"
+#include "self_list.h"
+
+#include "godot_nativescript.h"
+#include "modules/gdnative/gdnative.h"
+
+#ifndef NO_THREADS
+#include "os/mutex.h"
+#endif
+
+struct NativeScriptDesc {
+
+ struct Method {
+ godot_instance_method method;
+ MethodInfo info;
+ int rpc_mode;
+ };
+ struct Property {
+ godot_property_set_func setter;
+ godot_property_get_func getter;
+ PropertyInfo info;
+ Variant default_value;
+ int rset_mode;
+ };
+
+ struct Signal {
+ MethodInfo signal;
+ };
+
+ Map<StringName, Method> methods;
+ Map<StringName, Property> properties;
+ Map<StringName, Signal> signals_; // QtCreator doesn't like the name signals
+ StringName base;
+ StringName base_native_type;
+ NativeScriptDesc *base_data;
+ godot_instance_create_func create_func;
+ godot_instance_destroy_func destroy_func;
+
+ bool is_tool;
+
+ inline NativeScriptDesc()
+ : methods(),
+ properties(),
+ signals_(),
+ base(),
+ base_native_type() {
+ zeromem(&create_func, sizeof(godot_instance_create_func));
+ zeromem(&destroy_func, sizeof(godot_instance_destroy_func));
+ }
+};
+
+class NativeScript : public Script {
+ GDCLASS(NativeScript, Script)
+
+#ifdef TOOLS_ENABLED
+ Set<PlaceHolderScriptInstance *> placeholders;
+ void _update_placeholder(PlaceHolderScriptInstance *p_placeholder);
+ virtual void _placeholder_erased(PlaceHolderScriptInstance *p_placeholder);
+#endif
+
+ friend class NativeScriptInstance;
+ friend class NativeScriptLanguage;
+ friend class NativeReloadNode;
+ friend class GDNativeLibrary;
+
+ Ref<GDNativeLibrary> library;
+
+ String lib_path;
+
+ String class_name;
+
+#ifndef NO_THREADS
+ Mutex *owners_lock;
+#endif
+ Set<Object *> instance_owners;
+
+protected:
+ static void _bind_methods();
+
+public:
+ inline NativeScriptDesc *get_script_desc() const;
+
+ void set_class_name(String p_class_name);
+ String get_class_name() const;
+
+ void set_library(Ref<GDNativeLibrary> library);
+ Ref<GDNativeLibrary> get_library() const;
+
+ virtual bool can_instance() const;
+
+ virtual Ref<Script> get_base_script() const; //for script inheritance
+
+ virtual StringName get_instance_base_type() const; // this may not work in all scripts, will return empty if so
+ virtual ScriptInstance *instance_create(Object *p_this);
+ virtual bool instance_has(const Object *p_this) const;
+
+ virtual bool has_source_code() const;
+ virtual String get_source_code() const;
+ virtual void set_source_code(const String &p_code);
+ virtual Error reload(bool p_keep_state = false);
+
+ virtual bool has_method(const StringName &p_method) const;
+ virtual MethodInfo get_method_info(const StringName &p_method) const;
+
+ virtual bool is_tool() const;
+
+ virtual String get_node_type() const;
+
+ virtual ScriptLanguage *get_language() const;
+
+ virtual bool has_script_signal(const StringName &p_signal) const;
+ virtual void get_script_signal_list(List<MethodInfo> *r_signals) const;
+
+ virtual bool get_property_default_value(const StringName &p_property, Variant &r_value) const;
+
+ virtual void update_exports(); //editor tool
+ virtual void get_script_method_list(List<MethodInfo> *p_list) const;
+ virtual void get_script_property_list(List<PropertyInfo> *p_list) const;
+
+ Variant _new(const Variant **p_args, int p_argcount, Variant::CallError &r_error);
+
+ NativeScript();
+ ~NativeScript();
+};
+
+class NativeScriptInstance : public ScriptInstance {
+
+ friend class NativeScript;
+
+ Object *owner;
+ Ref<NativeScript> script;
+
+ void _ml_call_reversed(NativeScriptDesc *script_data, const StringName &p_method, const Variant **p_args, int p_argcount);
+
+public:
+ void *userdata;
+
+ virtual bool set(const StringName &p_name, const Variant &p_value);
+ virtual bool get(const StringName &p_name, Variant &r_ret) const;
+ virtual void get_property_list(List<PropertyInfo> *p_properties) const;
+ virtual Variant::Type get_property_type(const StringName &p_name, bool *r_is_valid) const;
+ virtual void get_method_list(List<MethodInfo> *p_list) const;
+ virtual bool has_method(const StringName &p_method) const;
+ virtual Variant call(const StringName &p_method, const Variant **p_args, int p_argcount, Variant::CallError &r_error);
+ virtual void notification(int p_notification);
+ virtual Ref<Script> get_script() const;
+ virtual RPCMode get_rpc_mode(const StringName &p_method) const;
+ virtual RPCMode get_rset_mode(const StringName &p_variable) const;
+ virtual ScriptLanguage *get_language();
+
+ virtual void call_multilevel(const StringName &p_method, const Variant **p_args, int p_argcount);
+ virtual void call_multilevel_reversed(const StringName &p_method, const Variant **p_args, int p_argcount);
+
+ virtual void refcount_incremented();
+ virtual bool refcount_decremented();
+
+ ~NativeScriptInstance();
+};
+
+class NativeReloadNode;
+
+class NativeScriptLanguage : public ScriptLanguage {
+
+ friend class NativeScript;
+ friend class NativeScriptInstance;
+ friend class NativeReloadNode;
+
+private:
+ static NativeScriptLanguage *singleton;
+
+ void _unload_stuff();
+
+#ifndef NO_THREADS
+ Mutex *mutex;
+
+ Set<Ref<GDNativeLibrary> > libs_to_init;
+ Set<NativeScript *> scripts_to_register;
+ volatile bool has_objects_to_register; // so that we don't lock mutex every frame - it's rarely needed
+ void defer_init_library(Ref<GDNativeLibrary> lib, NativeScript *script);
+#endif
+
+ void init_library(const Ref<GDNativeLibrary> &lib);
+ void register_script(NativeScript *script);
+ void unregister_script(NativeScript *script);
+
+public:
+ Map<String, Map<StringName, NativeScriptDesc> > library_classes;
+ Map<String, Ref<GDNative> > library_gdnatives;
+
+ Map<String, Set<NativeScript *> > library_script_users;
+
+ const StringName _init_call_type = "nativescript_init";
+ const StringName _init_call_name = "godot_nativescript_init";
+
+ const StringName _thread_cb_call_type = "godot_nativescript_thread_cb";
+ const StringName _thread_enter_call_name = "godot_nativescript_thread_enter";
+ const StringName _thread_exit_call_name = "godot_nativescript_thread_exit";
+
+ NativeScriptLanguage();
+ ~NativeScriptLanguage();
+
+ inline static NativeScriptLanguage *get_singleton() {
+ return singleton;
+ }
+
+ void _hacky_api_anchor();
+
+#ifndef NO_THREADS
+ virtual void thread_enter();
+ virtual void thread_exit();
+
+ virtual void frame();
+#endif
+
+ virtual String get_name() const;
+ virtual void init();
+ virtual String get_type() const;
+ virtual String get_extension() const;
+ virtual Error execute_file(const String &p_path);
+ virtual void finish();
+ virtual void get_reserved_words(List<String> *p_words) const;
+ virtual void get_comment_delimiters(List<String> *p_delimiters) const;
+ virtual void get_string_delimiters(List<String> *p_delimiters) const;
+ virtual Ref<Script> get_template(const String &p_class_name, const String &p_base_class_name) const;
+ virtual bool validate(const String &p_script, int &r_line_error, int &r_col_error, String &r_test_error, const String &p_path, List<String> *r_functions) const;
+ virtual Script *create_script() const;
+ virtual bool has_named_classes() const;
+ virtual int find_function(const String &p_function, const String &p_code) const;
+ virtual String make_function(const String &p_class, const String &p_name, const PoolStringArray &p_args) const;
+ virtual void auto_indent_code(String &p_code, int p_from_line, int p_to_line) const;
+ virtual void add_global_constant(const StringName &p_variable, const Variant &p_value);
+ virtual String debug_get_error() const;
+ virtual int debug_get_stack_level_count() const;
+ virtual int debug_get_stack_level_line(int p_level) const;
+ virtual String debug_get_stack_level_function(int p_level) const;
+ virtual String debug_get_stack_level_source(int p_level) const;
+ virtual void debug_get_stack_level_locals(int p_level, List<String> *p_locals, List<Variant> *p_values, int p_max_subitems, int p_max_depth);
+ virtual void debug_get_stack_level_members(int p_level, List<String> *p_members, List<Variant> *p_values, int p_max_subitems, int p_max_depth);
+ virtual void debug_get_globals(List<String> *p_locals, List<Variant> *p_values, int p_max_subitems, int p_max_depth);
+ virtual String debug_parse_stack_level_expression(int p_level, const String &p_expression, int p_max_subitems, int p_max_depth);
+ virtual void reload_all_scripts();
+ virtual void reload_tool_script(const Ref<Script> &p_script, bool p_soft_reload);
+ virtual void get_recognized_extensions(List<String> *p_extensions) const;
+ virtual void get_public_functions(List<MethodInfo> *p_functions) const;
+ virtual void get_public_constants(List<Pair<String, Variant> > *p_constants) const;
+ virtual void profiling_start();
+ virtual void profiling_stop();
+ virtual int profiling_get_accumulated_data(ProfilingInfo *p_info_arr, int p_info_max);
+ virtual int profiling_get_frame_data(ProfilingInfo *p_info_arr, int p_info_max);
+};
+
+inline NativeScriptDesc *NativeScript::get_script_desc() const {
+ Map<StringName, NativeScriptDesc>::Element *E = NativeScriptLanguage::singleton->library_classes[lib_path].find(class_name);
+ return E ? &E->get() : NULL;
+}
+
+class NativeReloadNode : public Node {
+ GDCLASS(NativeReloadNode, Node)
+ bool unloaded = false;
+
+public:
+ static void _bind_methods();
+ void _notification(int p_what);
+};
+
+class ResourceFormatLoaderNativeScript : public ResourceFormatLoader {
+public:
+ virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL);
+ virtual void get_recognized_extensions(List<String> *p_extensions) const;
+ virtual bool handles_type(const String &p_type) const;
+ virtual String get_resource_type(const String &p_path) const;
+};
+
+class ResourceFormatSaverNativeScript : public ResourceFormatSaver {
+ virtual Error save(const String &p_path, const RES &p_resource, uint32_t p_flags = 0);
+ virtual bool recognize(const RES &p_resource) const;
+ virtual void get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const;
+};
+
+#endif // GDNATIVE_H
diff --git a/modules/nativescript/register_types.cpp b/modules/nativescript/register_types.cpp
new file mode 100644
index 0000000000..dfa16d8a2a
--- /dev/null
+++ b/modules/nativescript/register_types.cpp
@@ -0,0 +1,124 @@
+/*************************************************************************/
+/* register_types.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+#include "register_types.h"
+
+#include "io/resource_loader.h"
+#include "io/resource_saver.h"
+
+#include "nativescript.h"
+
+#include "core/os/os.h"
+
+NativeScriptLanguage *native_script_language;
+
+typedef void (*native_script_init_fn)(void *);
+
+void init_call_cb(void *p_handle, godot_string *p_proc_name, void *p_data, int p_num_args, void **args, void *r_ret) {
+ if (p_handle == NULL) {
+ ERR_PRINT("No valid library handle, can't call nativescript init procedure");
+ return;
+ }
+
+ void *library_proc;
+ Error err = OS::get_singleton()->get_dynamic_library_symbol_handle(
+ p_handle,
+ *(String *)p_proc_name,
+ library_proc,
+ true); // we print our own message
+ if (err != OK) {
+ ERR_PRINT((String("GDNative procedure \"" + *(String *)p_proc_name) + "\" does not exists and can't be called").utf8().get_data());
+ return;
+ }
+
+ native_script_init_fn fn = (native_script_init_fn)library_proc;
+
+ fn(args[0]);
+}
+
+#ifndef NO_THREADS
+
+typedef void (*native_script_empty_callback)();
+
+void thread_call_cb(void *p_handle, godot_string *p_proc_name, void *p_data, int p_num_args, void **args, void *r_ret) {
+ if (p_handle == NULL) {
+ ERR_PRINT("No valid library handle, can't call nativescript thread enter/exit callback");
+ return;
+ }
+
+ void *library_proc;
+ Error err = OS::get_singleton()->get_dynamic_library_symbol_handle(
+ p_handle,
+ *(String *)p_proc_name,
+ library_proc,
+ true);
+ if (err != OK) {
+ // it's fine if thread callbacks are not present in the library.
+ return;
+ }
+
+ native_script_empty_callback fn = (native_script_empty_callback)library_proc;
+ fn();
+}
+
+#endif // NO_THREADS
+
+ResourceFormatLoaderNativeScript *resource_loader_gdns = NULL;
+ResourceFormatSaverNativeScript *resource_saver_gdns = NULL;
+
+void register_nativescript_types() {
+ native_script_language = memnew(NativeScriptLanguage);
+
+ ClassDB::register_class<NativeScript>();
+
+ ScriptServer::register_language(native_script_language);
+
+ GDNativeCallRegistry::singleton->register_native_raw_call_type(native_script_language->_init_call_type, init_call_cb);
+#ifndef NO_THREADS
+ GDNativeCallRegistry::singleton->register_native_raw_call_type(native_script_language->_thread_cb_call_type, thread_call_cb);
+#endif
+
+ resource_saver_gdns = memnew(ResourceFormatSaverNativeScript);
+ ResourceSaver::add_resource_format_saver(resource_saver_gdns);
+
+ resource_loader_gdns = memnew(ResourceFormatLoaderNativeScript);
+ ResourceLoader::add_resource_format_loader(resource_loader_gdns);
+}
+
+void unregister_nativescript_types() {
+
+ memdelete(resource_loader_gdns);
+
+ memdelete(resource_saver_gdns);
+
+ if (native_script_language) {
+ ScriptServer::unregister_language(native_script_language);
+ memdelete(native_script_language);
+ }
+}
diff --git a/modules/nativescript/register_types.h b/modules/nativescript/register_types.h
new file mode 100644
index 0000000000..319da9c42f
--- /dev/null
+++ b/modules/nativescript/register_types.h
@@ -0,0 +1,31 @@
+/*************************************************************************/
+/* register_types.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+void register_nativescript_types();
+void unregister_nativescript_types();
diff --git a/modules/openssl/stream_peer_openssl.cpp b/modules/openssl/stream_peer_openssl.cpp
index 8159296b3c..7a9d5195a9 100644
--- a/modules/openssl/stream_peer_openssl.cpp
+++ b/modules/openssl/stream_peer_openssl.cpp
@@ -560,7 +560,7 @@ void StreamPeerOpenSSL::initialize_ssl() {
ERR_load_BIO_strings(); // Load BIO error strings
OpenSSL_add_all_algorithms(); // Load all available encryption algorithms
String certs_path = GLOBAL_DEF("network/ssl/certificates", "");
- GlobalConfig::get_singleton()->set_custom_property_info("network/ssl/certificates", PropertyInfo(Variant::STRING, "network/ssl/certificates", PROPERTY_HINT_FILE, "*.crt"));
+ ProjectSettings::get_singleton()->set_custom_property_info("network/ssl/certificates", PropertyInfo(Variant::STRING, "network/ssl/certificates", PROPERTY_HINT_FILE, "*.crt"));
if (certs_path != "") {
FileAccess *f = FileAccess::open(certs_path, FileAccess::READ);
@@ -581,7 +581,7 @@ void StreamPeerOpenSSL::initialize_ssl() {
}
}
String config_path = GLOBAL_DEF("network/ssl/config", "");
- GlobalConfig::get_singleton()->set_custom_property_info("network/ssl/config", PropertyInfo(Variant::STRING, "network/ssl/config", PROPERTY_HINT_FILE, "*.cnf"));
+ ProjectSettings::get_singleton()->set_custom_property_info("network/ssl/config", PropertyInfo(Variant::STRING, "network/ssl/config", PROPERTY_HINT_FILE, "*.cnf"));
if (config_path != "") {
Vector<uint8_t> data = FileAccess::get_file_as_array(config_path);
diff --git a/modules/openssl/stream_peer_openssl.h b/modules/openssl/stream_peer_openssl.h
index 5c830ebf37..b1da5e1d95 100644
--- a/modules/openssl/stream_peer_openssl.h
+++ b/modules/openssl/stream_peer_openssl.h
@@ -30,9 +30,9 @@
#ifndef STREAM_PEER_OPEN_SSL_H
#define STREAM_PEER_OPEN_SSL_H
-#include "global_config.h"
#include "io/stream_peer_ssl.h"
#include "os/file_access.h"
+#include "project_settings.h"
#include "thirdparty/misc/curl_hostcheck.h"
diff --git a/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp b/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp
index c645a55703..7b8b2abebb 100644
--- a/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp
+++ b/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp
@@ -39,7 +39,7 @@ void AudioStreamPlaybackOGGVorbis::_mix_internal(AudioFrame *p_buffer, int p_fra
int todo = p_frames;
- while (todo) {
+ while (todo && active) {
int mixed = stb_vorbis_get_samples_float_interleaved(ogg_stream, 2, (float *)p_buffer, todo * 2);
todo -= mixed;
diff --git a/modules/theora/video_stream_theora.cpp b/modules/theora/video_stream_theora.cpp
index d895f60280..977062dd14 100644
--- a/modules/theora/video_stream_theora.cpp
+++ b/modules/theora/video_stream_theora.cpp
@@ -29,8 +29,8 @@
/*************************************************************************/
#include "video_stream_theora.h"
-#include "global_config.h"
#include "os/os.h"
+#include "project_settings.h"
#include "thirdparty/misc/yuv2rgb.h"
@@ -728,7 +728,7 @@ void VideoStreamPlaybackTheora::play() {
}
playing = true;
- delay_compensation = GlobalConfig::get_singleton()->get("audio/video_delay_compensation_ms");
+ delay_compensation = ProjectSettings::get_singleton()->get("audio/video_delay_compensation_ms");
delay_compensation /= 1000.0;
};
diff --git a/modules/tinyexr/config.py b/modules/tinyexr/config.py
index fb920482f5..2e4b96a6b0 100644
--- a/modules/tinyexr/config.py
+++ b/modules/tinyexr/config.py
@@ -4,4 +4,8 @@ def can_build(platform):
def configure(env):
- pass
+ # Tools only, disabled for non-tools
+ # TODO: Find a cleaner way to achieve that
+ if (env["tools"] == "no"):
+ env["module_tinyexr_enabled"] = "no"
+ env.disabled_modules.append("tinyexr")
diff --git a/modules/visual_script/register_types.cpp b/modules/visual_script/register_types.cpp
index c0467a901b..a54d306aff 100644
--- a/modules/visual_script/register_types.cpp
+++ b/modules/visual_script/register_types.cpp
@@ -90,6 +90,7 @@ void register_visual_script_types() {
ClassDB::register_class<VisualScriptSequence>();
//ClassDB::register_class<VisualScriptInputFilter>();
ClassDB::register_class<VisualScriptSwitch>();
+ ClassDB::register_class<VisualScriptSelect>();
ClassDB::register_class<VisualScriptYield>();
ClassDB::register_class<VisualScriptYieldSignal>();
diff --git a/modules/visual_script/visual_script.cpp b/modules/visual_script/visual_script.cpp
index bb8111ce99..f15abec7e2 100644
--- a/modules/visual_script/visual_script.cpp
+++ b/modules/visual_script/visual_script.cpp
@@ -29,8 +29,8 @@
/*************************************************************************/
#include "visual_script.h"
-#include "global_config.h"
#include "os/os.h"
+#include "project_settings.h"
#include "scene/main/node.h"
#include "visual_script_nodes.h"
@@ -140,7 +140,7 @@ VisualScriptNode::TypeGuess VisualScriptNode::guess_output_type(TypeGuess *p_inp
tg.type = pinfo.type;
if (pinfo.hint == PROPERTY_HINT_RESOURCE_TYPE) {
- tg.GDCLASS = pinfo.hint_string;
+ tg.gdclass = pinfo.hint_string;
}
return tg;
@@ -660,6 +660,9 @@ void VisualScript::set_variable_export(const StringName &p_name, bool p_export)
ERR_FAIL_COND(!variables.has(p_name));
variables[p_name]._export = p_export;
+#ifdef TOOLS_ENABLED
+ _update_placeholders();
+#endif
}
bool VisualScript::get_variable_export(const StringName &p_name) const {
@@ -1067,9 +1070,11 @@ void VisualScript::get_script_property_list(List<PropertyInfo> *p_list) const {
get_variable_list(&vars);
for (List<StringName>::Element *E = vars.front(); E; E = E->next()) {
- if (!variables[E->get()]._export)
- continue;
- p_list->push_back(variables[E->get()].info);
+ //if (!variables[E->get()]._export)
+ // continue;
+ PropertyInfo pi = variables[E->get()].info;
+ pi.usage |= PROPERTY_USAGE_SCRIPT_VARIABLE;
+ p_list->push_back(pi);
}
}
@@ -1259,14 +1264,14 @@ void VisualScript::_bind_methods() {
ClassDB::bind_method(D_METHOD("has_function", "name"), &VisualScript::has_function);
ClassDB::bind_method(D_METHOD("remove_function", "name"), &VisualScript::remove_function);
ClassDB::bind_method(D_METHOD("rename_function", "name", "new_name"), &VisualScript::rename_function);
- ClassDB::bind_method(D_METHOD("set_function_scroll", "ofs"), &VisualScript::set_function_scroll);
- ClassDB::bind_method(D_METHOD("get_function_scroll"), &VisualScript::get_function_scroll);
+ ClassDB::bind_method(D_METHOD("set_function_scroll", "name", "ofs"), &VisualScript::set_function_scroll);
+ ClassDB::bind_method(D_METHOD("get_function_scroll", "name"), &VisualScript::get_function_scroll);
- ClassDB::bind_method(D_METHOD("add_node", "func", "id", "node", "pos"), &VisualScript::add_node, DEFVAL(Point2()));
+ ClassDB::bind_method(D_METHOD("add_node", "func", "id", "node:VisualScriptNode", "pos"), &VisualScript::add_node, DEFVAL(Point2()));
ClassDB::bind_method(D_METHOD("remove_node", "func", "id"), &VisualScript::remove_node);
ClassDB::bind_method(D_METHOD("get_function_node_id", "name"), &VisualScript::get_function_node_id);
- ClassDB::bind_method(D_METHOD("get_node", "func", "id"), &VisualScript::get_node);
+ ClassDB::bind_method(D_METHOD("get_node:VisualScriptNode", "func", "id"), &VisualScript::get_node);
ClassDB::bind_method(D_METHOD("has_node", "func", "id"), &VisualScript::has_node);
ClassDB::bind_method(D_METHOD("set_node_pos", "func", "id", "pos"), &VisualScript::set_node_pos);
ClassDB::bind_method(D_METHOD("get_node_pos", "func", "id"), &VisualScript::get_node_pos);
@@ -1297,7 +1302,7 @@ void VisualScript::_bind_methods() {
ClassDB::bind_method(D_METHOD("custom_signal_get_argument_type", "name", "argidx"), &VisualScript::custom_signal_get_argument_type);
ClassDB::bind_method(D_METHOD("custom_signal_set_argument_name", "name", "argidx", "argname"), &VisualScript::custom_signal_set_argument_name);
ClassDB::bind_method(D_METHOD("custom_signal_get_argument_name", "name", "argidx"), &VisualScript::custom_signal_get_argument_name);
- ClassDB::bind_method(D_METHOD("custom_signal_remove_argument", "argidx"), &VisualScript::custom_signal_remove_argument);
+ ClassDB::bind_method(D_METHOD("custom_signal_remove_argument", "name", "argidx"), &VisualScript::custom_signal_remove_argument);
ClassDB::bind_method(D_METHOD("custom_signal_get_argument_count", "name"), &VisualScript::custom_signal_get_argument_count);
ClassDB::bind_method(D_METHOD("custom_signal_swap_argument", "name", "argidx", "withidx"), &VisualScript::custom_signal_swap_argument);
ClassDB::bind_method(D_METHOD("remove_custom_signal", "name"), &VisualScript::remove_custom_signal);
@@ -1358,6 +1363,7 @@ void VisualScriptInstance::get_property_list(List<PropertyInfo> *p_properties) c
continue;
PropertyInfo p = E->get().info;
p.name = String(E->key());
+ p.usage |= PROPERTY_USAGE_SCRIPT_VARIABLE;
p_properties->push_back(p);
}
}
@@ -2652,7 +2658,7 @@ VisualScriptLanguage::VisualScriptLanguage() {
_debug_parse_err_node = -1;
_debug_parse_err_file = "";
_debug_call_stack_pos = 0;
- int dmcs = GLOBAL_DEF("debug/script/max_call_stack", 1024);
+ int dmcs = GLOBAL_DEF("debug/settings/visual_script/max_call_stack", 1024);
if (ScriptDebugger::get_singleton()) {
//debugging enabled!
_debug_max_call_stack = dmcs;
diff --git a/modules/visual_script/visual_script.h b/modules/visual_script/visual_script.h
index 20a1cf49c5..cdd7eded18 100644
--- a/modules/visual_script/visual_script.h
+++ b/modules/visual_script/visual_script.h
@@ -89,7 +89,7 @@ public:
struct TypeGuess {
Variant::Type type;
- StringName GDCLASS;
+ StringName gdclass;
Ref<Script> script;
TypeGuess() {
diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp
index 941668d474..35358d5a1f 100644
--- a/modules/visual_script/visual_script_editor.cpp
+++ b/modules/visual_script/visual_script_editor.cpp
@@ -52,11 +52,13 @@ public:
protected:
static void _bind_methods() {
ClassDB::bind_method("_sig_changed", &VisualScriptEditorSignalEdit::_sig_changed);
+ ADD_SIGNAL(MethodInfo("changed"));
}
void _sig_changed() {
_change_notify();
+ emit_signal("changed");
}
bool _set(const StringName &p_name, const Variant &p_value) {
@@ -191,15 +193,18 @@ protected:
static void _bind_methods() {
ClassDB::bind_method("_var_changed", &VisualScriptEditorVariableEdit::_var_changed);
ClassDB::bind_method("_var_value_changed", &VisualScriptEditorVariableEdit::_var_value_changed);
+ ADD_SIGNAL(MethodInfo("changed"));
}
void _var_changed() {
_change_notify();
+ emit_signal("changed");
}
void _var_value_changed() {
_change_notify("value"); //so the whole tree is not redrawn, makes editing smoother in general
+ emit_signal("changed");
}
bool _set(const StringName &p_name, const Variant &p_value) {
@@ -261,6 +266,7 @@ protected:
if (String(p_name) == "export") {
script->set_variable_export(var, p_value);
+ EditorNode::get_singleton()->get_property_editor()->update_tree();
return true;
}
@@ -486,7 +492,8 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
}
if (EditorSettings::get_singleton()->has("editors/visual_script/color_" + node->get_category())) {
- gnode->set_modulate(EditorSettings::get_singleton()->get("editors/visual_script/color_" + node->get_category()));
+ Color c = EditorSettings::get_singleton()->get("editors/visual_script/color_" + node->get_category());
+ gnode->set_self_modulate(c);
}
gnode->set_meta("__vnode", node);
@@ -699,7 +706,7 @@ void VisualScriptEditor::_update_members() {
ti->set_selectable(0, true);
ti->set_editable(0, true);
//ti->add_button(0,Control::get_icon("Edit","EditorIcons"),0); function arguments are in the node now
- ti->add_button(0, Control::get_icon("Del", "EditorIcons"), 1);
+ //ti->add_button(0, Control::get_icon("Del", "EditorIcons"), 1);
ti->set_metadata(0, E->get());
if (E->get() == edited_func) {
ti->set_custom_bg_color(0, get_color("prop_category", "Editor"));
@@ -757,8 +764,8 @@ void VisualScriptEditor::_update_members() {
ti->set_selectable(0, true);
ti->set_editable(0, true);
- ti->add_button(0, Control::get_icon("Edit", "EditorIcons"), 0);
- ti->add_button(0, Control::get_icon("Del", "EditorIcons"), 1);
+ //ti->add_button(0, Control::get_icon("Edit", "EditorIcons"), 0);
+ //ti->add_button(0, Control::get_icon("Del", "EditorIcons"), 1);
ti->set_metadata(0, E->get());
if (selected == E->get())
ti->select(0);
@@ -777,8 +784,8 @@ void VisualScriptEditor::_update_members() {
ti->set_text(0, E->get());
ti->set_selectable(0, true);
ti->set_editable(0, true);
- ti->add_button(0, Control::get_icon("Edit", "EditorIcons"), 0);
- ti->add_button(0, Control::get_icon("Del", "EditorIcons"), 1);
+ //ti->add_button(0, Control::get_icon("Edit", "EditorIcons"), 0);
+ //ti->add_button(0, Control::get_icon("Del", "EditorIcons"), 1);
ti->set_metadata(0, E->get());
if (selected == E->get())
ti->select(0);
@@ -1068,105 +1075,6 @@ void VisualScriptEditor::_member_button(Object *p_item, int p_column, int p_butt
undo_redo->commit_action();
return; //or crash because it will become invalid
}
-
- } else {
-
- if (ti->get_parent() == root->get_children()) {
- //edit/remove function
- String name = ti->get_metadata(0);
-
- if (p_button == 1) {
- //delete the function
- undo_redo->create_action(TTR("Remove Function"));
- undo_redo->add_do_method(script.ptr(), "remove_function", name);
- undo_redo->add_undo_method(script.ptr(), "add_function", name);
- List<int> nodes;
- script->get_node_list(name, &nodes);
- for (List<int>::Element *E = nodes.front(); E; E = E->next()) {
- undo_redo->add_undo_method(script.ptr(), "add_node", name, E->get(), script->get_node(name, E->get()), script->get_node_pos(name, E->get()));
- }
-
- List<VisualScript::SequenceConnection> seq_connections;
-
- script->get_sequence_connection_list(name, &seq_connections);
-
- for (List<VisualScript::SequenceConnection>::Element *E = seq_connections.front(); E; E = E->next()) {
- undo_redo->add_undo_method(script.ptr(), "sequence_connect", name, E->get().from_node, E->get().from_output, E->get().to_node);
- }
-
- List<VisualScript::DataConnection> data_connections;
-
- script->get_data_connection_list(name, &data_connections);
-
- for (List<VisualScript::DataConnection>::Element *E = data_connections.front(); E; E = E->next()) {
- undo_redo->add_undo_method(script.ptr(), "data_connect", name, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port);
- }
-
- /*
- for(int i=0;i<script->function_get_argument_count(name);i++) {
- undo_redo->add_undo_method(script.ptr(),"function_add_argument",name,script->function_get_argument_name(name,i),script->function_get_argument_type(name,i));
- }
- */
- undo_redo->add_do_method(this, "_update_members");
- undo_redo->add_undo_method(this, "_update_members");
- undo_redo->add_do_method(this, "_update_graph");
- undo_redo->add_undo_method(this, "_update_graph");
- undo_redo->commit_action();
-
- } else if (p_button == 0) {
- }
- return; //or crash because it will become invalid
- }
-
- if (ti->get_parent() == root->get_children()->get_next()) {
- //edit/remove variable
-
- String name = ti->get_metadata(0);
-
- if (p_button == 1) {
-
- undo_redo->create_action(TTR("Remove Variable"));
- undo_redo->add_do_method(script.ptr(), "remove_variable", name);
- undo_redo->add_undo_method(script.ptr(), "add_variable", name, script->get_variable_default_value(name));
- undo_redo->add_undo_method(script.ptr(), "set_variable_info", name, script->call("get_variable_info", name)); //return as dict
- undo_redo->add_do_method(this, "_update_members");
- undo_redo->add_undo_method(this, "_update_members");
- undo_redo->commit_action();
- return; //or crash because it will become invalid
- } else if (p_button == 0) {
-
- variable_editor->edit(name);
- edit_variable_dialog->set_title(TTR("Editing Variable:") + " " + name);
- edit_variable_dialog->popup_centered_minsize(Size2(400, 200) * EDSCALE);
- }
- }
-
- if (ti->get_parent() == root->get_children()->get_next()->get_next()) {
- //edit/remove variable
- String name = ti->get_metadata(0);
-
- if (p_button == 1) {
-
- undo_redo->create_action(TTR("Remove Signal"));
- undo_redo->add_do_method(script.ptr(), "remove_custom_signal", name);
- undo_redo->add_undo_method(script.ptr(), "add_custom_signal", name);
-
- for (int i = 0; i < script->custom_signal_get_argument_count(name); i++) {
- undo_redo->add_undo_method(script.ptr(), "custom_signal_add_argument", name, script->custom_signal_get_argument_name(name, i), script->custom_signal_get_argument_type(name, i));
- }
-
- undo_redo->add_do_method(this, "_update_members");
- undo_redo->add_undo_method(this, "_update_members");
- undo_redo->commit_action();
- } else if (p_button == 0) {
-
- signal_editor->edit(name);
- edit_signal_dialog->set_title(TTR("Editing Signal:") + " " + name);
- edit_signal_dialog->popup_centered_minsize(Size2(400, 300) * EDSCALE);
- }
-
- return; //or crash because it will become invalid
- }
}
}
@@ -2269,6 +2177,11 @@ void VisualScriptEditor::_change_base_type() {
select_base_type->popup_create(true);
}
+void VisualScriptEditor::clear_edit_menu() {
+ memdelete(edit_menu);
+ memdelete(left_vsplit);
+}
+
void VisualScriptEditor::_change_base_type_callback() {
String bt = select_base_type->get_selected_type();
@@ -2415,6 +2328,16 @@ void VisualScriptEditor::_graph_connected(const String &p_from, int p_from_slot,
undo_redo->add_do_method(script.ptr(), "sequence_connect", edited_func, p_from.to_int(), from_port, p_to.to_int());
undo_redo->add_undo_method(script.ptr(), "sequence_disconnect", edited_func, p_from.to_int(), from_port, p_to.to_int());
} else {
+
+ // disconect current, and connect the new one
+ if (script->is_input_value_port_connected(edited_func, p_to.to_int(), to_port)) {
+ int conn_from;
+ int conn_port;
+ script->get_input_value_port_connection_source(edited_func, p_to.to_int(), to_port, &conn_from, &conn_port);
+ undo_redo->add_do_method(script.ptr(), "data_disconnect", edited_func, conn_from, conn_port, p_to.to_int(), to_port);
+ undo_redo->add_undo_method(script.ptr(), "data_connect", edited_func, conn_from, conn_port, p_to.to_int(), to_port);
+ }
+
undo_redo->add_do_method(script.ptr(), "data_connect", edited_func, p_from.to_int(), from_port, p_to.to_int(), to_port);
undo_redo->add_undo_method(script.ptr(), "data_disconnect", edited_func, p_from.to_int(), from_port, p_to.to_int(), to_port);
//update nodes in sgraph
@@ -2556,7 +2479,7 @@ VisualScriptNode::TypeGuess VisualScriptEditor::_guess_output_type(int p_node, i
if (obj) {
g.type = Variant::OBJECT;
- g.GDCLASS = obj->get_class();
+ g.gdclass = obj->get_class();
g.script = obj->get_script();
}
}
@@ -2596,8 +2519,8 @@ void VisualScriptEditor::_port_action_menu(int p_option) {
if (tg.type == Variant::OBJECT) {
n->set_call_mode(VisualScriptFunctionCall::CALL_MODE_INSTANCE);
- if (tg.GDCLASS != StringName()) {
- n->set_base_type(tg.GDCLASS);
+ if (tg.gdclass != StringName()) {
+ n->set_base_type(tg.gdclass);
} else {
n->set_base_type("Object");
}
@@ -2627,8 +2550,8 @@ void VisualScriptEditor::_port_action_menu(int p_option) {
if (tg.type == Variant::OBJECT) {
n->set_call_mode(VisualScriptPropertySet::CALL_MODE_INSTANCE);
- if (tg.GDCLASS != StringName()) {
- n->set_base_type(tg.GDCLASS);
+ if (tg.gdclass != StringName()) {
+ n->set_base_type(tg.gdclass);
} else {
n->set_base_type("Object");
}
@@ -2657,8 +2580,8 @@ void VisualScriptEditor::_port_action_menu(int p_option) {
if (tg.type == Variant::OBJECT) {
n->set_call_mode(VisualScriptPropertyGet::CALL_MODE_INSTANCE);
- if (tg.GDCLASS != StringName()) {
- n->set_base_type(tg.GDCLASS);
+ if (tg.gdclass != StringName()) {
+ n->set_base_type(tg.gdclass);
} else {
n->set_base_type("Object");
}
@@ -2833,13 +2756,18 @@ void VisualScriptEditor::_node_filter_changed(const String &p_text) {
void VisualScriptEditor::_notification(int p_what) {
if (p_what == NOTIFICATION_READY) {
- node_filter_icon->set_texture(Control::get_icon("Zoom", "EditorIcons"));
+ node_filter->add_icon_override("right_icon", Control::get_icon("Search", "EditorIcons"));
+ variable_editor->connect("changed", this, "_update_members");
+ signal_editor->connect("changed", this, "_update_members");
+ }
+ if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
+ left_vsplit->set_visible(is_visible_in_tree());
}
}
void VisualScriptEditor::_graph_ofs_changed(const Vector2 &p_ofs) {
- if (updating_graph)
+ if (updating_graph || !script.is_valid())
return;
updating_graph = true;
@@ -3053,6 +2981,142 @@ void VisualScriptEditor::_menu_option(int p_what) {
}
}
+void VisualScriptEditor::_member_rmb_selected(const Vector2 &p_pos) {
+
+ TreeItem *ti = members->get_selected();
+ ERR_FAIL_COND(!ti);
+
+ member_popup->clear();
+ member_popup->set_position(members->get_global_position() + p_pos);
+ member_popup->set_size(Vector2());
+
+ TreeItem *root = members->get_root();
+
+ Ref<Texture> del_icon = Control::get_icon("Del", "EditorIcons");
+
+ Ref<Texture> edit_icon = Control::get_icon("Edit", "EditorIcons");
+
+ if (ti->get_parent() == root->get_children()) {
+
+ member_type = MEMBER_FUNCTION;
+ member_name = ti->get_text(0);
+ member_popup->add_icon_item(del_icon, TTR("Remove Function"), MEMBER_REMOVE);
+ member_popup->popup();
+ return;
+ }
+
+ if (ti->get_parent() == root->get_children()->get_next()) {
+
+ member_type = MEMBER_VARIABLE;
+ member_name = ti->get_text(0);
+ member_popup->add_icon_item(edit_icon, TTR("Edit Variable"), MEMBER_EDIT);
+ member_popup->add_separator();
+ member_popup->add_icon_item(del_icon, TTR("Remove Variable"), MEMBER_REMOVE);
+ member_popup->popup();
+ return;
+ }
+
+ if (ti->get_parent() == root->get_children()->get_next()->get_next()) {
+
+ member_type = MEMBER_SIGNAL;
+ member_name = ti->get_text(0);
+ member_popup->add_icon_item(edit_icon, TTR("Edit Signal"), MEMBER_EDIT);
+ member_popup->add_separator();
+ member_popup->add_icon_item(del_icon, TTR("Remove Signal"), MEMBER_REMOVE);
+ member_popup->popup();
+ return;
+ }
+}
+
+void VisualScriptEditor::_member_option(int p_option) {
+
+ switch (member_type) {
+ case MEMBER_FUNCTION: {
+
+ if (p_option == MEMBER_REMOVE) {
+ //delete the function
+ String name = member_name;
+
+ undo_redo->create_action(TTR("Remove Function"));
+ undo_redo->add_do_method(script.ptr(), "remove_function", name);
+ undo_redo->add_undo_method(script.ptr(), "add_function", name);
+ List<int> nodes;
+ script->get_node_list(name, &nodes);
+ for (List<int>::Element *E = nodes.front(); E; E = E->next()) {
+ undo_redo->add_undo_method(script.ptr(), "add_node", name, E->get(), script->get_node(name, E->get()), script->get_node_pos(name, E->get()));
+ }
+
+ List<VisualScript::SequenceConnection> seq_connections;
+
+ script->get_sequence_connection_list(name, &seq_connections);
+
+ for (List<VisualScript::SequenceConnection>::Element *E = seq_connections.front(); E; E = E->next()) {
+ undo_redo->add_undo_method(script.ptr(), "sequence_connect", name, E->get().from_node, E->get().from_output, E->get().to_node);
+ }
+
+ List<VisualScript::DataConnection> data_connections;
+
+ script->get_data_connection_list(name, &data_connections);
+
+ for (List<VisualScript::DataConnection>::Element *E = data_connections.front(); E; E = E->next()) {
+ undo_redo->add_undo_method(script.ptr(), "data_connect", name, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port);
+ }
+
+ /*
+ for(int i=0;i<script->function_get_argument_count(name);i++) {
+ undo_redo->add_undo_method(script.ptr(),"function_add_argument",name,script->function_get_argument_name(name,i),script->function_get_argument_type(name,i));
+ }
+ */
+ undo_redo->add_do_method(this, "_update_members");
+ undo_redo->add_undo_method(this, "_update_members");
+ undo_redo->add_do_method(this, "_update_graph");
+ undo_redo->add_undo_method(this, "_update_graph");
+ undo_redo->commit_action();
+ }
+ } break;
+ case MEMBER_VARIABLE: {
+
+ String name = member_name;
+
+ if (p_option == MEMBER_REMOVE) {
+ undo_redo->create_action(TTR("Remove Variable"));
+ undo_redo->add_do_method(script.ptr(), "remove_variable", name);
+ undo_redo->add_undo_method(script.ptr(), "add_variable", name, script->get_variable_default_value(name));
+ undo_redo->add_undo_method(script.ptr(), "set_variable_info", name, script->call("get_variable_info", name)); //return as dict
+ undo_redo->add_do_method(this, "_update_members");
+ undo_redo->add_undo_method(this, "_update_members");
+ undo_redo->commit_action();
+ } else if (p_option == MEMBER_EDIT) {
+ variable_editor->edit(name);
+ edit_variable_dialog->set_title(TTR("Editing Variable:") + " " + name);
+ edit_variable_dialog->popup_centered_minsize(Size2(400, 200) * EDSCALE);
+ }
+ } break;
+ case MEMBER_SIGNAL: {
+ String name = member_name;
+
+ if (p_option == MEMBER_REMOVE) {
+ undo_redo->create_action(TTR("Remove Signal"));
+ undo_redo->add_do_method(script.ptr(), "remove_custom_signal", name);
+ undo_redo->add_undo_method(script.ptr(), "add_custom_signal", name);
+
+ for (int i = 0; i < script->custom_signal_get_argument_count(name); i++) {
+ undo_redo->add_undo_method(script.ptr(), "custom_signal_add_argument", name, script->custom_signal_get_argument_name(name, i), script->custom_signal_get_argument_type(name, i));
+ }
+
+ undo_redo->add_do_method(this, "_update_members");
+ undo_redo->add_undo_method(this, "_update_members");
+ undo_redo->commit_action();
+ } else if (p_option == MEMBER_EDIT) {
+
+ signal_editor->edit(name);
+ edit_signal_dialog->set_title(TTR("Editing Signal:") + " " + name);
+ edit_signal_dialog->popup_centered_minsize(Size2(400, 300) * EDSCALE);
+ }
+ } break;
+ }
+}
+
void VisualScriptEditor::_bind_methods() {
ClassDB::bind_method("_member_button", &VisualScriptEditor::_member_button);
@@ -3101,6 +3165,10 @@ void VisualScriptEditor::_bind_methods() {
ClassDB::bind_method("_selected_method", &VisualScriptEditor::_selected_method);
ClassDB::bind_method("_draw_color_over_button", &VisualScriptEditor::_draw_color_over_button);
+
+ ClassDB::bind_method("_member_rmb_selected", &VisualScriptEditor::_member_rmb_selected);
+
+ ClassDB::bind_method("_member_option", &VisualScriptEditor::_member_option);
}
VisualScriptEditor::VisualScriptEditor() {
@@ -3122,17 +3190,16 @@ VisualScriptEditor::VisualScriptEditor() {
edit_menu->get_popup()->connect("id_pressed", this, "_menu_option");
- main_hsplit = memnew(HSplitContainer);
- add_child(main_hsplit);
- main_hsplit->set_area_as_parent_rect();
-
left_vsplit = memnew(VSplitContainer);
- main_hsplit->add_child(left_vsplit);
+ ScriptEditor::get_singleton()->get_left_list_split()->call_deferred("add_child", left_vsplit); //add but wait until done settig up this
+ left_vsplit->set_v_size_flags(SIZE_EXPAND_FILL);
+ left_vsplit->set_stretch_ratio(2);
+ left_vsplit->hide();
VBoxContainer *left_vb = memnew(VBoxContainer);
left_vsplit->add_child(left_vb);
left_vb->set_v_size_flags(SIZE_EXPAND_FILL);
- left_vb->set_custom_minimum_size(Size2(230, 1) * EDSCALE);
+ //left_vb->set_custom_minimum_size(Size2(230, 1) * EDSCALE);
base_type_select = memnew(Button);
left_vb->add_margin_child(TTR("Base Type:"), base_type_select);
@@ -3158,9 +3225,6 @@ VisualScriptEditor::VisualScriptEditor() {
node_filter->connect("text_changed", this, "_node_filter_changed");
hbc_nodes->add_child(node_filter);
node_filter->set_h_size_flags(SIZE_EXPAND_FILL);
- node_filter_icon = memnew(TextureRect);
- node_filter_icon->set_stretch_mode(TextureRect::STRETCH_KEEP_CENTERED);
- hbc_nodes->add_child(node_filter_icon);
vbc_nodes->add_child(hbc_nodes);
nodes = memnew(Tree);
@@ -3174,7 +3238,8 @@ VisualScriptEditor::VisualScriptEditor() {
nodes->set_drag_forwarding(this);
graph = memnew(GraphEdit);
- main_hsplit->add_child(graph);
+ add_child(graph);
+ graph->set_area_as_parent_rect();
graph->set_h_size_flags(SIZE_EXPAND_FILL);
graph->connect("node_selected", this, "_node_selected");
graph->connect("_begin_node_move", this, "_begin_node_move");
@@ -3190,7 +3255,8 @@ VisualScriptEditor::VisualScriptEditor() {
select_func_text->set_align(Label::ALIGN_CENTER);
select_func_text->set_valign(Label::VALIGN_CENTER);
select_func_text->set_h_size_flags(SIZE_EXPAND_FILL);
- main_hsplit->add_child(select_func_text);
+ add_child(select_func_text);
+ graph->set_area_as_parent_rect();
hint_text = memnew(Label);
hint_text->set_anchor_and_margin(MARGIN_TOP, ANCHOR_END, 100);
@@ -3280,6 +3346,12 @@ VisualScriptEditor::VisualScriptEditor() {
port_action_popup = memnew(PopupMenu);
add_child(port_action_popup);
port_action_popup->connect("id_pressed", this, "_port_action_menu");
+
+ member_popup = memnew(PopupMenu);
+ add_child(member_popup);
+ members->connect("item_rmb_selected", this, "_member_rmb_selected");
+ members->set_allow_rmb_select(true);
+ member_popup->connect("id_pressed", this, "_member_option");
}
VisualScriptEditor::~VisualScriptEditor() {
@@ -3311,7 +3383,7 @@ static void register_editor_callback() {
EditorSettings::get_singleton()->set("editors/visual_script/color_functions", Color(1, 0.9, 0.9));
EditorSettings::get_singleton()->set("editors/visual_script/color_data", Color(0.9, 1.0, 0.9));
EditorSettings::get_singleton()->set("editors/visual_script/color_operators", Color(0.9, 0.9, 1.0));
- EditorSettings::get_singleton()->set("editors/visual_script/color_flow_control", Color(1.0, 1.0, 0.8));
+ EditorSettings::get_singleton()->set("editors/visual_script/color_flow_control", Color(1.0, 1.0, 1.0));
EditorSettings::get_singleton()->set("editors/visual_script/color_custom", Color(0.8, 1.0, 1.0));
EditorSettings::get_singleton()->set("editors/visual_script/color_constants", Color(1.0, 0.8, 1.0));
diff --git a/modules/visual_script/visual_script_editor.h b/modules/visual_script/visual_script_editor.h
index 92f31f20da..fee4e27bd5 100644
--- a/modules/visual_script/visual_script_editor.h
+++ b/modules/visual_script/visual_script_editor.h
@@ -72,15 +72,25 @@ class VisualScriptEditor : public ScriptEditorBase {
CREATE_RETURN,
};
+ enum MemberAction {
+ MEMBER_EDIT,
+ MEMBER_REMOVE
+
+ };
+
+ enum MemberType {
+ MEMBER_FUNCTION,
+ MEMBER_VARIABLE,
+ MEMBER_SIGNAL
+ };
+
+ VSplitContainer *left_vsplit;
MenuButton *edit_menu;
Ref<VisualScript> script;
Button *base_type_select;
- HSplitContainer *main_hsplit;
- VSplitContainer *left_vsplit;
-
GraphEdit *graph;
LineEdit *node_filter;
@@ -154,6 +164,10 @@ class VisualScriptEditor : public ScriptEditorBase {
static Clipboard *clipboard;
PopupMenu *port_action_popup;
+ PopupMenu *member_popup;
+
+ MemberType member_type;
+ String member_name;
PortAction port_action;
int port_action_node;
@@ -223,6 +237,9 @@ class VisualScriptEditor : public ScriptEditorBase {
VisualScriptNode::TypeGuess _guess_output_type(int p_port_action_node, int p_port_action_output, Set<int> &visited_nodes);
+ void _member_rmb_selected(const Vector2 &p_pos);
+ void _member_option(int p_option);
+
protected:
void _notification(int p_what);
static void _bind_methods();
@@ -252,6 +269,7 @@ public:
virtual void set_debugger_active(bool p_active);
virtual void set_tooltip_request_func(String p_method, Object *p_obj);
virtual Control *get_edit_menu();
+ virtual void clear_edit_menu();
virtual bool can_lose_focus_on_node_selection() { return false; }
static void register_editor();
diff --git a/modules/visual_script/visual_script_expression.cpp b/modules/visual_script/visual_script_expression.cpp
index 791b5d99ff..78b70934c0 100644
--- a/modules/visual_script/visual_script_expression.cpp
+++ b/modules/visual_script/visual_script_expression.cpp
@@ -68,12 +68,12 @@ bool VisualScriptExpression::_set(const StringName &p_name, const Variant &p_val
return true;
}
- if (String(p_name).begins_with("input/")) {
+ if (String(p_name).begins_with("input_")) {
- int idx = String(p_name).get_slice("/", 1).to_int();
+ int idx = String(p_name).get_slicec('_', 1).get_slicec('/', 0).to_int();
ERR_FAIL_INDEX_V(idx, inputs.size(), false);
- String what = String(p_name).get_slice("/", 2);
+ String what = String(p_name).get_slice("/", 1);
if (what == "type") {
@@ -115,12 +115,12 @@ bool VisualScriptExpression::_get(const StringName &p_name, Variant &r_ret) cons
return true;
}
- if (String(p_name).begins_with("input/")) {
+ if (String(p_name).begins_with("input_")) {
- int idx = String(p_name).get_slice("/", 1).to_int();
+ int idx = String(p_name).get_slicec('_', 1).get_slicec('/', 0).to_int();
ERR_FAIL_INDEX_V(idx, inputs.size(), false);
- String what = String(p_name).get_slice("/", 2);
+ String what = String(p_name).get_slice("/", 1);
if (what == "type") {
@@ -151,8 +151,8 @@ void VisualScriptExpression::_get_property_list(List<PropertyInfo> *p_list) cons
for (int i = 0; i < inputs.size(); i++) {
- p_list->push_back(PropertyInfo(Variant::INT, "input/" + itos(i) + "/type", PROPERTY_HINT_ENUM, argt));
- p_list->push_back(PropertyInfo(Variant::STRING, "input/" + itos(i) + "/name"));
+ p_list->push_back(PropertyInfo(Variant::INT, "input_" + itos(i) + "/type", PROPERTY_HINT_ENUM, argt));
+ p_list->push_back(PropertyInfo(Variant::STRING, "input_" + itos(i) + "/name"));
}
}
diff --git a/modules/visual_script/visual_script_flow_control.cpp b/modules/visual_script/visual_script_flow_control.cpp
index 07d69db207..77f3111d94 100644
--- a/modules/visual_script/visual_script_flow_control.cpp
+++ b/modules/visual_script/visual_script_flow_control.cpp
@@ -29,8 +29,9 @@
/*************************************************************************/
#include "visual_script_flow_control.h"
-#include "global_config.h"
+#include "io/resource_loader.h"
#include "os/keyboard.h"
+#include "project_settings.h"
//////////////////////////////////////////
////////////////RETURN////////////////////
@@ -119,8 +120,8 @@ void VisualScriptReturn::_bind_methods() {
argt += "," + Variant::get_type_name(Variant::Type(i));
}
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "return_value/enabled"), "set_enable_return_value", "is_return_value_enabled");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "return_value/type", PROPERTY_HINT_ENUM, argt), "set_return_type", "get_return_type");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "return_enabled"), "set_enable_return_value", "is_return_value_enabled");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "return_type", PROPERTY_HINT_ENUM, argt), "set_return_type", "get_return_type");
}
class VisualScriptNodeInstanceReturn : public VisualScriptNodeInstance {
@@ -137,11 +138,11 @@ public:
if (with_value) {
*p_working_mem = *p_inputs[0];
+ return STEP_EXIT_FUNCTION_BIT;
} else {
*p_working_mem = Variant();
+ return 0;
}
-
- return 0;
}
};
@@ -874,7 +875,7 @@ String VisualScriptInputFilter::get_output_sequence_port_text(int p_port) const
case Ref<InputEvent>::ACTION: {
List<PropertyInfo> pinfo;
- GlobalConfig::get_singleton()->get_property_list(&pinfo);
+ ProjectSettings::get_singleton()->get_property_list(&pinfo);
int index = 1;
text = "No Action";
@@ -943,7 +944,7 @@ bool VisualScriptInputFilter::_set(const StringName &p_name, const Variant &p_va
filters[idx] = Ref<InputEvent>();
filters[idx].type = Ref<InputEvent>::Type(int(p_value));
if (filters[idx].type == Ref<InputEvent>::JOYPAD_MOTION) {
- filters[idx].joy_motion.axis_value = 0.5; //for treshold
+ filters[idx].joy_motion.axis_value = 0.5; //for threshold
} else if (filters[idx].type == Ref<InputEvent>::KEY) {
filters[idx]->is_pressed() = true; //put these as true to make it more user friendly
} else if (filters[idx].type == Ref<InputEvent>::MOUSE_BUTTON) {
@@ -1070,7 +1071,7 @@ bool VisualScriptInputFilter::_set(const StringName &p_name, const Variant &p_va
filters[idx].joy_motion.axis = int(p_value) << 1 | filters[idx].joy_motion.axis;
} else if (what == "mode") {
filters[idx].joy_motion.axis |= int(p_value);
- } else if (what == "treshold") {
+ } else if (what == "threshold") {
filters[idx].joy_motion.axis_value = p_value;
} else {
return false;
@@ -1118,7 +1119,7 @@ bool VisualScriptInputFilter::_set(const StringName &p_name, const Variant &p_va
if (what == "action_name") {
List<PropertyInfo> pinfo;
- GlobalConfig::get_singleton()->get_property_list(&pinfo);
+ ProjectSettings::get_singleton()->get_property_list(&pinfo);
int index = 1;
for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
@@ -1280,7 +1281,7 @@ bool VisualScriptInputFilter::_get(const StringName &p_name, Variant &r_ret) con
r_ret = filters[idx].joy_motion.axis >> 1;
} else if (what == "mode") {
r_ret = filters[idx].joy_motion.axis & 1;
- } else if (what == "treshold") {
+ } else if (what == "threshold") {
r_ret = filters[idx].joy_motion.axis_value;
} else {
return false;
@@ -1324,7 +1325,7 @@ bool VisualScriptInputFilter::_get(const StringName &p_name, Variant &r_ret) con
if (what == "action_name") {
List<PropertyInfo> pinfo;
- GlobalConfig::get_singleton()->get_property_list(&pinfo);
+ ProjectSettings::get_singleton()->get_property_list(&pinfo);
int index = 1;
for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
@@ -1433,7 +1434,7 @@ void VisualScriptInputFilter::_get_property_list(List<PropertyInfo> *p_list) con
p_list->push_back(PropertyInfo(Variant::INT, base + "axis_index"));
p_list->push_back(PropertyInfo(Variant::INT, base + "mode", PROPERTY_HINT_ENUM, "Min,Max"));
- p_list->push_back(PropertyInfo(Variant::REAL, base + "treshold", PROPERTY_HINT_RANGE, "0,1,0.01"));
+ p_list->push_back(PropertyInfo(Variant::REAL, base + "threshold", PROPERTY_HINT_RANGE, "0,1,0.01"));
} break;
case Ref<InputEvent>::JOYPAD_BUTTON: {
p_list->push_back(PropertyInfo(Variant::INT, base + "button_index"));
@@ -1455,7 +1456,7 @@ void VisualScriptInputFilter::_get_property_list(List<PropertyInfo> *p_list) con
actions = "None";
List<PropertyInfo> pinfo;
- GlobalConfig::get_singleton()->get_property_list(&pinfo);
+ ProjectSettings::get_singleton()->get_property_list(&pinfo);
Vector<String> al;
for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
@@ -1725,6 +1726,20 @@ String VisualScriptTypeCast::get_base_script() const {
return script;
}
+VisualScriptTypeCast::TypeGuess VisualScriptTypeCast::guess_output_type(TypeGuess *p_inputs, int p_output) const {
+
+ TypeGuess tg;
+ tg.type = Variant::OBJECT;
+ if (script != String()) {
+ tg.script = ResourceLoader::load(script);
+ }
+ //if (!tg.script.is_valid()) {
+ // tg.gdclass = base_type;
+ //}
+
+ return tg;
+}
+
class VisualScriptNodeInstanceTypeCast : public VisualScriptNodeInstance {
public:
VisualScriptInstance *instance;
@@ -1815,8 +1830,8 @@ void VisualScriptTypeCast::_bind_methods() {
script_ext_hint += "*." + E->get();
}
- ADD_PROPERTY(PropertyInfo(Variant::STRING, "function/base_type", PROPERTY_HINT_TYPE_STRING, "Object"), "set_base_type", "get_base_type");
- ADD_PROPERTY(PropertyInfo(Variant::STRING, "property/base_script", PROPERTY_HINT_FILE, script_ext_hint), "set_base_script", "get_base_script");
+ ADD_PROPERTY(PropertyInfo(Variant::STRING, "base_type", PROPERTY_HINT_TYPE_STRING, "Object"), "set_base_type", "get_base_type");
+ ADD_PROPERTY(PropertyInfo(Variant::STRING, "base_script", PROPERTY_HINT_FILE, script_ext_hint), "set_base_script", "get_base_script");
}
VisualScriptTypeCast::VisualScriptTypeCast() {
diff --git a/modules/visual_script/visual_script_flow_control.h b/modules/visual_script/visual_script_flow_control.h
index 314804602e..d27fd47f84 100644
--- a/modules/visual_script/visual_script_flow_control.h
+++ b/modules/visual_script/visual_script_flow_control.h
@@ -261,6 +261,7 @@ public:
VisualScriptInputFilter();
};
#endif
+
class VisualScriptTypeCast : public VisualScriptNode {
GDCLASS(VisualScriptTypeCast, VisualScriptNode)
@@ -293,6 +294,8 @@ public:
void set_base_script(const String &p_path);
String get_base_script() const;
+ virtual TypeGuess guess_output_type(TypeGuess *p_inputs, int p_output) const;
+
virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
VisualScriptTypeCast();
diff --git a/modules/visual_script/visual_script_func_nodes.cpp b/modules/visual_script/visual_script_func_nodes.cpp
index e0e1a217b3..c438edd21f 100644
--- a/modules/visual_script/visual_script_func_nodes.cpp
+++ b/modules/visual_script/visual_script_func_nodes.cpp
@@ -29,9 +29,9 @@
/*************************************************************************/
#include "visual_script_func_nodes.h"
-#include "global_config.h"
#include "io/resource_loader.h"
#include "os/os.h"
+#include "project_settings.h"
#include "scene/main/node.h"
#include "scene/main/scene_tree.h"
#include "visual_script_nodes.h"
@@ -347,7 +347,7 @@ void VisualScriptFunctionCall::set_singleton(const StringName &p_path) {
return;
singleton = p_path;
- Object *obj = GlobalConfig::get_singleton()->get_singleton_object(singleton);
+ Object *obj = ProjectSettings::get_singleton()->get_singleton_object(singleton);
if (obj) {
base_type = obj->get_class();
}
@@ -383,7 +383,7 @@ void VisualScriptFunctionCall::_update_method_cache() {
} else if (call_mode == CALL_MODE_SINGLETON) {
- Object *obj = GlobalConfig::get_singleton()->get_singleton_object(singleton);
+ Object *obj = ProjectSettings::get_singleton()->get_singleton_object(singleton);
if (obj) {
type = obj->get_class();
script = obj->get_script();
@@ -546,33 +546,33 @@ Dictionary VisualScriptFunctionCall::_get_argument_cache() const {
void VisualScriptFunctionCall::_validate_property(PropertyInfo &property) const {
- if (property.name == "function/base_type") {
+ if (property.name == "base_type") {
if (call_mode != CALL_MODE_INSTANCE) {
property.usage = PROPERTY_USAGE_NOEDITOR;
}
}
- if (property.name == "function/base_script") {
+ if (property.name == "base_script") {
if (call_mode != CALL_MODE_INSTANCE) {
property.usage = 0;
}
}
- if (property.name == "function/basic_type") {
+ if (property.name == "basic_type") {
if (call_mode != CALL_MODE_BASIC_TYPE) {
property.usage = 0;
}
}
- if (property.name == "function/singleton") {
+ if (property.name == "singleton") {
if (call_mode != CALL_MODE_SINGLETON) {
property.usage = 0;
} else {
- List<GlobalConfig::Singleton> names;
- GlobalConfig::get_singleton()->get_singletons(&names);
+ List<ProjectSettings::Singleton> names;
+ ProjectSettings::get_singleton()->get_singletons(&names);
property.hint = PROPERTY_HINT_ENUM;
String sl;
- for (List<GlobalConfig::Singleton>::Element *E = names.front(); E; E = E->next()) {
+ for (List<ProjectSettings::Singleton>::Element *E = names.front(); E; E = E->next()) {
if (sl != String())
sl += ",";
sl += E->get().name;
@@ -581,7 +581,7 @@ void VisualScriptFunctionCall::_validate_property(PropertyInfo &property) const
}
}
- if (property.name == "function/node_path") {
+ if (property.name == "node_path") {
if (call_mode != CALL_MODE_NODE_PATH) {
property.usage = 0;
} else {
@@ -594,7 +594,7 @@ void VisualScriptFunctionCall::_validate_property(PropertyInfo &property) const
}
}
- if (property.name == "function/function") {
+ if (property.name == "function") {
if (call_mode == CALL_MODE_BASIC_TYPE) {
@@ -606,7 +606,7 @@ void VisualScriptFunctionCall::_validate_property(PropertyInfo &property) const
property.hint_string = itos(get_visual_script()->get_instance_ID());
} else if (call_mode == CALL_MODE_SINGLETON) {
- Object *obj = GlobalConfig::get_singleton()->get_singleton_object(singleton);
+ Object *obj = ProjectSettings::get_singleton()->get_singleton_object(singleton);
if (obj) {
property.hint = PROPERTY_HINT_METHOD_OF_INSTANCE;
property.hint_string = itos(obj->get_instance_ID());
@@ -648,7 +648,7 @@ void VisualScriptFunctionCall::_validate_property(PropertyInfo &property) const
}
}
- if (property.name == "function/use_default_args") {
+ if (property.name == "use_default_args") {
property.hint = PROPERTY_HINT_RANGE;
@@ -673,7 +673,7 @@ void VisualScriptFunctionCall::_validate_property(PropertyInfo &property) const
}
}
- if (property.name == "rpc/call_mode") {
+ if (property.name == "rpc_call_mode") {
if (call_mode == CALL_MODE_BASIC_TYPE) {
property.usage = 0;
}
@@ -735,17 +735,17 @@ void VisualScriptFunctionCall::_bind_methods() {
script_ext_hint += "*." + E->get();
}
- ADD_PROPERTY(PropertyInfo(Variant::INT, "function/call_mode", PROPERTY_HINT_ENUM, "Self,Node Path,Instance,Basic Type,Singleton"), "set_call_mode", "get_call_mode");
- ADD_PROPERTY(PropertyInfo(Variant::STRING, "function/base_type", PROPERTY_HINT_TYPE_STRING, "Object"), "set_base_type", "get_base_type");
- ADD_PROPERTY(PropertyInfo(Variant::STRING, "function/base_script", PROPERTY_HINT_FILE, script_ext_hint), "set_base_script", "get_base_script");
- ADD_PROPERTY(PropertyInfo(Variant::STRING, "function/singleton"), "set_singleton", "get_singleton");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "function/basic_type", PROPERTY_HINT_ENUM, bt), "set_basic_type", "get_basic_type");
- ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "function/node_path", PROPERTY_HINT_NODE_PATH_TO_EDITED_NODE), "set_base_path", "get_base_path");
- ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "function/argument_cache", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "_set_argument_cache", "_get_argument_cache");
- ADD_PROPERTY(PropertyInfo(Variant::STRING, "function/function"), "set_function", "get_function"); //when set, if loaded properly, will override argument count.
- ADD_PROPERTY(PropertyInfo(Variant::INT, "function/use_default_args"), "set_use_default_args", "get_use_default_args");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "function/validate"), "set_validate", "get_validate");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "rpc/call_mode", PROPERTY_HINT_ENUM, "Disabled,Reliable,Unreliable,ReliableToID,UnreliableToID"), "set_rpc_call_mode", "get_rpc_call_mode"); //when set, if loaded properly, will override argument count.
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "call_mode", PROPERTY_HINT_ENUM, "Self,Node Path,Instance,Basic Type,Singleton"), "set_call_mode", "get_call_mode");
+ ADD_PROPERTY(PropertyInfo(Variant::STRING, "base_type", PROPERTY_HINT_TYPE_STRING, "Object"), "set_base_type", "get_base_type");
+ ADD_PROPERTY(PropertyInfo(Variant::STRING, "base_script", PROPERTY_HINT_FILE, script_ext_hint), "set_base_script", "get_base_script");
+ ADD_PROPERTY(PropertyInfo(Variant::STRING, "singleton"), "set_singleton", "get_singleton");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "basic_type", PROPERTY_HINT_ENUM, bt), "set_basic_type", "get_basic_type");
+ ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "node_path", PROPERTY_HINT_NODE_PATH_TO_EDITED_NODE), "set_base_path", "get_base_path");
+ ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "argument_cache", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "_set_argument_cache", "_get_argument_cache");
+ ADD_PROPERTY(PropertyInfo(Variant::STRING, "function"), "set_function", "get_function"); //when set, if loaded properly, will override argument count.
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "use_default_args"), "set_use_default_args", "get_use_default_args");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "validate"), "set_validate", "get_validate");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "rpc_call_mode", PROPERTY_HINT_ENUM, "Disabled,Reliable,Unreliable,ReliableToID,UnreliableToID"), "set_rpc_call_mode", "get_rpc_call_mode"); //when set, if loaded properly, will override argument count.
BIND_CONSTANT(CALL_MODE_SELF);
BIND_CONSTANT(CALL_MODE_NODE_PATH);
@@ -867,7 +867,7 @@ public:
} break;
case VisualScriptFunctionCall::CALL_MODE_SINGLETON: {
- Object *object = GlobalConfig::get_singleton()->get_singleton_object(singleton);
+ Object *object = ProjectSettings::get_singleton()->get_singleton_object(singleton);
if (!object) {
r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
r_error_str = "Invalid singleton name: '" + String(singleton) + "'";
@@ -1020,6 +1020,18 @@ String VisualScriptPropertySet::get_output_sequence_port_text(int p_port) const
return String();
}
+void VisualScriptPropertySet::_adjust_input_index(PropertyInfo &pinfo) const {
+
+ if (index != StringName()) {
+
+ Variant v;
+ Variant::CallError ce;
+ v = Variant::construct(pinfo.type, NULL, 0, ce);
+ Variant i = v.get(index);
+ pinfo.type = i.get_type();
+ }
+}
+
PropertyInfo VisualScriptPropertySet::get_input_value_port_info(int p_idx) const {
if (call_mode == CALL_MODE_INSTANCE || call_mode == CALL_MODE_BASIC_TYPE) {
@@ -1027,6 +1039,7 @@ PropertyInfo VisualScriptPropertySet::get_input_value_port_info(int p_idx) const
PropertyInfo pi;
pi.type = (call_mode == CALL_MODE_INSTANCE ? Variant::OBJECT : basic_type);
pi.name = (call_mode == CALL_MODE_INSTANCE ? String("instance") : Variant::get_type_name(basic_type).to_lower());
+ _adjust_input_index(pi);
return pi;
} else {
p_idx--;
@@ -1035,6 +1048,7 @@ PropertyInfo VisualScriptPropertySet::get_input_value_port_info(int p_idx) const
PropertyInfo pinfo = type_cache;
pinfo.name = "value";
+ _adjust_input_index(pinfo);
return pinfo;
}
@@ -1051,13 +1065,16 @@ PropertyInfo VisualScriptPropertySet::get_output_value_port_info(int p_idx) cons
String VisualScriptPropertySet::get_caption() const {
static const char *cname[4] = {
- "SelfSet",
- "NodeSet",
- "InstanceSet",
- "BasicSet"
+ "Self",
+ "Node",
+ "Instance",
+ "Basic"
};
- return cname[call_mode];
+ static const char *opname[ASSIGN_OP_MAX] = {
+ "Set", "Add", "Sub", "Mul", "Div", "Mod", "ShiftLeft", "ShiftRight", "BitAnd", "BitOr", "BitXor"
+ };
+ return String(cname[call_mode]) + opname[assign_op];
}
String VisualScriptPropertySet::get_text() const {
@@ -1073,6 +1090,9 @@ String VisualScriptPropertySet::get_text() const {
else if (call_mode == CALL_MODE_INSTANCE)
prop = String(base_type) + ":" + property;
+ if (index != StringName()) {
+ prop += "." + String(index);
+ }
return prop;
}
@@ -1236,6 +1256,7 @@ void VisualScriptPropertySet::set_property(const StringName &p_type) {
return;
property = p_type;
+ index = StringName();
_update_cache();
_change_notify();
ports_changed_notify();
@@ -1285,27 +1306,58 @@ Dictionary VisualScriptPropertySet::_get_type_cache() const {
return type_cache;
}
+void VisualScriptPropertySet::set_index(const StringName &p_type) {
+
+ if (index == p_type)
+ return;
+ index = p_type;
+ _update_cache();
+ _change_notify();
+ ports_changed_notify();
+}
+
+StringName VisualScriptPropertySet::get_index() const {
+
+ return index;
+}
+
+void VisualScriptPropertySet::set_assign_op(AssignOp p_op) {
+
+ ERR_FAIL_INDEX(p_op, ASSIGN_OP_MAX);
+ if (assign_op == p_op)
+ return;
+
+ assign_op = p_op;
+ _update_cache();
+ _change_notify();
+ ports_changed_notify();
+}
+
+VisualScriptPropertySet::AssignOp VisualScriptPropertySet::get_assign_op() const {
+ return assign_op;
+}
+
void VisualScriptPropertySet::_validate_property(PropertyInfo &property) const {
- if (property.name == "property/base_type") {
+ if (property.name == "base_type") {
if (call_mode != CALL_MODE_INSTANCE) {
property.usage = PROPERTY_USAGE_NOEDITOR;
}
}
- if (property.name == "property/base_script") {
+ if (property.name == "base_script") {
if (call_mode != CALL_MODE_INSTANCE) {
property.usage = 0;
}
}
- if (property.name == "property/basic_type") {
+ if (property.name == "basic_type") {
if (call_mode != CALL_MODE_BASIC_TYPE) {
property.usage = 0;
}
}
- if (property.name == "property/node_path") {
+ if (property.name == "node_path") {
if (call_mode != CALL_MODE_NODE_PATH) {
property.usage = 0;
} else {
@@ -1318,7 +1370,7 @@ void VisualScriptPropertySet::_validate_property(PropertyInfo &property) const {
}
}
- if (property.name == "property/property") {
+ if (property.name == "property") {
if (call_mode == CALL_MODE_BASIC_TYPE) {
@@ -1360,6 +1412,24 @@ void VisualScriptPropertySet::_validate_property(PropertyInfo &property) const {
}
}
}
+
+ if (property.name == "index") {
+
+ Variant::CallError ce;
+ Variant v = Variant::construct(type_cache.type, NULL, 0, ce);
+ List<PropertyInfo> plist;
+ v.get_property_list(&plist);
+ String options = "";
+ for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) {
+ options += "," + E->get().name;
+ }
+
+ property.hint = PROPERTY_HINT_ENUM;
+ property.hint_string = options;
+ property.type = Variant::STRING;
+ if (options == "")
+ property.usage = 0; //hide if type has no usable index
+ }
}
void VisualScriptPropertySet::_bind_methods() {
@@ -1385,6 +1455,12 @@ void VisualScriptPropertySet::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_base_path", "base_path"), &VisualScriptPropertySet::set_base_path);
ClassDB::bind_method(D_METHOD("get_base_path"), &VisualScriptPropertySet::get_base_path);
+ ClassDB::bind_method(D_METHOD("set_index", "index"), &VisualScriptPropertySet::set_index);
+ ClassDB::bind_method(D_METHOD("get_index"), &VisualScriptPropertySet::get_index);
+
+ ClassDB::bind_method(D_METHOD("set_assign_op", "assign_op"), &VisualScriptPropertySet::set_assign_op);
+ ClassDB::bind_method(D_METHOD("get_assign_op"), &VisualScriptPropertySet::get_assign_op);
+
String bt;
for (int i = 0; i < Variant::VARIANT_MAX; i++) {
if (i > 0)
@@ -1405,14 +1481,15 @@ void VisualScriptPropertySet::_bind_methods() {
script_ext_hint += "*." + E->get();
}
- ADD_PROPERTY(PropertyInfo(Variant::INT, "property/set_mode", PROPERTY_HINT_ENUM, "Self,Node Path,Instance,Basic Type"), "set_call_mode", "get_call_mode");
- ADD_PROPERTY(PropertyInfo(Variant::STRING, "property/base_type", PROPERTY_HINT_TYPE_STRING, "Object"), "set_base_type", "get_base_type");
- ADD_PROPERTY(PropertyInfo(Variant::STRING, "property/base_script", PROPERTY_HINT_FILE, script_ext_hint), "set_base_script", "get_base_script");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "property/type_cache", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "_set_type_cache", "_get_type_cache");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "property/basic_type", PROPERTY_HINT_ENUM, bt), "set_basic_type", "get_basic_type");
- ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "property/node_path", PROPERTY_HINT_NODE_PATH_TO_EDITED_NODE), "set_base_path", "get_base_path");
- ADD_PROPERTY(PropertyInfo(Variant::STRING, "property/property"), "set_property", "get_property");
-
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "set_mode", PROPERTY_HINT_ENUM, "Self,Node Path,Instance,Basic Type"), "set_call_mode", "get_call_mode");
+ ADD_PROPERTY(PropertyInfo(Variant::STRING, "base_type", PROPERTY_HINT_TYPE_STRING, "Object"), "set_base_type", "get_base_type");
+ ADD_PROPERTY(PropertyInfo(Variant::STRING, "base_script", PROPERTY_HINT_FILE, script_ext_hint), "set_base_script", "get_base_script");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "type_cache", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "_set_type_cache", "_get_type_cache");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "basic_type", PROPERTY_HINT_ENUM, bt), "set_basic_type", "get_basic_type");
+ ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "node_path", PROPERTY_HINT_NODE_PATH_TO_EDITED_NODE), "set_base_path", "get_base_path");
+ ADD_PROPERTY(PropertyInfo(Variant::STRING, "property"), "set_property", "get_property");
+ ADD_PROPERTY(PropertyInfo(Variant::STRING, "index"), "set_index", "get_index");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "assign_op", PROPERTY_HINT_ENUM, "Assign,Add,Sub,Mul,Div,Mod,ShiftLeft,ShiftRight,BitAnd,BitOr,Bitxor"), "set_assign_op", "get_assign_op");
BIND_CONSTANT(CALL_MODE_SELF);
BIND_CONSTANT(CALL_MODE_NODE_PATH);
BIND_CONSTANT(CALL_MODE_INSTANCE);
@@ -1426,11 +1503,72 @@ public:
VisualScriptPropertySet *node;
VisualScriptInstance *instance;
+ VisualScriptPropertySet::AssignOp assign_op;
+ StringName index;
+ bool needs_get;
//virtual int get_working_memory_size() const { return 0; }
//virtual bool is_output_port_unsequenced(int p_idx) const { return false; }
//virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return true; }
+ _FORCE_INLINE_ void _process_get(Variant &source, const Variant &p_argument, bool &valid) {
+
+ if (index != StringName() && assign_op == VisualScriptPropertySet::ASSIGN_OP_NONE) {
+ source.set_named(index, p_argument, &valid);
+ } else {
+
+ Variant value;
+ if (index != StringName()) {
+ value = source.get_named(index, &valid);
+ } else {
+ value = source;
+ }
+
+ switch (assign_op) {
+ case VisualScriptPropertySet::ASSIGN_OP_NONE: {
+ //should never get here
+ } break;
+ case VisualScriptPropertySet::ASSIGN_OP_ADD: {
+ value = Variant::evaluate(Variant::OP_ADD, value, p_argument);
+ } break;
+ case VisualScriptPropertySet::ASSIGN_OP_SUB: {
+ value = Variant::evaluate(Variant::OP_SUBSTRACT, value, p_argument);
+ } break;
+ case VisualScriptPropertySet::ASSIGN_OP_MUL: {
+ value = Variant::evaluate(Variant::OP_MULTIPLY, value, p_argument);
+ } break;
+ case VisualScriptPropertySet::ASSIGN_OP_DIV: {
+ value = Variant::evaluate(Variant::OP_DIVIDE, value, p_argument);
+ } break;
+ case VisualScriptPropertySet::ASSIGN_OP_MOD: {
+ value = Variant::evaluate(Variant::OP_MODULE, value, p_argument);
+ } break;
+ case VisualScriptPropertySet::ASSIGN_OP_SHIFT_LEFT: {
+ value = Variant::evaluate(Variant::OP_SHIFT_LEFT, value, p_argument);
+ } break;
+ case VisualScriptPropertySet::ASSIGN_OP_SHIFT_RIGHT: {
+ value = Variant::evaluate(Variant::OP_SHIFT_RIGHT, value, p_argument);
+ } break;
+ case VisualScriptPropertySet::ASSIGN_OP_BIT_AND: {
+ value = Variant::evaluate(Variant::OP_BIT_AND, value, p_argument);
+ } break;
+ case VisualScriptPropertySet::ASSIGN_OP_BIT_OR: {
+ value = Variant::evaluate(Variant::OP_BIT_OR, value, p_argument);
+ } break;
+ case VisualScriptPropertySet::ASSIGN_OP_BIT_XOR: {
+ value = Variant::evaluate(Variant::OP_BIT_XOR, value, p_argument);
+ } break;
+ default: {}
+ }
+
+ if (index != StringName()) {
+ source.set_named(index, value, &valid);
+ } else {
+ source = value;
+ }
+ }
+ }
+
virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Variant::CallError &r_error, String &r_error_str) {
switch (call_mode) {
@@ -1441,7 +1579,13 @@ public:
bool valid;
- object->set(property, *p_inputs[0], &valid);
+ if (needs_get) {
+ Variant value = object->get(property, &valid);
+ _process_get(value, *p_inputs[0], valid);
+ object->set(property, value, &valid);
+ } else {
+ object->set(property, *p_inputs[0], &valid);
+ }
if (!valid) {
r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
@@ -1466,7 +1610,14 @@ public:
bool valid;
- another->set(property, *p_inputs[0], &valid);
+ if (needs_get) {
+
+ Variant value = another->get(property, &valid);
+ _process_get(value, *p_inputs[0], valid);
+ another->set(property, value, &valid);
+ } else {
+ another->set(property, *p_inputs[0], &valid);
+ }
if (!valid) {
r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
@@ -1481,7 +1632,14 @@ public:
bool valid;
- v.set(property, *p_inputs[1], &valid);
+ if (needs_get) {
+ Variant value = v.get_named(property, &valid);
+ _process_get(value, *p_inputs[1], valid);
+ v.set_named(property, value, &valid);
+
+ } else {
+ v.set_named(property, *p_inputs[1], &valid);
+ }
if (!valid) {
r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
@@ -1504,6 +1662,9 @@ VisualScriptNodeInstance *VisualScriptPropertySet::instance(VisualScriptInstance
instance->property = property;
instance->call_mode = call_mode;
instance->node_path = base_path;
+ instance->assign_op = assign_op;
+ instance->index = index;
+ instance->needs_get = index != StringName() || assign_op != ASSIGN_OP_NONE;
return instance;
}
@@ -1517,6 +1678,7 @@ VisualScriptPropertySet::TypeGuess VisualScriptPropertySet::guess_output_type(Ty
}
VisualScriptPropertySet::VisualScriptPropertySet() {
+ assign_op = ASSIGN_OP_NONE;
call_mode = CALL_MODE_SELF;
base_type = "Object";
basic_type = Variant::NIL;
@@ -1641,6 +1803,15 @@ PropertyInfo VisualScriptPropertyGet::get_input_value_port_info(int p_idx) const
PropertyInfo VisualScriptPropertyGet::get_output_value_port_info(int p_idx) const {
+ if (index != StringName()) {
+
+ Variant v;
+ Variant::CallError ce;
+ v = Variant::construct(type_cache, NULL, 0, ce);
+ Variant i = v.get(index);
+ return PropertyInfo(i.get_type(), "value." + String(index));
+ }
+
return PropertyInfo(type_cache, "value");
}
@@ -1867,27 +2038,42 @@ Variant::Type VisualScriptPropertyGet::_get_type_cache() const {
return type_cache;
}
+void VisualScriptPropertyGet::set_index(const StringName &p_type) {
+
+ if (index == p_type)
+ return;
+ index = p_type;
+ _update_cache();
+ _change_notify();
+ ports_changed_notify();
+}
+
+StringName VisualScriptPropertyGet::get_index() const {
+
+ return index;
+}
+
void VisualScriptPropertyGet::_validate_property(PropertyInfo &property) const {
- if (property.name == "property/base_type") {
+ if (property.name == "base_type") {
if (call_mode != CALL_MODE_INSTANCE) {
property.usage = PROPERTY_USAGE_NOEDITOR;
}
}
- if (property.name == "property/base_script") {
+ if (property.name == "base_script") {
if (call_mode != CALL_MODE_INSTANCE) {
property.usage = 0;
}
}
- if (property.name == "property/basic_type") {
+ if (property.name == "basic_type") {
if (call_mode != CALL_MODE_BASIC_TYPE) {
property.usage = 0;
}
}
- if (property.name == "property/node_path") {
+ if (property.name == "node_path") {
if (call_mode != CALL_MODE_NODE_PATH) {
property.usage = 0;
} else {
@@ -1900,7 +2086,7 @@ void VisualScriptPropertyGet::_validate_property(PropertyInfo &property) const {
}
}
- if (property.name == "property/property") {
+ if (property.name == "property") {
if (call_mode == CALL_MODE_BASIC_TYPE) {
@@ -1941,6 +2127,24 @@ void VisualScriptPropertyGet::_validate_property(PropertyInfo &property) const {
}
}
}
+
+ if (property.name == "index") {
+
+ Variant::CallError ce;
+ Variant v = Variant::construct(type_cache, NULL, 0, ce);
+ List<PropertyInfo> plist;
+ v.get_property_list(&plist);
+ String options = "";
+ for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) {
+ options += "," + E->get().name;
+ }
+
+ property.hint = PROPERTY_HINT_ENUM;
+ property.hint_string = options;
+ property.type = Variant::STRING;
+ if (options == "")
+ property.usage = 0; //hide if type has no usable index
+ }
}
void VisualScriptPropertyGet::_bind_methods() {
@@ -1966,6 +2170,9 @@ void VisualScriptPropertyGet::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_base_path", "base_path"), &VisualScriptPropertyGet::set_base_path);
ClassDB::bind_method(D_METHOD("get_base_path"), &VisualScriptPropertyGet::get_base_path);
+ ClassDB::bind_method(D_METHOD("set_index", "index"), &VisualScriptPropertyGet::set_index);
+ ClassDB::bind_method(D_METHOD("get_index"), &VisualScriptPropertyGet::get_index);
+
String bt;
for (int i = 0; i < Variant::VARIANT_MAX; i++) {
if (i > 0)
@@ -1986,13 +2193,14 @@ void VisualScriptPropertyGet::_bind_methods() {
script_ext_hint += "." + E->get();
}
- ADD_PROPERTY(PropertyInfo(Variant::INT, "property/set_mode", PROPERTY_HINT_ENUM, "Self,Node Path,Instance,Basic Type"), "set_call_mode", "get_call_mode");
- ADD_PROPERTY(PropertyInfo(Variant::STRING, "property/base_type", PROPERTY_HINT_TYPE_STRING, "Object"), "set_base_type", "get_base_type");
- ADD_PROPERTY(PropertyInfo(Variant::STRING, "property/base_script", PROPERTY_HINT_FILE, script_ext_hint), "set_base_script", "get_base_script");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "property/type_cache", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "_set_type_cache", "_get_type_cache");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "property/basic_type", PROPERTY_HINT_ENUM, bt), "set_basic_type", "get_basic_type");
- ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "property/node_path", PROPERTY_HINT_NODE_PATH_TO_EDITED_NODE), "set_base_path", "get_base_path");
- ADD_PROPERTY(PropertyInfo(Variant::STRING, "property/property"), "set_property", "get_property");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "set_mode", PROPERTY_HINT_ENUM, "Self,Node Path,Instance,Basic Type"), "set_call_mode", "get_call_mode");
+ ADD_PROPERTY(PropertyInfo(Variant::STRING, "base_type", PROPERTY_HINT_TYPE_STRING, "Object"), "set_base_type", "get_base_type");
+ ADD_PROPERTY(PropertyInfo(Variant::STRING, "base_script", PROPERTY_HINT_FILE, script_ext_hint), "set_base_script", "get_base_script");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "type_cache", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "_set_type_cache", "_get_type_cache");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "basic_type", PROPERTY_HINT_ENUM, bt), "set_basic_type", "get_basic_type");
+ ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "node_path", PROPERTY_HINT_NODE_PATH_TO_EDITED_NODE), "set_base_path", "get_base_path");
+ ADD_PROPERTY(PropertyInfo(Variant::STRING, "property"), "set_property", "get_property");
+ ADD_PROPERTY(PropertyInfo(Variant::STRING, "index", PROPERTY_HINT_ENUM), "set_index", "get_index");
BIND_CONSTANT(CALL_MODE_SELF);
BIND_CONSTANT(CALL_MODE_NODE_PATH);
@@ -2004,6 +2212,7 @@ public:
VisualScriptPropertyGet::CallMode call_mode;
NodePath node_path;
StringName property;
+ StringName index;
VisualScriptPropertyGet *node;
VisualScriptInstance *instance;
@@ -2020,6 +2229,10 @@ public:
*p_outputs[0] = object->get(property, &valid);
+ if (index != StringName()) {
+ *p_outputs[0] = p_outputs[0]->get_named(index);
+ }
+
if (!valid) {
r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
r_error_str = RTR("Invalid index property name.");
@@ -2046,6 +2259,10 @@ public:
*p_outputs[0] = another->get(property, &valid);
+ if (index != StringName()) {
+ *p_outputs[0] = p_outputs[0]->get_named(index);
+ }
+
if (!valid) {
r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
r_error_str = vformat(RTR("Invalid index property name '%s' in node %s."), String(property), another->get_name());
@@ -2059,6 +2276,9 @@ public:
Variant v = *p_inputs[0];
*p_outputs[0] = v.get(property, &valid);
+ if (index != StringName()) {
+ *p_outputs[0] = p_outputs[0]->get_named(index);
+ }
if (!valid) {
r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
@@ -2079,6 +2299,7 @@ VisualScriptNodeInstance *VisualScriptPropertyGet::instance(VisualScriptInstance
instance->property = property;
instance->call_mode = call_mode;
instance->node_path = base_path;
+ instance->index = index;
return instance;
}
@@ -2182,7 +2403,7 @@ StringName VisualScriptEmitSignal::get_signal() const {
void VisualScriptEmitSignal::_validate_property(PropertyInfo &property) const {
- if (property.name == "signal/signal") {
+ if (property.name == "signal") {
property.hint = PROPERTY_HINT_ENUM;
List<StringName> sigs;
@@ -2210,7 +2431,7 @@ void VisualScriptEmitSignal::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_signal", "name"), &VisualScriptEmitSignal::set_signal);
ClassDB::bind_method(D_METHOD("get_signal"), &VisualScriptEmitSignal::get_signal);
- ADD_PROPERTY(PropertyInfo(Variant::STRING, "signal/signal"), "set_signal", "get_signal");
+ ADD_PROPERTY(PropertyInfo(Variant::STRING, "signal"), "set_signal", "get_signal");
}
class VisualScriptNodeInstanceEmitSignal : public VisualScriptNodeInstance {
diff --git a/modules/visual_script/visual_script_func_nodes.h b/modules/visual_script/visual_script_func_nodes.h
index 3b284952c5..7839748661 100644
--- a/modules/visual_script/visual_script_func_nodes.h
+++ b/modules/visual_script/visual_script_func_nodes.h
@@ -146,6 +146,21 @@ public:
};
+ enum AssignOp {
+ ASSIGN_OP_NONE,
+ ASSIGN_OP_ADD,
+ ASSIGN_OP_SUB,
+ ASSIGN_OP_MUL,
+ ASSIGN_OP_DIV,
+ ASSIGN_OP_MOD,
+ ASSIGN_OP_SHIFT_LEFT,
+ ASSIGN_OP_SHIFT_RIGHT,
+ ASSIGN_OP_BIT_AND,
+ ASSIGN_OP_BIT_OR,
+ ASSIGN_OP_BIT_XOR,
+ ASSIGN_OP_MAX
+ };
+
private:
PropertyInfo type_cache;
@@ -155,6 +170,8 @@ private:
String base_script;
NodePath base_path;
StringName property;
+ StringName index;
+ AssignOp assign_op;
Node *_get_base_node() const;
StringName _get_base_type() const;
@@ -166,6 +183,8 @@ private:
void _set_type_cache(const Dictionary &p_type);
Dictionary _get_type_cache() const;
+ void _adjust_input_index(PropertyInfo &pinfo) const;
+
protected:
virtual void _validate_property(PropertyInfo &property) const;
@@ -205,6 +224,12 @@ public:
void set_call_mode(CallMode p_mode);
CallMode get_call_mode() const;
+ void set_index(const StringName &p_type);
+ StringName get_index() const;
+
+ void set_assign_op(AssignOp p_op);
+ AssignOp get_assign_op() const;
+
virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
virtual TypeGuess guess_output_type(TypeGuess *p_inputs, int p_output) const;
@@ -212,6 +237,7 @@ public:
};
VARIANT_ENUM_CAST(VisualScriptPropertySet::CallMode);
+VARIANT_ENUM_CAST(VisualScriptPropertySet::AssignOp);
class VisualScriptPropertyGet : public VisualScriptNode {
@@ -234,6 +260,7 @@ private:
String base_script;
NodePath base_path;
StringName property;
+ StringName index;
void _update_base_type();
Node *_get_base_node() const;
@@ -283,6 +310,9 @@ public:
void set_call_mode(CallMode p_mode);
CallMode get_call_mode() const;
+ void set_index(const StringName &p_type);
+ StringName get_index() const;
+
virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
VisualScriptPropertyGet();
diff --git a/modules/visual_script/visual_script_nodes.cpp b/modules/visual_script/visual_script_nodes.cpp
index 86c98d076e..69aa10ebca 100644
--- a/modules/visual_script/visual_script_nodes.cpp
+++ b/modules/visual_script/visual_script_nodes.cpp
@@ -29,10 +29,10 @@
/*************************************************************************/
#include "visual_script_nodes.h"
-#include "global_config.h"
#include "global_constants.h"
#include "os/input.h"
#include "os/os.h"
+#include "project_settings.h"
#include "scene/main/node.h"
#include "scene/main/scene_tree.h"
@@ -59,10 +59,10 @@ bool VisualScriptFunction::_set(const StringName &p_name, const Variant &p_value
_change_notify();
return true;
}
- if (String(p_name).begins_with("argument/")) {
- int idx = String(p_name).get_slice("/", 1).to_int() - 1;
+ if (String(p_name).begins_with("argument_")) {
+ int idx = String(p_name).get_slicec('_', 1).get_slicec('/', 0).to_int() - 1;
ERR_FAIL_INDEX_V(idx, arguments.size(), false);
- String what = String(p_name).get_slice("/", 2);
+ String what = String(p_name).get_slice("/", 1);
if (what == "type") {
Variant::Type new_type = Variant::Type(int(p_value));
@@ -104,10 +104,10 @@ bool VisualScriptFunction::_get(const StringName &p_name, Variant &r_ret) const
r_ret = arguments.size();
return true;
}
- if (String(p_name).begins_with("argument/")) {
- int idx = String(p_name).get_slice("/", 1).to_int() - 1;
+ if (String(p_name).begins_with("argument_")) {
+ int idx = String(p_name).get_slicec('_', 1).get_slicec('/', 0).to_int() - 1;
ERR_FAIL_INDEX_V(idx, arguments.size(), false);
- String what = String(p_name).get_slice("/", 2);
+ String what = String(p_name).get_slice("/", 1);
if (what == "type") {
r_ret = arguments[idx].type;
return true;
@@ -144,8 +144,8 @@ void VisualScriptFunction::_get_property_list(List<PropertyInfo> *p_list) const
}
for (int i = 0; i < arguments.size(); i++) {
- p_list->push_back(PropertyInfo(Variant::INT, "argument/" + itos(i + 1) + "/type", PROPERTY_HINT_ENUM, argt));
- p_list->push_back(PropertyInfo(Variant::STRING, "argument/" + itos(i + 1) + "/name"));
+ p_list->push_back(PropertyInfo(Variant::INT, "argument_" + itos(i + 1) + "/type", PROPERTY_HINT_ENUM, argt));
+ p_list->push_back(PropertyInfo(Variant::STRING, "argument_" + itos(i + 1) + "/name"));
}
if (!stack_less) {
p_list->push_back(PropertyInfo(Variant::INT, "stack/size", PROPERTY_HINT_RANGE, "1,100000"));
@@ -559,8 +559,8 @@ void VisualScriptOperator::_bind_methods() {
argt += "," + Variant::get_type_name(Variant::Type(i));
}
- ADD_PROPERTY(PropertyInfo(Variant::INT, "operator_value/type", PROPERTY_HINT_ENUM, types), "set_operator", "get_operator");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "typed_value/typed", PROPERTY_HINT_ENUM, argt), "set_typed", "get_typed");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "operator", PROPERTY_HINT_ENUM, types), "set_operator", "get_operator");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "type", PROPERTY_HINT_ENUM, argt), "set_typed", "get_typed");
}
class VisualScriptNodeInstanceOperator : public VisualScriptNodeInstance {
@@ -621,6 +621,113 @@ static Ref<VisualScriptNode> create_op_node(const String &p_name) {
}
//////////////////////////////////////////
+////////////////OPERATOR//////////////////
+//////////////////////////////////////////
+
+int VisualScriptSelect::get_output_sequence_port_count() const {
+
+ return 0;
+}
+
+bool VisualScriptSelect::has_input_sequence_port() const {
+
+ return false;
+}
+
+int VisualScriptSelect::get_input_value_port_count() const {
+
+ return 3;
+}
+int VisualScriptSelect::get_output_value_port_count() const {
+
+ return 1;
+}
+
+String VisualScriptSelect::get_output_sequence_port_text(int p_port) const {
+
+ return String();
+}
+
+PropertyInfo VisualScriptSelect::get_input_value_port_info(int p_idx) const {
+
+ if (p_idx == 0) {
+ return PropertyInfo(Variant::BOOL, "cond");
+ } else if (p_idx == 1) {
+ return PropertyInfo(typed, "a");
+ } else {
+ return PropertyInfo(typed, "b");
+ }
+}
+PropertyInfo VisualScriptSelect::get_output_value_port_info(int p_idx) const {
+
+ return PropertyInfo(typed, "out");
+}
+
+String VisualScriptSelect::get_caption() const {
+
+ return "Select";
+}
+
+String VisualScriptSelect::get_text() const {
+
+ return "a if cond, else b";
+}
+
+void VisualScriptSelect::set_typed(Variant::Type p_op) {
+
+ if (typed == p_op)
+ return;
+
+ typed = p_op;
+ ports_changed_notify();
+}
+
+Variant::Type VisualScriptSelect::get_typed() const {
+
+ return typed;
+}
+
+void VisualScriptSelect::_bind_methods() {
+
+ ClassDB::bind_method(D_METHOD("set_typed", "type"), &VisualScriptSelect::set_typed);
+ ClassDB::bind_method(D_METHOD("get_typed"), &VisualScriptSelect::get_typed);
+
+ String argt = "Any";
+ for (int i = 1; i < Variant::VARIANT_MAX; i++) {
+ argt += "," + Variant::get_type_name(Variant::Type(i));
+ }
+
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "type", PROPERTY_HINT_ENUM, argt), "set_typed", "get_typed");
+}
+
+class VisualScriptNodeInstanceSelect : public VisualScriptNodeInstance {
+public:
+ //virtual int get_working_memory_size() const { return 0; }
+
+ virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Variant::CallError &r_error, String &r_error_str) {
+
+ bool cond = *p_inputs[0];
+ if (cond)
+ *p_outputs[0] = *p_inputs[1];
+ else
+ *p_outputs[0] = *p_inputs[2];
+
+ return 0;
+ }
+};
+
+VisualScriptNodeInstance *VisualScriptSelect::instance(VisualScriptInstance *p_instance) {
+
+ VisualScriptNodeInstanceSelect *instance = memnew(VisualScriptNodeInstanceSelect);
+ return instance;
+}
+
+VisualScriptSelect::VisualScriptSelect() {
+
+ typed = Variant::NIL;
+}
+
+//////////////////////////////////////////
////////////////VARIABLE GET//////////////////
//////////////////////////////////////////
@@ -691,7 +798,7 @@ StringName VisualScriptVariableGet::get_variable() const {
void VisualScriptVariableGet::_validate_property(PropertyInfo &property) const {
- if (property.name == "variable/name" && get_visual_script().is_valid()) {
+ if (property.name == "var_name" && get_visual_script().is_valid()) {
Ref<VisualScript> vs = get_visual_script();
List<StringName> vars;
vs->get_variable_list(&vars);
@@ -714,7 +821,7 @@ void VisualScriptVariableGet::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_variable", "name"), &VisualScriptVariableGet::set_variable);
ClassDB::bind_method(D_METHOD("get_variable"), &VisualScriptVariableGet::get_variable);
- ADD_PROPERTY(PropertyInfo(Variant::STRING, "variable/name"), "set_variable", "get_variable");
+ ADD_PROPERTY(PropertyInfo(Variant::STRING, "var_name"), "set_variable", "get_variable");
}
class VisualScriptNodeInstanceVariableGet : public VisualScriptNodeInstance {
@@ -816,7 +923,7 @@ StringName VisualScriptVariableSet::get_variable() const {
void VisualScriptVariableSet::_validate_property(PropertyInfo &property) const {
- if (property.name == "variable/name" && get_visual_script().is_valid()) {
+ if (property.name == "var_name" && get_visual_script().is_valid()) {
Ref<VisualScript> vs = get_visual_script();
List<StringName> vars;
vs->get_variable_list(&vars);
@@ -839,7 +946,7 @@ void VisualScriptVariableSet::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_variable", "name"), &VisualScriptVariableSet::set_variable);
ClassDB::bind_method(D_METHOD("get_variable"), &VisualScriptVariableSet::get_variable);
- ADD_PROPERTY(PropertyInfo(Variant::STRING, "variable/name"), "set_variable", "get_variable");
+ ADD_PROPERTY(PropertyInfo(Variant::STRING, "var_name"), "set_variable", "get_variable");
}
class VisualScriptNodeInstanceVariableSet : public VisualScriptNodeInstance {
@@ -956,7 +1063,7 @@ Variant VisualScriptConstant::get_constant_value() const {
void VisualScriptConstant::_validate_property(PropertyInfo &property) const {
- if (property.name == "constant/value") {
+ if (property.name == "value") {
property.type = type;
if (type == Variant::NIL)
property.usage = 0; //do not save if nil
@@ -969,15 +1076,15 @@ void VisualScriptConstant::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_constant_type"), &VisualScriptConstant::get_constant_type);
ClassDB::bind_method(D_METHOD("set_constant_value", "value"), &VisualScriptConstant::set_constant_value);
- ClassDB::bind_method(D_METHOD("get_constant_value"), &VisualScriptConstant::get_constant_value);
+ ClassDB::bind_method(D_METHOD("get_constant_value:Variant"), &VisualScriptConstant::get_constant_value);
String argt = "Null";
for (int i = 1; i < Variant::VARIANT_MAX; i++) {
argt += "," + Variant::get_type_name(Variant::Type(i));
}
- ADD_PROPERTY(PropertyInfo(Variant::INT, "constant/type", PROPERTY_HINT_ENUM, argt), "set_constant_type", "get_constant_type");
- ADD_PROPERTY(PropertyInfo(Variant::NIL, "constant/value"), "set_constant_value", "get_constant_value");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "type", PROPERTY_HINT_ENUM, argt), "set_constant_type", "get_constant_type");
+ ADD_PROPERTY(PropertyInfo(Variant::NIL, "value"), "set_constant_value", "get_constant_value");
}
class VisualScriptNodeInstanceConstant : public VisualScriptNodeInstance {
@@ -1083,8 +1190,8 @@ Ref<Resource> VisualScriptPreload::get_preload() const {
void VisualScriptPreload::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_preload", "resource"), &VisualScriptPreload::set_preload);
- ClassDB::bind_method(D_METHOD("get_preload"), &VisualScriptPreload::get_preload);
+ ClassDB::bind_method(D_METHOD("set_preload", "resource:Resource"), &VisualScriptPreload::set_preload);
+ ClassDB::bind_method(D_METHOD("get_preload:Resource"), &VisualScriptPreload::get_preload);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "resource", PROPERTY_HINT_RESOURCE_TYPE, "Resource"), "set_preload", "get_preload");
}
@@ -1832,17 +1939,17 @@ public:
VisualScriptNodeInstance *VisualScriptEngineSingleton::instance(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceEngineSingleton *instance = memnew(VisualScriptNodeInstanceEngineSingleton);
- instance->singleton = GlobalConfig::get_singleton()->get_singleton_object(singleton);
+ instance->singleton = ProjectSettings::get_singleton()->get_singleton_object(singleton);
return instance;
}
VisualScriptEngineSingleton::TypeGuess VisualScriptEngineSingleton::guess_output_type(TypeGuess *p_inputs, int p_output) const {
- Object *obj = GlobalConfig::get_singleton()->get_singleton_object(singleton);
+ Object *obj = ProjectSettings::get_singleton()->get_singleton_object(singleton);
TypeGuess tg;
tg.type = Variant::OBJECT;
if (obj) {
- tg.GDCLASS = obj->get_class();
+ tg.gdclass = obj->get_class();
tg.script = obj->get_script();
}
@@ -1856,11 +1963,11 @@ void VisualScriptEngineSingleton::_bind_methods() {
String cc;
- List<GlobalConfig::Singleton> singletons;
+ List<ProjectSettings::Singleton> singletons;
- GlobalConfig::get_singleton()->get_singletons(&singletons);
+ ProjectSettings::get_singleton()->get_singletons(&singletons);
- for (List<GlobalConfig::Singleton>::Element *E = singletons.front(); E; E = E->next()) {
+ for (List<ProjectSettings::Singleton>::Element *E = singletons.front(); E; E = E->next()) {
if (E->get().name == "VS" || E->get().name == "PS" || E->get().name == "PS2D" || E->get().name == "AS" || E->get().name == "TS" || E->get().name == "SS" || E->get().name == "SS2D")
continue; //skip these, too simple named
@@ -2002,7 +2109,7 @@ VisualScriptSceneNode::TypeGuess VisualScriptSceneNode::guess_output_type(TypeGu
VisualScriptSceneNode::TypeGuess tg;
tg.type = Variant::OBJECT;
- tg.GDCLASS = "Node";
+ tg.gdclass = "Node";
#ifdef TOOLS_ENABLED
Ref<Script> script = get_visual_script();
@@ -2031,7 +2138,7 @@ VisualScriptSceneNode::TypeGuess VisualScriptSceneNode::guess_output_type(TypeGu
Node *another = script_node->get_node(path);
if (another) {
- tg.GDCLASS = another->get_class();
+ tg.gdclass = another->get_class();
tg.script = another->get_script();
}
#endif
@@ -2173,7 +2280,7 @@ VisualScriptSceneTree::TypeGuess VisualScriptSceneTree::guess_output_type(TypeGu
TypeGuess tg;
tg.type = Variant::OBJECT;
- tg.GDCLASS = "SceneTree";
+ tg.gdclass = "SceneTree";
return tg;
}
@@ -2353,13 +2460,13 @@ VisualScriptSelf::TypeGuess VisualScriptSelf::guess_output_type(TypeGuess *p_inp
VisualScriptSceneNode::TypeGuess tg;
tg.type = Variant::OBJECT;
- tg.GDCLASS = "Object";
+ tg.gdclass = "Object";
Ref<Script> script = get_visual_script();
if (!script.is_valid())
return tg;
- tg.GDCLASS = script->get_instance_base_type();
+ tg.gdclass = script->get_instance_base_type();
tg.script = script;
return tg;
@@ -2489,10 +2596,10 @@ public:
in_values.resize(in_count);
for (int i = 0; i < in_count; i++) {
- in_values[i] = p_inputs[i];
+ in_values[i] = *p_inputs[i];
}
- out_values.resize(in_count);
+ out_values.resize(out_count);
work_mem.resize(work_mem_size);
@@ -2538,6 +2645,7 @@ VisualScriptNodeInstance *VisualScriptCustomNode::instance(VisualScriptInstance
VisualScriptNodeInstanceCustomNode *instance = memnew(VisualScriptNodeInstanceCustomNode);
instance->instance = p_instance;
+ instance->node = this;
instance->in_count = get_input_value_port_count();
instance->out_count = get_output_value_port_count();
@@ -2550,6 +2658,10 @@ VisualScriptNodeInstance *VisualScriptCustomNode::instance(VisualScriptInstance
return instance;
}
+void VisualScriptCustomNode::_script_changed() {
+ ports_changed_notify();
+}
+
void VisualScriptCustomNode::_bind_methods() {
BIND_VMETHOD(MethodInfo(Variant::INT, "_get_output_sequence_port_count"));
@@ -2572,6 +2684,8 @@ void VisualScriptCustomNode::_bind_methods() {
BIND_VMETHOD(MethodInfo(Variant::INT, "_get_working_memory_size"));
BIND_VMETHOD(MethodInfo(Variant::NIL, "_step:Variant", PropertyInfo(Variant::ARRAY, "inputs"), PropertyInfo(Variant::ARRAY, "outputs"), PropertyInfo(Variant::INT, "start_mode"), PropertyInfo(Variant::ARRAY, "working_mem")));
+ ClassDB::bind_method(D_METHOD("_script_changed"), &VisualScriptCustomNode::_script_changed);
+
BIND_CONSTANT(START_MODE_BEGIN_SEQUENCE);
BIND_CONSTANT(START_MODE_CONTINUE_SEQUENCE);
BIND_CONSTANT(START_MODE_RESUME_YIELD);
@@ -2584,6 +2698,7 @@ void VisualScriptCustomNode::_bind_methods() {
}
VisualScriptCustomNode::VisualScriptCustomNode() {
+ connect("script_changed", this, "_script_changed");
}
//////////////////////////////////////////
@@ -3088,8 +3203,8 @@ void VisualScriptLocalVar::_bind_methods() {
argt += "," + Variant::get_type_name(Variant::Type(i));
}
- ADD_PROPERTY(PropertyInfo(Variant::STRING, "variable/name"), "set_var_name", "get_var_name");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "variable/type", PROPERTY_HINT_ENUM, argt), "set_var_type", "get_var_type");
+ ADD_PROPERTY(PropertyInfo(Variant::STRING, "var_name"), "set_var_name", "get_var_name");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "type", PROPERTY_HINT_ENUM, argt), "set_var_type", "get_var_type");
}
VisualScriptLocalVar::VisualScriptLocalVar() {
@@ -3210,8 +3325,8 @@ void VisualScriptLocalVarSet::_bind_methods() {
argt += "," + Variant::get_type_name(Variant::Type(i));
}
- ADD_PROPERTY(PropertyInfo(Variant::STRING, "variable/name"), "set_var_name", "get_var_name");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "variable/type", PROPERTY_HINT_ENUM, argt), "set_var_type", "get_var_type");
+ ADD_PROPERTY(PropertyInfo(Variant::STRING, "var_name"), "set_var_name", "get_var_name");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "type", PROPERTY_HINT_ENUM, argt), "set_var_type", "get_var_type");
}
VisualScriptLocalVarSet::VisualScriptLocalVarSet() {
@@ -3253,32 +3368,33 @@ PropertyInfo VisualScriptInputAction::get_input_value_port_info(int p_idx) const
}
PropertyInfo VisualScriptInputAction::get_output_value_port_info(int p_idx) const {
- return PropertyInfo(Variant::BOOL, "pressed");
-}
-
-String VisualScriptInputAction::get_caption() const {
-
- return "Action";
-}
-
-String VisualScriptInputAction::get_text() const {
-
+ String mstr;
switch (mode) {
case MODE_PRESSED: {
- return name;
+ mstr = "pressed";
} break;
case MODE_RELEASED: {
- return "not " + name;
+ mstr = "not pressed";
} break;
case MODE_JUST_PRESSED: {
- return String(name) + " " + TTR("just pressed");
+ mstr = "just pressed";
} break;
case MODE_JUST_RELEASED: {
- return String(name) + " " + TTR("just released");
+ mstr = "just released";
} break;
}
- return String();
+ return PropertyInfo(Variant::BOOL, mstr);
+}
+
+String VisualScriptInputAction::get_caption() const {
+
+ return "Action";
+}
+
+String VisualScriptInputAction::get_text() const {
+
+ return name;
}
String VisualScriptInputAction::get_category() const {
@@ -3319,8 +3435,6 @@ public:
StringName action;
VisualScriptInputAction::Mode mode;
- virtual int get_working_memory_size() const { return 1; }
-
virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Variant::CallError &r_error, String &r_error_str) {
switch (mode) {
@@ -3360,7 +3474,7 @@ void VisualScriptInputAction::_validate_property(PropertyInfo &property) const {
String actions;
List<PropertyInfo> pinfo;
- GlobalConfig::get_singleton()->get_property_list(&pinfo);
+ ProjectSettings::get_singleton()->get_property_list(&pinfo);
Vector<String> al;
for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
@@ -3628,6 +3742,7 @@ void register_visual_script_nodes() {
VisualScriptLanguage::singleton->add_register_func("operators/logic/xor", create_op_node<Variant::OP_XOR>);
VisualScriptLanguage::singleton->add_register_func("operators/logic/not", create_op_node<Variant::OP_NOT>);
VisualScriptLanguage::singleton->add_register_func("operators/logic/in", create_op_node<Variant::OP_IN>);
+ VisualScriptLanguage::singleton->add_register_func("operators/logic/select", create_node_generic<VisualScriptSelect>);
VisualScriptLanguage::singleton->add_register_func("functions/deconstruct", create_node_generic<VisualScriptDeconstruct>);
diff --git a/modules/visual_script/visual_script_nodes.h b/modules/visual_script/visual_script_nodes.h
index 402093fa80..7a3b26fe55 100644
--- a/modules/visual_script/visual_script_nodes.h
+++ b/modules/visual_script/visual_script_nodes.h
@@ -127,6 +127,39 @@ public:
VisualScriptOperator();
};
+class VisualScriptSelect : public VisualScriptNode {
+
+ GDCLASS(VisualScriptSelect, VisualScriptNode)
+
+ Variant::Type typed;
+
+protected:
+ static void _bind_methods();
+
+public:
+ virtual int get_output_sequence_port_count() const;
+ virtual bool has_input_sequence_port() const;
+
+ virtual String get_output_sequence_port_text(int p_port) const;
+
+ virtual int get_input_value_port_count() const;
+ virtual int get_output_value_port_count() const;
+
+ virtual PropertyInfo get_input_value_port_info(int p_idx) const;
+ virtual PropertyInfo get_output_value_port_info(int p_idx) const;
+
+ virtual String get_caption() const;
+ virtual String get_text() const;
+ virtual String get_category() const { return "operators"; }
+
+ void set_typed(Variant::Type p_op);
+ Variant::Type get_typed() const;
+
+ virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
+
+ VisualScriptSelect();
+};
+
class VisualScriptVariableGet : public VisualScriptNode {
GDCLASS(VisualScriptVariableGet, VisualScriptNode)
@@ -679,6 +712,8 @@ public:
virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
+ void _script_changed();
+
VisualScriptCustomNode();
};
diff --git a/modules/visual_script/visual_script_yield_nodes.cpp b/modules/visual_script/visual_script_yield_nodes.cpp
index be5b218d0a..2e111511b7 100644
--- a/modules/visual_script/visual_script_yield_nodes.cpp
+++ b/modules/visual_script/visual_script_yield_nodes.cpp
@@ -419,13 +419,13 @@ VisualScriptYieldSignal::CallMode VisualScriptYieldSignal::get_call_mode() const
void VisualScriptYieldSignal::_validate_property(PropertyInfo &property) const {
- if (property.name == "signal/base_type") {
+ if (property.name == "base_type") {
if (call_mode != CALL_MODE_INSTANCE) {
property.usage = PROPERTY_USAGE_NOEDITOR;
}
}
- if (property.name == "signal/node_path") {
+ if (property.name == "node_path") {
if (call_mode != CALL_MODE_NODE_PATH) {
property.usage = 0;
} else {
@@ -438,7 +438,7 @@ void VisualScriptYieldSignal::_validate_property(PropertyInfo &property) const {
}
}
- if (property.name == "signal/signal") {
+ if (property.name == "signal") {
property.hint = PROPERTY_HINT_ENUM;
List<MethodInfo> methods;
@@ -488,10 +488,10 @@ void VisualScriptYieldSignal::_bind_methods() {
bt += Variant::get_type_name(Variant::Type(i));
}
- ADD_PROPERTY(PropertyInfo(Variant::INT, "signal/call_mode", PROPERTY_HINT_ENUM, "Self,Node Path,Instance"), "set_call_mode", "get_call_mode");
- ADD_PROPERTY(PropertyInfo(Variant::STRING, "signal/base_type", PROPERTY_HINT_TYPE_STRING, "Object"), "set_base_type", "get_base_type");
- ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "signal/node_path", PROPERTY_HINT_NODE_PATH_TO_EDITED_NODE), "set_base_path", "get_base_path");
- ADD_PROPERTY(PropertyInfo(Variant::STRING, "signal/signal"), "set_signal", "get_signal");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "call_mode", PROPERTY_HINT_ENUM, "Self,Node Path,Instance"), "set_call_mode", "get_call_mode");
+ ADD_PROPERTY(PropertyInfo(Variant::STRING, "base_type", PROPERTY_HINT_TYPE_STRING, "Object"), "set_base_type", "get_base_type");
+ ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "node_path", PROPERTY_HINT_NODE_PATH_TO_EDITED_NODE), "set_base_path", "get_base_path");
+ ADD_PROPERTY(PropertyInfo(Variant::STRING, "signal"), "set_signal", "get_signal");
BIND_CONSTANT(CALL_MODE_SELF);
BIND_CONSTANT(CALL_MODE_NODE_PATH);
diff --git a/modules/webm/video_stream_webm.cpp b/modules/webm/video_stream_webm.cpp
index eaf4215302..72f10b4f45 100644
--- a/modules/webm/video_stream_webm.cpp
+++ b/modules/webm/video_stream_webm.cpp
@@ -34,8 +34,8 @@
#include "mkvparser/mkvparser.h"
-#include "global_config.h"
#include "os/file_access.h"
+#include "project_settings.h"
#include "thirdparty/misc/yuv2rgb.h"
@@ -168,7 +168,7 @@ void VideoStreamPlaybackWebm::play() {
stop();
- delay_compensation = GlobalConfig::get_singleton()->get("audio/video_delay_compensation_ms");
+ delay_compensation = ProjectSettings::get_singleton()->get("audio/video_delay_compensation_ms");
delay_compensation /= 1000.0;
playing = true;
diff --git a/platform/android/audio_driver_jandroid.cpp b/platform/android/audio_driver_jandroid.cpp
index 7b2127a211..d293f3ed30 100644
--- a/platform/android/audio_driver_jandroid.cpp
+++ b/platform/android/audio_driver_jandroid.cpp
@@ -29,8 +29,8 @@
/*************************************************************************/
#include "audio_driver_jandroid.h"
-#include "global_config.h"
#include "os/os.h"
+#include "project_settings.h"
#include "thread_jandroid.h"
#ifndef ANDROID_NATIVE_ACTIVITY
diff --git a/platform/android/detect.py b/platform/android/detect.py
index ce44ffbf74..fae1df3f27 100644
--- a/platform/android/detect.py
+++ b/platform/android/detect.py
@@ -14,22 +14,17 @@ def get_name():
def can_build():
- import os
- if (not os.environ.has_key("ANDROID_NDK_ROOT")):
- return False
-
- return True
+ return (os.environ.has_key("ANDROID_NDK_ROOT"))
def get_opts():
return [
- ('ANDROID_NDK_ROOT', 'the path to Android NDK',
- os.environ.get("ANDROID_NDK_ROOT", 0)),
- ('ndk_platform', 'compile for platform: (android-<api> , example: android-18)', "android-18"),
- ('android_arch', 'select compiler architecture: (armv7/armv6/x86)', "armv7"),
- ('android_neon', 'enable neon (armv7 only)', "yes"),
- ('android_stl', 'enable STL support in android port (for modules)', "no")
+ ('ANDROID_NDK_ROOT', 'Path to the Android NDK', os.environ.get("ANDROID_NDK_ROOT", 0)),
+ ('ndk_platform', 'Target platform (android-<api>, e.g. "android-18")', "android-18"),
+ ('android_arch', 'Target architecture (armv7/armv6/x86)', "armv7"),
+ ('android_neon', 'Enable NEON support (armv7 only)', "yes"),
+ ('android_stl', 'Enable Android STL support (for modules)', "no")
]
@@ -41,6 +36,7 @@ def get_flags():
def create(env):
+
tools = env['TOOLS']
if "mingw" in tools:
tools.remove('mingw')
@@ -54,7 +50,6 @@ def configure(env):
# Workaround for MinGW. See:
# http://www.scons.org/wiki/LongCmdLinesOnWin32
- import os
if (os.name == "nt"):
import subprocess
@@ -92,35 +87,29 @@ def configure(env):
env['SPAWN'] = mySpawn
- ndk_platform = env['ndk_platform']
+ ## Architecture
if env['android_arch'] not in ['armv7', 'armv6', 'x86']:
env['android_arch'] = 'armv7'
- if env['android_arch'] == 'x86':
- env["x86_libtheora_opt_gcc"] = True
-
- if env['PLATFORM'] == 'win32':
- env.Tool('gcc')
- env['SHLIBSUFFIX'] = '.so'
-
neon_text = ""
if env["android_arch"] == "armv7" and env['android_neon'] == 'yes':
- neon_text = " (with neon)"
- print("Godot Android!!!!! (" + env['android_arch'] + ")" + neon_text)
-
- env.Append(CPPPATH=['#platform/android'])
+ neon_text = " (with NEON)"
+ print("Building for Android (" + env['android_arch'] + ")" + neon_text)
+ can_vectorize = True
if env['android_arch'] == 'x86':
env.extra_suffix = ".x86" + env.extra_suffix
target_subpath = "x86-4.9"
abi_subpath = "i686-linux-android"
arch_subpath = "x86"
+ env["x86_libtheora_opt_gcc"] = True
elif env['android_arch'] == 'armv6':
env.extra_suffix = ".armv6" + env.extra_suffix
target_subpath = "arm-linux-androideabi-4.9"
abi_subpath = "arm-linux-androideabi"
arch_subpath = "armeabi"
+ can_vectorize = False
elif env["android_arch"] == "armv7":
target_subpath = "arm-linux-androideabi-4.9"
abi_subpath = "arm-linux-androideabi"
@@ -130,6 +119,28 @@ def configure(env):
else:
env.extra_suffix = ".armv7" + env.extra_suffix
+ ## Build type
+
+ if (env["target"].startswith("release")):
+ env.Append(LINKFLAGS=['-O2'])
+ env.Append(CPPFLAGS=['-O2', '-DNDEBUG', '-ffast-math', '-funsafe-math-optimizations', '-fomit-frame-pointer'])
+ if (can_vectorize):
+ env.Append(CPPFLAGS=['-ftree-vectorize'])
+ if (env["target"] == "release_debug"):
+ env.Append(CPPFLAGS=['-DDEBUG_ENABLED'])
+ elif (env["target"] == "debug"):
+ env.Append(LINKFLAGS=['-O0'])
+ env.Append(CPPFLAGS=['-O0', '-D_DEBUG', '-UNDEBUG', '-DDEBUG_ENABLED',
+ '-DDEBUG_MEMORY_ENABLED', '-g', '-fno-limit-debug-info'])
+
+ ## Compiler configuration
+
+ env['SHLIBSUFFIX'] = '.so'
+
+ if env['PLATFORM'] == 'win32':
+ env.Tool('gcc')
+ env.use_windows_spawn_fix()
+
mt_link = True
if (sys.platform.startswith("linux")):
host_subpath = "linux-x86_64"
@@ -142,10 +153,8 @@ def configure(env):
mt_link = False
host_subpath = "windows"
- compiler_path = env["ANDROID_NDK_ROOT"] + \
- "/toolchains/llvm/prebuilt/" + host_subpath + "/bin"
- gcc_toolchain_path = env["ANDROID_NDK_ROOT"] + \
- "/toolchains/" + target_subpath + "/prebuilt/" + host_subpath
+ compiler_path = env["ANDROID_NDK_ROOT"] + "/toolchains/llvm/prebuilt/" + host_subpath + "/bin"
+ gcc_toolchain_path = env["ANDROID_NDK_ROOT"] + "/toolchains/" + target_subpath + "/prebuilt/" + host_subpath
tools_path = gcc_toolchain_path + "/" + abi_subpath + "/bin"
# For Clang to find NDK tools in preference of those system-wide
@@ -162,31 +171,28 @@ def configure(env):
else:
env['ARCH'] = 'arch-arm'
- sysroot = env["ANDROID_NDK_ROOT"] + \
- "/platforms/" + ndk_platform + "/" + env['ARCH']
+ sysroot = env["ANDROID_NDK_ROOT"] + "/platforms/" + env['ndk_platform'] + "/" + env['ARCH']
common_opts = ['-fno-integrated-as', '-gcc-toolchain', gcc_toolchain_path]
+ ## Compile flags
+
env.Append(CPPFLAGS=["-isystem", sysroot + "/usr/include"])
- env.Append(CPPFLAGS=string.split(
- '-fpic -ffunction-sections -funwind-tables -fstack-protector-strong -fvisibility=hidden -fno-strict-aliasing'))
- env.Append(CPPFLAGS=string.split('-DANDROID -DNO_STATVFS -DGLES2_ENABLED'))
+ env.Append(CPPFLAGS=string.split('-fpic -ffunction-sections -funwind-tables -fstack-protector-strong -fvisibility=hidden -fno-strict-aliasing'))
+ env.Append(CPPFLAGS=string.split('-DNO_STATVFS -DGLES2_ENABLED'))
env['neon_enabled'] = False
if env['android_arch'] == 'x86':
- can_vectorize = True
target_opts = ['-target', 'i686-none-linux-android']
# The NDK adds this if targeting API < 21, so we can drop it when Godot targets it at least
env.Append(CPPFLAGS=['-mstackrealign'])
+
elif env["android_arch"] == "armv6":
- can_vectorize = False
target_opts = ['-target', 'armv6-none-linux-androideabi']
- env.Append(CPPFLAGS=string.split(
- '-D__ARM_ARCH_6__ -march=armv6 -mfpu=vfp -mfloat-abi=softfp'))
+ env.Append(CPPFLAGS=string.split('-D__ARM_ARCH_6__ -march=armv6 -mfpu=vfp -mfloat-abi=softfp'))
+
elif env["android_arch"] == "armv7":
- can_vectorize = True
target_opts = ['-target', 'armv7-none-linux-androideabi']
- env.Append(CPPFLAGS=string.split(
- '-D__ARM_ARCH_7__ -D__ARM_ARCH_7A__ -march=armv7-a -mfloat-abi=softfp'))
+ env.Append(CPPFLAGS=string.split('-D__ARM_ARCH_7__ -D__ARM_ARCH_7A__ -march=armv7-a -mfloat-abi=softfp'))
if env['android_neon'] == 'yes':
env['neon_enabled'] = True
env.Append(CPPFLAGS=['-mfpu=neon', '-D__ARM_NEON__'])
@@ -196,21 +202,20 @@ def configure(env):
env.Append(CPPFLAGS=target_opts)
env.Append(CPPFLAGS=common_opts)
- env.Append(LIBS=['OpenSLES'])
- env.Append(LIBS=['EGL', 'OpenSLES', 'android'])
- env.Append(LIBS=['log', 'GLESv1_CM', 'GLESv2', 'GLESv3','z'])
-
- if (sys.platform.startswith("darwin")):
- env['SHLIBSUFFIX'] = '.so'
-
- env['LINKFLAGS'] = ['-shared', '--sysroot=' +
- sysroot, '-Wl,--warn-shared-textrel']
- env.Append(LINKFLAGS=string.split(
- '-Wl,--fix-cortex-a8'))
- env.Append(LINKFLAGS=string.split(
- '-Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now'))
- env.Append(LINKFLAGS=string.split(
- '-Wl,-soname,libgodot_android.so -Wl,--gc-sections'))
+ if (env['android_stl'] == 'yes'):
+ env.Append(CPPPATH=[env["ANDROID_NDK_ROOT"] + "/sources/cxx-stl/gnu-libstdc++/4.9/include"])
+ env.Append(CPPPATH=[env["ANDROID_NDK_ROOT"] + "/sources/cxx-stl/gnu-libstdc++/4.9/libs/" + arch_subpath + "/include"])
+ env.Append(LIBPATH=[env["ANDROID_NDK_ROOT"] + "/sources/cxx-stl/gnu-libstdc++/4.9/libs/" + arch_subpath])
+ env.Append(LIBS=["gnustl_static"])
+ else:
+ env.Append(CXXFLAGS=['-fno-rtti', '-fno-exceptions', '-DNO_SAFE_CAST'])
+
+ ## Link flags
+
+ env['LINKFLAGS'] = ['-shared', '--sysroot=' + sysroot, '-Wl,--warn-shared-textrel']
+ env.Append(LINKFLAGS=string.split('-Wl,--fix-cortex-a8'))
+ env.Append(LINKFLAGS=string.split('-Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now'))
+ env.Append(LINKFLAGS=string.split('-Wl,-soname,libgodot_android.so -Wl,--gc-sections'))
if mt_link:
env.Append(LINKFLAGS=['-Wl,--threads'])
env.Append(LINKFLAGS=target_opts)
@@ -221,45 +226,12 @@ def configure(env):
env.Append(LIBPATH=[env["ANDROID_NDK_ROOT"] +
'/toolchains/arm-linux-androideabi-4.9/prebuilt/' + host_subpath + '/' + abi_subpath + '/lib'])
- if (env["target"].startswith("release")):
- env.Append(LINKFLAGS=['-O2'])
- env.Append(CPPFLAGS=['-O2', '-DNDEBUG', '-ffast-math',
- '-funsafe-math-optimizations', '-fomit-frame-pointer'])
- if (can_vectorize):
- env.Append(CPPFLAGS=['-ftree-vectorize'])
- if (env["target"] == "release_debug"):
- env.Append(CPPFLAGS=['-DDEBUG_ENABLED'])
- elif (env["target"] == "debug"):
- env.Append(LINKFLAGS=['-O0'])
- env.Append(CPPFLAGS=['-O0', '-D_DEBUG', '-UNDEBUG', '-DDEBUG_ENABLED',
- '-DDEBUG_MEMORY_ENABLED', '-g', '-fno-limit-debug-info'])
-
- env.Append(CPPFLAGS=['-DANDROID_ENABLED',
- '-DUNIX_ENABLED', '-DNO_FCNTL', '-DMPC_FIXED_POINT'])
+ env.Append(CPPPATH=['#platform/android'])
+ env.Append(CPPFLAGS=['-DANDROID_ENABLED', '-DUNIX_ENABLED', '-DNO_FCNTL', '-DMPC_FIXED_POINT'])
+ env.Append(LIBS=['OpenSLES', 'EGL', 'GLESv3', 'android', 'log', 'z'])
# TODO: Move that to opus module's config
if("module_opus_enabled" in env and env["module_opus_enabled"] != "no"):
if (env["android_arch"] == "armv6" or env["android_arch"] == "armv7"):
env.Append(CFLAGS=["-DOPUS_ARM_OPT"])
env.opus_fixed_point = "yes"
-
- if (env['android_stl'] == 'yes'):
- env.Append(CPPPATH=[env["ANDROID_NDK_ROOT"] +
- "/sources/cxx-stl/gnu-libstdc++/4.9/include"])
- env.Append(CPPPATH=[env["ANDROID_NDK_ROOT"] +
- "/sources/cxx-stl/gnu-libstdc++/4.9/libs/" + arch_subpath + "/include"])
- env.Append(LIBPATH=[env["ANDROID_NDK_ROOT"] +
- "/sources/cxx-stl/gnu-libstdc++/4.9/libs/" + arch_subpath])
- env.Append(LIBS=["gnustl_static"])
- else:
- env.Append(CXXFLAGS=['-fno-rtti', '-fno-exceptions', '-DNO_SAFE_CAST'])
-
- import methods
- env.Append(BUILDERS={'GLSL120': env.Builder(
- action=methods.build_legacygl_headers, suffix='glsl.h', src_suffix='.glsl')})
- env.Append(BUILDERS={'GLSL': env.Builder(
- action=methods.build_glsl_headers, suffix='glsl.h', src_suffix='.glsl')})
- env.Append(BUILDERS={'GLSL120GLES': env.Builder(
- action=methods.build_gles2_headers, suffix='glsl.h', src_suffix='.glsl')})
-
- env.use_windows_spawn_fix()
diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp
index a72e8aa90e..a722cd1b8c 100644
--- a/platform/android/export/export.cpp
+++ b/platform/android/export/export.cpp
@@ -31,13 +31,13 @@
#include "editor/editor_export.h"
#include "editor/editor_node.h"
#include "editor/editor_settings.h"
-#include "global_config.h"
#include "io/marshalls.h"
#include "io/zip_io.h"
#include "os/file_access.h"
#include "os/os.h"
#include "platform/android/logo.gen.h"
#include "platform/android/run_icon.gen.h"
+#include "project_settings.h"
#include "version.h"
#include <string.h>
#if 0
@@ -554,9 +554,9 @@ void EditorExportPlatformAndroid::_fix_resources(Vector<uint8_t>& p_manifest) {
} else {
String lang = str.substr(str.find_last("-")+1,str.length()).replace("-","_");
- String prop = "application/name_"+lang;
- if (GlobalConfig::get_singleton()->has(prop)) {
- str = GlobalConfig::get_singleton()->get(prop);
+ String prop = "application/config/name_"+lang;
+ if (ProjectSettings::get_singleton()->has(prop)) {
+ str = ProjectSettings::get_singleton()->get(prop);
} else {
str = get_project_name();
}
@@ -628,7 +628,7 @@ String EditorExportPlatformAndroid::get_project_name() const {
if (this->name!="") {
aname=this->name;
} else {
- aname = GlobalConfig::get_singleton()->get("application/name");
+ aname = ProjectSettings::get_singleton()->get("application/config/name");
}
@@ -1144,7 +1144,7 @@ Error EditorExportPlatformAndroid::export_project(const String& p_path, bool p_d
if (!found) {
- String appicon = GlobalConfig::get_singleton()->get("application/icon");
+ String appicon = ProjectSettings::get_singleton()->get("application/config/icon");
if (appicon!="" && appicon.ends_with(".png")) {
FileAccess*f = FileAccess::open(appicon,FileAccess::READ);
if (f) {
@@ -1763,7 +1763,7 @@ Error EditorExportPlatformAndroid::run(int p_device, int p_flags) {
String EditorExportPlatformAndroid::get_package_name() {
String pname = package;
- String basename = GlobalConfig::get_singleton()->get("application/name");
+ String basename = ProjectSettings::get_singleton()->get("application/config/name");
basename=basename.to_lower();
String name;
@@ -2050,6 +2050,7 @@ class EditorExportAndroid : public EditorExportPlatform {
String id;
String name;
String description;
+ int release;
};
struct APKExportData {
@@ -2123,6 +2124,7 @@ class EditorExportAndroid : public EditorExportPlatform {
if (ea->devices[j].id == ldevices[i]) {
d.description = ea->devices[j].description;
d.name = ea->devices[j].name;
+ d.release = ea->devices[j].release;
}
}
@@ -2143,6 +2145,7 @@ class EditorExportAndroid : public EditorExportPlatform {
String vendor;
String device;
d.description + "Device ID: " + d.id + "\n";
+ d.release = 0;
for (int j = 0; j < props.size(); j++) {
String p = props[j];
@@ -2153,7 +2156,9 @@ class EditorExportAndroid : public EditorExportPlatform {
} else if (p.begins_with("ro.build.display.id=")) {
d.description += "Build: " + p.get_slice("=", 1).strip_edges() + "\n";
} else if (p.begins_with("ro.build.version.release=")) {
- d.description += "Release: " + p.get_slice("=", 1).strip_edges() + "\n";
+ const String release_str = p.get_slice("=", 1).strip_edges();
+ d.description += "Release: " + release_str + "\n";
+ d.release = release_str.to_int();
} else if (p.begins_with("ro.product.cpu.abi=")) {
d.description += "CPU: " + p.get_slice("=", 1).strip_edges() + "\n";
} else if (p.begins_with("ro.product.manufacturer=")) {
@@ -2208,7 +2213,7 @@ class EditorExportAndroid : public EditorExportPlatform {
if (p_name != "") {
aname = p_name;
} else {
- aname = GlobalConfig::get_singleton()->get("application/name");
+ aname = ProjectSettings::get_singleton()->get("application/config/name");
}
if (aname == "") {
@@ -2221,7 +2226,7 @@ class EditorExportAndroid : public EditorExportPlatform {
String get_package_name(const String &p_package) {
String pname = p_package;
- String basename = GlobalConfig::get_singleton()->get("application/name");
+ String basename = ProjectSettings::get_singleton()->get("application/config/name");
basename = basename.to_lower();
String name;
@@ -2537,6 +2542,10 @@ class EditorExportAndroid : public EditorExportPlatform {
}*/
}
+ if (tname == "uses-feature" && /*nspace=="android" &&*/ attrname == "glEsVersion") {
+ print_line("version number: " + itos(decode_uint32(&p_manifest[iofs + 16])));
+ }
+
if (tname == "uses-permission" && /*nspace=="android" &&*/ attrname == "name") {
if (value.begins_with("godot.custom")) {
@@ -2750,9 +2759,9 @@ class EditorExportAndroid : public EditorExportPlatform {
} else {
String lang = str.substr(str.find_last("-") + 1, str.length()).replace("-", "_");
- String prop = "application/name_" + lang;
- if (GlobalConfig::get_singleton()->has(prop)) {
- str = GlobalConfig::get_singleton()->get(prop);
+ String prop = "application/config/name_" + lang;
+ if (ProjectSettings::get_singleton()->has(prop)) {
+ str = ProjectSettings::get_singleton()->get(prop);
} else {
str = get_project_name(package_name);
}
@@ -2826,11 +2835,17 @@ public:
public:
virtual void get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) {
- r_features->push_back("etc");
+ int api = p_preset->get("graphics/api");
+ if (api == 0)
+ r_features->push_back("etc");
+ else
+ r_features->push_back("etc2");
}
virtual void get_export_options(List<ExportOption> *r_options) {
+ r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "graphics/api", PROPERTY_HINT_ENUM, "OpenGL ES 2.0,OpenGL ES 3.0"), 1));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "graphics/32_bits_framebuffer"), true));
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "one_click_deploy/clear_previous_install"), true));
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_package/debug", PROPERTY_HINT_GLOBAL_FILE, "apk"), ""));
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_package/release", PROPERTY_HINT_GLOBAL_FILE, "apk"), ""));
@@ -2843,7 +2858,6 @@ public:
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "package/signed"), true));
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "architecture/arm"), true));
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "architecture/x86"), false));
- r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "screen/use_32_bits_view"), true));
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "screen/immersive_mode"), true));
r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "screen/orientation", PROPERTY_HINT_ENUM, "Landscape,Portrait"), 0));
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "screen/support_small"), true));
@@ -2875,6 +2889,11 @@ public:
virtual String get_name() const {
return "Android";
}
+
+ virtual String get_os_name() const {
+ return "Android";
+ }
+
virtual Ref<Texture> get_logo() const {
return logo;
}
@@ -2991,15 +3010,19 @@ public:
if (use_adb_over_usb) {
args.clear();
+ args.push_back("-s");
+ args.push_back(devices[p_device].id);
args.push_back("reverse");
args.push_back("--remove-all");
err = OS::get_singleton()->execute(adb, args, true, NULL, NULL, &rv);
- int port = (int)EditorSettings::get_singleton()->get("network/debug/remote_port");
+ int dbg_port = EditorSettings::get_singleton()->get("network/debug/remote_port");
args.clear();
+ args.push_back("-s");
+ args.push_back(devices[p_device].id);
args.push_back("reverse");
- args.push_back("tcp:" + itos(port));
- args.push_back("tcp:" + itos(port));
+ args.push_back("tcp:" + itos(dbg_port));
+ args.push_back("tcp:" + itos(dbg_port));
err = OS::get_singleton()->execute(adb, args, true, NULL, NULL, &rv);
print_line("Reverse result: " + itos(rv));
@@ -3007,6 +3030,8 @@ public:
int fs_port = EditorSettings::get_singleton()->get("filesystem/file_server/port");
args.clear();
+ args.push_back("-s");
+ args.push_back(devices[p_device].id);
args.push_back("reverse");
args.push_back("tcp:" + itos(fs_port));
args.push_back("tcp:" + itos(fs_port));
@@ -3022,7 +3047,10 @@ public:
args.push_back("shell");
args.push_back("am");
args.push_back("start");
- args.push_back("--user 0");
+ if ((bool)EditorSettings::get_singleton()->get("export/android/force_system_user") && devices[p_device].release >= 17) { // Multi-user introduced in Android 17
+ args.push_back("--user");
+ args.push_back("0");
+ }
args.push_back("-a");
args.push_back("android.intent.action.MAIN");
args.push_back("-n");
@@ -3030,7 +3058,7 @@ public:
err = OS::get_singleton()->execute(adb, args, true, NULL, NULL, &rv);
if (err || rv != 0) {
- EditorNode::add_io_error("Could not execute ondevice.");
+ EditorNode::add_io_error("Could not execute on device.");
device_lock->unlock();
return ERR_CANT_CREATE;
}
@@ -3219,7 +3247,7 @@ public:
if (!found) {
- String appicon = GlobalConfig::get_singleton()->get("application/icon");
+ String appicon = ProjectSettings::get_singleton()->get("application/config/icon");
if (appicon != "" && appicon.ends_with(".png")) {
FileAccess *f = FileAccess::open(appicon, FileAccess::READ);
if (f) {
@@ -3527,6 +3555,12 @@ public:
return OK;
}
+ virtual void get_platform_features(List<String> *r_features) {
+
+ r_features->push_back("mobile");
+ r_features->push_back("Android");
+ }
+
EditorExportAndroid() {
Ref<Image> img = memnew(Image(_android_logo));
@@ -3566,6 +3600,7 @@ void register_android_exporter() {
EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING, "export/android/debug_keystore", PROPERTY_HINT_GLOBAL_FILE, "keystore"));
EDITOR_DEF("export/android/debug_keystore_user", "androiddebugkey");
EDITOR_DEF("export/android/debug_keystore_pass", "android");
+ EDITOR_DEF("export/android/force_system_user", false);
EDITOR_DEF("export/android/timestamping_authority_url", "");
EDITOR_DEF("export/android/use_remote_debug_over_adb", false);
diff --git a/platform/android/globals/global_defaults.cpp b/platform/android/globals/global_defaults.cpp
index f708ad5dd7..6bdc6b337c 100644
--- a/platform/android/globals/global_defaults.cpp
+++ b/platform/android/globals/global_defaults.cpp
@@ -28,7 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "global_defaults.h"
-#include "global_config.h"
+#include "project_settings.h"
void register_android_global_defaults() {
@@ -37,6 +37,6 @@ void register_android_global_defaults() {
GLOBAL_DEF("display.Android/driver","GLES2");
//GLOBAL_DEF("rasterizer.Android/trilinear_mipmap_filter",false);
- GlobalConfig::get_singleton()->set_custom_property_info("display.Android/driver",PropertyInfo(Variant::STRING,"display.Android/driver",PROPERTY_HINT_ENUM,"GLES2"));
+ ProjectSettings::get_singleton()->set_custom_property_info("display.Android/driver",PropertyInfo(Variant::STRING,"display.Android/driver",PROPERTY_HINT_ENUM,"GLES2"));
*/
}
diff --git a/platform/android/godot_android.cpp b/platform/android/godot_android.cpp
index 3a21f9212f..71db03049a 100644
--- a/platform/android/godot_android.cpp
+++ b/platform/android/godot_android.cpp
@@ -36,9 +36,9 @@
#include <GLES2/gl2.h>
#include "file_access_android.h"
-#include "global_config.h"
#include "main/main.h"
#include "os_android.h"
+#include "project_settings.h"
#include <android/log.h>
#include <android/sensor.h>
#include <android/window.h>
@@ -623,7 +623,7 @@ static void engine_handle_cmd(struct android_app *app, int32_t cmd) {
#else
Error err = Main::setup("apk", 0, NULL);
- String modules = GlobalConfig::get_singleton()->get("android/modules");
+ String modules = ProjectSettings::get_singleton()->get("android/modules");
Vector<String> mods = modules.split(",", false);
mods.push_back("GodotOS");
__android_log_print(ANDROID_LOG_INFO, "godot", "mod count: %i", mods.size());
@@ -859,7 +859,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_Godot_registerSingleton(JNIEnv
s->set_instance(env->NewGlobalRef(p_object));
jni_singletons[singname] = s;
- GlobalConfig::get_singleton()->add_singleton(GlobalConfig::Singleton(singname, s));
+ ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton(singname, s));
}
static Variant::Type get_jni_type(const String &p_type) {
@@ -926,7 +926,7 @@ JNIEXPORT jstring JNICALL Java_org_godotengine_godot_Godot_getGlobal(JNIEnv *env
String js = env->GetStringUTFChars(path, NULL);
- return env->NewStringUTF(GlobalConfig::get_singleton()->get(js).operator String().utf8().get_data());
+ return env->NewStringUTF(ProjectSettings::get_singleton()->get(js).operator String().utf8().get_data());
}
JNIEXPORT void JNICALL Java_org_godotengine_godot_Godot_registerMethod(JNIEnv *env, jobject obj, jstring sname, jstring name, jstring ret, jobjectArray args) {
diff --git a/platform/android/java/src/org/godotengine/godot/Godot.java b/platform/android/java/src/org/godotengine/godot/Godot.java
index 88928089b6..d620b2b9c4 100644
--- a/platform/android/java/src/org/godotengine/godot/Godot.java
+++ b/platform/android/java/src/org/godotengine/godot/Godot.java
@@ -273,7 +273,7 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
mView = new GodotView(getApplication(),io,use_gl2,use_32_bits, this);
layout.addView(mView,new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT));
- setKeepScreenOn(GodotLib.getGlobal("display/keep_screen_on").equals("True"));
+ setKeepScreenOn(GodotLib.getGlobal("display/driver/keep_screen_on").equals("True"));
edittext.setView(mView);
io.setEdit(edittext);
diff --git a/platform/android/java_glue.cpp b/platform/android/java_glue.cpp
index d4bd443689..0508989d2f 100644
--- a/platform/android/java_glue.cpp
+++ b/platform/android/java_glue.cpp
@@ -36,11 +36,11 @@
#include "dir_access_jandroid.h"
#include "file_access_android.h"
#include "file_access_jandroid.h"
-#include "global_config.h"
#include "java_class_wrapper.h"
#include "main/input_default.h"
#include "main/main.h"
#include "os_android.h"
+#include "project_settings.h"
#include "thread_jandroid.h"
#include <unistd.h>
@@ -883,7 +883,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_initialize(JNIEnv *en
__android_log_print(ANDROID_LOG_INFO, "godot", "*****SETUP OK");
//video driver is determined here, because once initialized, it can't be changed
- String vd = GlobalConfig::get_singleton()->get("display/driver");
+ String vd = ProjectSettings::get_singleton()->get("display/driver");
env->CallVoidMethod(_godot_instance, _on_video_init, (jboolean) true);
@@ -930,12 +930,12 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_back(JNIEnv *env, job
static void _initialize_java_modules() {
- if (!GlobalConfig::get_singleton()->has("android/modules")) {
+ if (!ProjectSettings::get_singleton()->has("android/modules")) {
print_line("ANDROID MODULES: Nothing to load, aborting");
return;
}
- String modules = GlobalConfig::get_singleton()->get("android/modules");
+ String modules = ProjectSettings::get_singleton()->get("android/modules");
modules = modules.strip_edges();
if (modules == String()) {
return;
@@ -1005,7 +1005,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_step(JNIEnv *env, job
// because of the way android forces you to do everything with threads
java_class_wrapper = memnew(JavaClassWrapper(_godot_instance));
- GlobalConfig::get_singleton()->add_singleton(GlobalConfig::Singleton("JavaClassWrapper", java_class_wrapper));
+ ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("JavaClassWrapper", java_class_wrapper));
_initialize_java_modules();
Main::setup2();
@@ -1504,8 +1504,8 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_singleton(JNIEnv *env
s->set_instance(env->NewGlobalRef(p_object));
jni_singletons[singname] = s;
- GlobalConfig::get_singleton()->add_singleton(GlobalConfig::Singleton(singname, s));
- GlobalConfig::get_singleton()->set(singname, s);
+ ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton(singname, s));
+ ProjectSettings::get_singleton()->set(singname, s);
}
static Variant::Type get_jni_type(const String &p_type) {
@@ -1578,7 +1578,7 @@ JNIEXPORT jstring JNICALL Java_org_godotengine_godot_GodotLib_getGlobal(JNIEnv *
String js = env->GetStringUTFChars(path, NULL);
- return env->NewStringUTF(GlobalConfig::get_singleton()->get(js).operator String().utf8().get_data());
+ return env->NewStringUTF(ProjectSettings::get_singleton()->get(js).operator String().utf8().get_data());
}
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_method(JNIEnv *env, jobject obj, jstring sname, jstring name, jstring ret, jobjectArray args) {
diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp
index 9010b9e7da..ad46ceb43f 100644
--- a/platform/android/os_android.cpp
+++ b/platform/android/os_android.cpp
@@ -29,8 +29,8 @@
/*************************************************************************/
#include "os_android.h"
-#include "core/global_config.h"
#include "core/io/file_access_buffered_fa.h"
+#include "core/project_settings.h"
#include "drivers/gles3/rasterizer_gles3.h"
#include "drivers/unix/dir_access_unix.h"
#include "drivers/unix/file_access_unix.h"
@@ -677,7 +677,7 @@ String OS_Android::get_data_dir() const {
}
return ".";
- //return GlobalConfig::get_singleton()->get_singleton_object("GodotOS")->call("get_data_dir");
+ //return ProjectSettings::get_singleton()->get_singleton_object("GodotOS")->call("get_data_dir");
}
void OS_Android::set_screen_orientation(ScreenOrientation p_orientation) {
@@ -741,6 +741,10 @@ String OS_Android::get_joy_guid(int p_device) const {
return input->get_joy_guid_remapped(p_device);
}
+bool OS_Android::_check_internal_feature_support(const String &p_feature) {
+ return p_feature == "mobile" || p_feature == "etc" || p_feature == "etc2"; //TODO support etc2 only if GLES3 driver is selected
+}
+
OS_Android::OS_Android(GFXInitFunc p_gfx_init_func, void *p_gfx_init_ud, OpenURIFunc p_open_uri_func, GetDataDirFunc p_get_data_dir_func, GetLocaleFunc p_get_locale_func, GetModelFunc p_get_model_func, GetScreenDPIFunc p_get_screen_dpi_func, ShowVirtualKeyboardFunc p_show_vk, HideVirtualKeyboardFunc p_hide_vk, SetScreenOrientationFunc p_screen_orient, GetUniqueIDFunc p_get_unique_id, GetSystemDirFunc p_get_sdir_func, VideoPlayFunc p_video_play_func, VideoIsPlayingFunc p_video_is_playing_func, VideoPauseFunc p_video_pause_func, VideoStopFunc p_video_stop_func, SetKeepScreenOnFunc p_set_keep_screen_on_func, AlertFunc p_alert_func, bool p_use_apk_expansion) {
use_apk_expansion = p_use_apk_expansion;
diff --git a/platform/android/os_android.h b/platform/android/os_android.h
index 897c71a7df..393bc68d8a 100644
--- a/platform/android/os_android.h
+++ b/platform/android/os_android.h
@@ -243,6 +243,7 @@ public:
virtual String get_joy_guid(int p_device) const;
void joy_connection_changed(int p_device, bool p_connected, String p_name);
+ virtual bool _check_internal_feature_support(const String &p_feature);
OS_Android(GFXInitFunc p_gfx_init_func, void *p_gfx_init_ud, OpenURIFunc p_open_uri_func, GetDataDirFunc p_get_data_dir_func, GetLocaleFunc p_get_locale_func, GetModelFunc p_get_model_func, GetScreenDPIFunc p_get_screen_dpi_func, ShowVirtualKeyboardFunc p_show_vk, HideVirtualKeyboardFunc p_hide_vk, SetScreenOrientationFunc p_screen_orient, GetUniqueIDFunc p_get_unique_id, GetSystemDirFunc p_get_sdir_func, VideoPlayFunc p_video_play_func, VideoIsPlayingFunc p_video_is_playing_func, VideoPauseFunc p_video_pause_func, VideoStopFunc p_video_stop_func, SetKeepScreenOnFunc p_set_keep_screen_on_func, AlertFunc p_alert_func, bool p_use_apk_expansion);
~OS_Android();
};
diff --git a/platform/haiku/audio_driver_media_kit.cpp b/platform/haiku/audio_driver_media_kit.cpp
index 9c4f6d3aba..93351e0799 100644
--- a/platform/haiku/audio_driver_media_kit.cpp
+++ b/platform/haiku/audio_driver_media_kit.cpp
@@ -31,7 +31,7 @@
#ifdef MEDIA_KIT_ENABLED
-#include "global_config.h"
+#include "project_settings.h"
int32_t *AudioDriverMediaKit::samples_in = NULL;
diff --git a/platform/haiku/detect.py b/platform/haiku/detect.py
index 54e227cd19..c0e003a3d2 100644
--- a/platform/haiku/detect.py
+++ b/platform/haiku/detect.py
@@ -11,57 +11,58 @@ def get_name():
def can_build():
- if (os.name != "posix"):
- return False
- if (sys.platform == "darwin"):
+ if (os.name != "posix" or sys.platform == "darwin"):
return False
return True
def get_opts():
+
return [
('debug_release', 'Add debug symbols to release version', 'no')
]
def get_flags():
+
return [
]
def configure(env):
- is64 = sys.maxsize > 2**32
-
- if (env["bits"] == "default"):
- if (is64):
- env["bits"] = "64"
- else:
- env["bits"] = "32"
-
- env.Append(CPPPATH=['#platform/haiku'])
- env["CC"] = "gcc-x86"
- env["CXX"] = "g++-x86"
+ ## Build type
if (env["target"] == "release"):
if (env["debug_release"] == "yes"):
- env.Append(CCFLAGS=['-g2'])
+ env.Prepend(CCFLAGS=['-g2'])
else:
- env.Append(CCFLAGS=['-O3', '-ffast-math'])
+ env.Prepend(CCFLAGS=['-O3', '-ffast-math'])
+
elif (env["target"] == "release_debug"):
- env.Append(CCFLAGS=['-O2', '-ffast-math', '-DDEBUG_ENABLED'])
+ env.Prepend(CCFLAGS=['-O2', '-ffast-math', '-DDEBUG_ENABLED'])
+
elif (env["target"] == "debug"):
- env.Append(CCFLAGS=['-g2', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED'])
+ env.Prepend(CCFLAGS=['-g2', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED'])
+
+ ## Architecture
+
+ is64 = sys.maxsize > 2**32
+ if (env["bits"] == "default"):
+ env["bits"] = "64" if is64 else "32"
+
+ ## Compiler configuration
+ env["CC"] = "gcc-x86"
+ env["CXX"] = "g++-x86"
+
+ ## Flags
+
+ env.Append(CPPPATH=['#platform/haiku'])
+ env.Append(CPPFLAGS=['-DUNIX_ENABLED', '-DOPENGL_ENABLED', '-DGLES2_ENABLED', '-DGLES_OVER_GL'])
+ env.Append(CPPFLAGS=['-DMEDIA_KIT_ENABLED'])
# env.Append(CCFLAGS=['-DFREETYPE_ENABLED'])
env.Append(CPPFLAGS=['-DPTHREAD_NO_RENAME']) # TODO: enable when we have pthread_setname_np
- env.Append(CPPFLAGS=['-DOPENGL_ENABLED', '-DMEDIA_KIT_ENABLED'])
- env.Append(CPPFLAGS=['-DUNIX_ENABLED', '-DGLES2_ENABLED', '-DGLES_OVER_GL'])
env.Append(LIBS=['be', 'game', 'media', 'network', 'bnetapi', 'z', 'GL'])
-
- import methods
- env.Append(BUILDERS={'GLSL120': env.Builder(action=methods.build_legacygl_headers, suffix='glsl.h', src_suffix='.glsl')})
- env.Append(BUILDERS={'GLSL': env.Builder(action=methods.build_glsl_headers, suffix='glsl.h', src_suffix='.glsl')})
- env.Append(BUILDERS={'GLSL120GLES': env.Builder(action=methods.build_gles2_headers, suffix='glsl.h', src_suffix='.glsl')})
diff --git a/platform/haiku/os_haiku.cpp b/platform/haiku/os_haiku.cpp
index 3131f2bf1e..e897d4c385 100644
--- a/platform/haiku/os_haiku.cpp
+++ b/platform/haiku/os_haiku.cpp
@@ -331,3 +331,8 @@ void OS_Haiku::get_fullscreen_mode_list(List<VideoMode> *p_list, int p_screen) c
String OS_Haiku::get_executable_path() const {
return OS::get_executable_path();
}
+
+bool OS_Haiku::_check_internal_feature_support(const String &p_feature) {
+
+ return p_feature == "pc" || p_feature == "s3tc";
+}
diff --git a/platform/haiku/os_haiku.h b/platform/haiku/os_haiku.h
index 83e44734a6..256c9eecf7 100644
--- a/platform/haiku/os_haiku.h
+++ b/platform/haiku/os_haiku.h
@@ -120,6 +120,8 @@ public:
virtual PowerState get_power_state();
virtual int get_power_seconds_left();
virtual int get_power_percent_left();
+
+ virtual bool _check_internal_feature_support(const String &p_feature);
};
#endif
diff --git a/platform/iphone/SCsub b/platform/iphone/SCsub
index 466b8241de..998d0a3f0d 100644
--- a/platform/iphone/SCsub
+++ b/platform/iphone/SCsub
@@ -17,17 +17,8 @@ iphone_lib = [
'ios.mm',
]
-# env.Depends('#core/math/vector3.h', 'vector3_psp.h')
-
-#iphone_lib = env.Library('iphone', iphone_lib)
-
env_ios = env.Clone()
-
-if env['ios_gles22_override'] == "yes":
- env_ios.Append(CPPFLAGS=['-DGLES2_OVERRIDE'])
-
-
obj = env_ios.Object('godot_iphone.cpp')
prog = None
diff --git a/platform/iphone/app_delegate.mm b/platform/iphone/app_delegate.mm
index 1f81f0f86e..da6dfcf53f 100644
--- a/platform/iphone/app_delegate.mm
+++ b/platform/iphone/app_delegate.mm
@@ -29,11 +29,11 @@
/*************************************************************************/
#import "app_delegate.h"
-#include "core/global_config.h"
+#include "audio_driver_iphone.h"
+#include "core/project_settings.h"
#import "gl_view.h"
#include "main/main.h"
#include "os_iphone.h"
-#include "audio_driver_iphone.h"
#ifdef MODULE_FACEBOOKSCORER_IOS_ENABLED
#include "modules/FacebookScorer_ios/FacebookScorer.h"
@@ -449,14 +449,14 @@ static int frame_count = 0;
NSString *str = (NSString *)value;
String uval = String::utf8([str UTF8String]);
- GlobalConfig::get_singleton()->set("Info.plist/" + ukey, uval);
+ ProjectSettings::get_singleton()->set("Info.plist/" + ukey, uval);
} else if ([value isKindOfClass:[NSNumber class]]) {
NSNumber *n = (NSNumber *)value;
double dval = [n doubleValue];
- GlobalConfig::get_singleton()->set("Info.plist/" + ukey, dval);
+ ProjectSettings::get_singleton()->set("Info.plist/" + ukey, dval);
};
// do stuff
}
@@ -615,7 +615,7 @@ static int frame_count = 0;
view_controller.view = glView;
window.rootViewController = view_controller;
- _set_keep_screen_on(bool(GLOBAL_DEF("display/keep_screen_on", true)) ? YES : NO);
+ _set_keep_screen_on(bool(GLOBAL_DEF("display/window/keep_screen_on", true)) ? YES : NO);
glView.useCADisplayLink =
bool(GLOBAL_DEF("display.iOS/use_cadisplaylink", true)) ? YES : NO;
printf("cadisaplylink: %d", glView.useCADisplayLink);
@@ -645,10 +645,10 @@ static int frame_count = 0;
#ifdef MODULE_GAME_ANALYTICS_ENABLED
printf("********************* didFinishLaunchingWithOptions\n");
- if (!GlobalConfig::get_singleton()->has("mobileapptracker/advertiser_id")) {
+ if (!ProjectSettings::get_singleton()->has("mobileapptracker/advertiser_id")) {
return;
}
- if (!GlobalConfig::get_singleton()->has("mobileapptracker/conversion_key")) {
+ if (!ProjectSettings::get_singleton()->has("mobileapptracker/conversion_key")) {
return;
}
@@ -673,7 +673,6 @@ static int frame_count = 0;
isAdvertisingTrackingEnabled]];
#endif
-
};
- (void)applicationWillTerminate:(UIApplication *)application {
@@ -737,7 +736,7 @@ static int frame_count = 0;
};
// Fixed audio can not resume if it is interrupted cause by an incoming phone call
- if(AudioDriverIphone::get_singleton() != NULL)
+ if (AudioDriverIphone::get_singleton() != NULL)
AudioDriverIphone::get_singleton()->start();
}
diff --git a/platform/iphone/detect.py b/platform/iphone/detect.py
index c20d8e90f4..1d802ff288 100644
--- a/platform/iphone/detect.py
+++ b/platform/iphone/detect.py
@@ -1,4 +1,5 @@
import os
+import string
import sys
@@ -12,8 +13,6 @@ def get_name():
def can_build():
- import sys
- import os
if sys.platform == 'darwin' or os.environ.has_key("OSXCROSS_IOS"):
return True
@@ -23,13 +22,12 @@ def can_build():
def get_opts():
return [
- ('IPHONEPLATFORM', 'name of the iphone platform', 'iPhoneOS'),
- ('IPHONEPATH', 'the path to iphone toolchain', '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain'),
- ('IPHONESDK', 'path to the iphone SDK', '/Applications/Xcode.app/Contents/Developer/Platforms/${IPHONEPLATFORM}.platform/Developer/SDKs/${IPHONEPLATFORM}.sdk/'),
+ ('IPHONEPLATFORM', 'Name of the iPhone platform', 'iPhoneOS'),
+ ('IPHONEPATH', 'Path to iPhone toolchain', '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain'),
+ ('IPHONESDK', 'Path to the iPhone SDK', '/Applications/Xcode.app/Contents/Developer/Platforms/${IPHONEPLATFORM}.platform/Developer/SDKs/${IPHONEPLATFORM}.sdk/'),
('game_center', 'Support for game center', 'yes'),
('store_kit', 'Support for in-app store', 'yes'),
('icloud', 'Support for iCloud', 'yes'),
- ('ios_gles22_override', 'Force GLES2.0 on iOS', 'yes'),
('ios_exceptions', 'Enable exceptions', 'no'),
('ios_triple', 'Triple for ios toolchain', ''),
('ios_sim', 'Build simulator binary', 'no'),
@@ -45,95 +43,92 @@ def get_flags():
def configure(env):
- env.Append(CPPPATH=['#platform/iphone'])
+ ## Build type
- env['ENV']['PATH'] = env['IPHONEPATH'] + "/Developer/usr/bin/:" + env['ENV']['PATH']
+ if (env["target"].startswith("release")):
+ env.Append(CPPFLAGS=['-DNDEBUG', '-DNS_BLOCK_ASSERTIONS=1'])
+ env.Append(CPPFLAGS=['-O2', '-flto', '-ftree-vectorize', '-fomit-frame-pointer', '-ffast-math', '-funsafe-math-optimizations'])
+ env.Append(LINKFLAGS=['-O2', '-flto'])
- env['CC'] = '$IPHONEPATH/usr/bin/${ios_triple}clang'
- env['CXX'] = '$IPHONEPATH/usr/bin/${ios_triple}clang++'
- env['AR'] = '$IPHONEPATH/usr/bin/${ios_triple}ar'
- env['RANLIB'] = '$IPHONEPATH/usr/bin/${ios_triple}ranlib'
+ if env["target"] == "release_debug":
+ env.Append(CPPFLAGS=['-DDEBUG_ENABLED'])
+
+ elif (env["target"] == "debug"):
+ env.Append(CPPFLAGS=['-D_DEBUG', '-DDEBUG=1', '-gdwarf-2', '-O0', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED'])
+
+ ## Architecture
- import string
if (env["ios_sim"] == "yes" or env["arch"] == "x86"): # i386, simulator
env["arch"] = "x86"
env["bits"] = "32"
- env.Append(CCFLAGS=string.split('-arch i386 -fobjc-abi-version=2 -fobjc-legacy-dispatch -fmessage-length=0 -fpascal-strings -fblocks -fasm-blocks -D__IPHONE_OS_VERSION_MIN_REQUIRED=40100 -isysroot $IPHONESDK -mios-simulator-version-min=4.3 -DCUSTOM_MATRIX_TRANSFORM_H=\\\"build/iphone/matrix4_iphone.h\\\" -DCUSTOM_VECTOR3_TRANSFORM_H=\\\"build/iphone/vector3_iphone.h\\\"'))
elif (env["arch"] == "arm" or env["arch"] == "arm32" or env["arch"] == "armv7" or env["bits"] == "32"): # arm
env["arch"] = "arm"
env["bits"] = "32"
- env.Append(CCFLAGS=string.split('-fno-objc-arc -arch armv7 -fmessage-length=0 -fno-strict-aliasing -fdiagnostics-print-source-range-info -fdiagnostics-show-category=id -fdiagnostics-parseable-fixits -fpascal-strings -fblocks -isysroot $IPHONESDK -fvisibility=hidden -mthumb "-DIBOutlet=__attribute__((iboutlet))" "-DIBOutletCollection(ClassName)=__attribute__((iboutletcollection(ClassName)))" "-DIBAction=void)__attribute__((ibaction)" -miphoneos-version-min=9.0 -MMD -MT dependencies'))
else: # armv64
env["arch"] = "arm64"
env["bits"] = "64"
+
+ ## Compiler configuration
+
+ env['ENV']['PATH'] = env['IPHONEPATH'] + "/Developer/usr/bin/:" + env['ENV']['PATH']
+
+ env['CC'] = '$IPHONEPATH/usr/bin/${ios_triple}clang'
+ env['CXX'] = '$IPHONEPATH/usr/bin/${ios_triple}clang++'
+ env['AR'] = '$IPHONEPATH/usr/bin/${ios_triple}ar'
+ env['RANLIB'] = '$IPHONEPATH/usr/bin/${ios_triple}ranlib'
+ env['S_compiler'] = '$IPHONEPATH/Developer/usr/bin/gcc'
+
+ ## Compile flags
+
+ if (env["arch"] == "x86"):
+ env['IPHONEPLATFORM'] = 'iPhoneSimulator'
+ env['ENV']['MACOSX_DEPLOYMENT_TARGET'] = '10.6'
+ env.Append(CCFLAGS=string.split('-arch i386 -fobjc-abi-version=2 -fobjc-legacy-dispatch -fmessage-length=0 -fpascal-strings -fblocks -fasm-blocks -D__IPHONE_OS_VERSION_MIN_REQUIRED=40100 -isysroot $IPHONESDK -mios-simulator-version-min=4.3 -DCUSTOM_MATRIX_TRANSFORM_H=\\\"build/iphone/matrix4_iphone.h\\\" -DCUSTOM_VECTOR3_TRANSFORM_H=\\\"build/iphone/vector3_iphone.h\\\"'))
+ elif (env["arch"] == "arm"):
+ env.Append(CCFLAGS=string.split('-fno-objc-arc -arch armv7 -fmessage-length=0 -fno-strict-aliasing -fdiagnostics-print-source-range-info -fdiagnostics-show-category=id -fdiagnostics-parseable-fixits -fpascal-strings -fblocks -isysroot $IPHONESDK -fvisibility=hidden -mthumb "-DIBOutlet=__attribute__((iboutlet))" "-DIBOutletCollection(ClassName)=__attribute__((iboutletcollection(ClassName)))" "-DIBAction=void)__attribute__((ibaction)" -miphoneos-version-min=9.0 -MMD -MT dependencies'))
+ elif (env["arch"] == "arm64"):
env.Append(CCFLAGS=string.split('-fno-objc-arc -arch arm64 -fmessage-length=0 -fno-strict-aliasing -fdiagnostics-print-source-range-info -fdiagnostics-show-category=id -fdiagnostics-parseable-fixits -fpascal-strings -fblocks -fvisibility=hidden -MMD -MT dependencies -miphoneos-version-min=9.0 -isysroot $IPHONESDK'))
env.Append(CPPFLAGS=['-DNEED_LONG_INT'])
env.Append(CPPFLAGS=['-DLIBYUV_DISABLE_NEON'])
+ if env['ios_exceptions'] == 'yes':
+ env.Append(CPPFLAGS=['-fexceptions'])
+ else:
+ env.Append(CPPFLAGS=['-fno-exceptions'])
+
+ ## Link flags
+
if (env["arch"] == "x86"):
- env['IPHONEPLATFORM'] = 'iPhoneSimulator'
env.Append(LINKFLAGS=['-arch', 'i386', '-mios-simulator-version-min=4.3',
'-isysroot', '$IPHONESDK',
- #'-mmacosx-version-min=10.6',
'-Xlinker',
'-objc_abi_version',
'-Xlinker', '2',
- '-framework', 'AudioToolbox',
- '-framework', 'AVFoundation',
- '-framework', 'CoreAudio',
- '-framework', 'CoreGraphics',
- '-framework', 'CoreMedia',
- '-framework', 'CoreMotion',
- '-framework', 'Foundation',
- '-framework', 'Security',
- '-framework', 'UIKit',
- '-framework', 'MediaPlayer',
- '-framework', 'OpenGLES',
- '-framework', 'QuartzCore',
- '-framework', 'SystemConfiguration',
- '-framework', 'GameController',
'-F$IPHONESDK',
])
- elif (env["arch"] == "arm64"):
- env.Append(LINKFLAGS=['-arch', 'arm64', '-Wl,-dead_strip', '-miphoneos-version-min=9.0',
- '-isysroot', '$IPHONESDK',
- #'-stdlib=libc++',
- '-framework', 'Foundation',
- '-framework', 'UIKit',
- '-framework', 'CoreGraphics',
- '-framework', 'OpenGLES',
- '-framework', 'QuartzCore',
- '-framework', 'CoreAudio',
- '-framework', 'AudioToolbox',
- '-framework', 'SystemConfiguration',
- '-framework', 'Security',
- #'-framework', 'AdSupport',
- '-framework', 'MediaPlayer',
- '-framework', 'AVFoundation',
- '-framework', 'CoreMedia',
- '-framework', 'CoreMotion',
- '-framework', 'GameController',
- ])
- else:
- env.Append(LINKFLAGS=['-arch', 'armv7', '-Wl,-dead_strip', '-miphoneos-version-min=9.0',
- '-isysroot', '$IPHONESDK',
- '-framework', 'Foundation',
- '-framework', 'UIKit',
- '-framework', 'CoreGraphics',
- '-framework', 'OpenGLES',
- '-framework', 'QuartzCore',
- '-framework', 'CoreAudio',
- '-framework', 'AudioToolbox',
- '-framework', 'SystemConfiguration',
- '-framework', 'Security',
- #'-framework', 'AdSupport',
- '-framework', 'MediaPlayer',
- '-framework', 'AVFoundation',
- '-framework', 'CoreMedia',
- '-framework', 'CoreMotion',
- '-framework', 'GameController',
- ])
-
+ elif (env["arch"] == "arm"):
+ env.Append(LINKFLAGS=['-arch', 'armv7', '-Wl,-dead_strip', '-miphoneos-version-min=9.0'])
+ if (env["arch"] == "arm64"):
+ env.Append(LINKFLAGS=['-arch', 'arm64', '-Wl,-dead_strip', '-miphoneos-version-min=9.0'])
+
+ env.Append(LINKFLAGS=['-isysroot', '$IPHONESDK',
+ '-framework', 'AudioToolbox',
+ '-framework', 'AVFoundation',
+ '-framework', 'CoreAudio',
+ '-framework', 'CoreGraphics',
+ '-framework', 'CoreMedia',
+ '-framework', 'CoreMotion',
+ '-framework', 'Foundation',
+ '-framework', 'GameController',
+ '-framework', 'MediaPlayer',
+ '-framework', 'OpenGLES',
+ '-framework', 'QuartzCore',
+ '-framework', 'Security',
+ '-framework', 'SystemConfiguration',
+ '-framework', 'UIKit',
+ ])
+
+ # Feature options
if env['game_center'] == 'yes':
env.Append(CPPFLAGS=['-DGAME_CENTER_ENABLED'])
env.Append(LINKFLAGS=['-framework', 'GameKit'])
@@ -145,45 +140,20 @@ def configure(env):
if env['icloud'] == 'yes':
env.Append(CPPFLAGS=['-DICLOUD_ENABLED'])
- env.Append(CPPPATH=['$IPHONESDK/usr/include', '$IPHONESDK/System/Library/Frameworks/OpenGLES.framework/Headers', '$IPHONESDK/System/Library/Frameworks/AudioUnit.framework/Headers'])
+ env.Append(CPPPATH=['$IPHONESDK/usr/include',
+ '$IPHONESDK/System/Library/Frameworks/OpenGLES.framework/Headers',
+ '$IPHONESDK/System/Library/Frameworks/AudioUnit.framework/Headers',
+ ])
- if (env["target"].startswith("release")):
-
- env.Append(CPPFLAGS=['-DNDEBUG', '-DNS_BLOCK_ASSERTIONS=1'])
- env.Append(CPPFLAGS=['-O2', '-flto', '-ftree-vectorize', '-fomit-frame-pointer', '-ffast-math', '-funsafe-math-optimizations'])
- env.Append(LINKFLAGS=['-O2', '-flto'])
-
- if env["target"] == "release_debug":
- env.Append(CPPFLAGS=['-DDEBUG_ENABLED'])
-
- elif (env["target"] == "debug"):
-
- env.Append(CPPFLAGS=['-D_DEBUG', '-DDEBUG=1', '-gdwarf-2', '-O0', '-DDEBUG_ENABLED'])
- env.Append(CPPFLAGS=['-DDEBUG_MEMORY_ENABLED'])
-
- if (env["ios_sim"] == "yes"): # TODO: Check if needed?
- env['ENV']['MACOSX_DEPLOYMENT_TARGET'] = '10.6'
env['ENV']['CODESIGN_ALLOCATE'] = '/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate'
+
+ env.Append(CPPPATH=['#platform/iphone'])
env.Append(CPPFLAGS=['-DIPHONE_ENABLED', '-DUNIX_ENABLED', '-DGLES2_ENABLED', '-DMPC_FIXED_POINT'])
# TODO: Move that to opus module's config
if("module_opus_enabled" in env and env["module_opus_enabled"] != "no"):
env.opus_fixed_point = "yes"
- if env["arch"] == "x86":
- pass
- elif(env["arch"] == "arm64"):
- env.Append(CFLAGS=["-DOPUS_ARM64_OPT"])
- else:
+ if (env["arch"] == "arm"):
env.Append(CFLAGS=["-DOPUS_ARM_OPT"])
-
- if env['ios_exceptions'] == 'yes':
- env.Append(CPPFLAGS=['-fexceptions'])
- else:
- env.Append(CPPFLAGS=['-fno-exceptions'])
- # env['neon_enabled']=True
- env['S_compiler'] = '$IPHONEPATH/Developer/usr/bin/gcc'
-
- import methods
- env.Append(BUILDERS={'GLSL120': env.Builder(action=methods.build_legacygl_headers, suffix='glsl.h', src_suffix='.glsl')})
- env.Append(BUILDERS={'GLSL': env.Builder(action=methods.build_glsl_headers, suffix='glsl.h', src_suffix='.glsl')})
- env.Append(BUILDERS={'GLSL120GLES': env.Builder(action=methods.build_gles2_headers, suffix='glsl.h', src_suffix='.glsl')})
+ elif (env["arch"] == "arm64"):
+ env.Append(CFLAGS=["-DOPUS_ARM64_OPT"])
diff --git a/platform/iphone/export/export.cpp b/platform/iphone/export/export.cpp
new file mode 100644
index 0000000000..6ae2a0692d
--- /dev/null
+++ b/platform/iphone/export/export.cpp
@@ -0,0 +1,366 @@
+/*************************************************************************/
+/* export.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#include "export.h"
+#include "editor/editor_export.h"
+#include "editor/editor_node.h"
+#include "editor/editor_settings.h"
+#include "io/marshalls.h"
+#include "io/resource_saver.h"
+#include "io/zip_io.h"
+#include "os/file_access.h"
+#include "os/os.h"
+#include "platform/osx/logo.gen.h"
+#include "project_settings.h"
+#include "string.h"
+#include "version.h"
+
+#include <sys/stat.h>
+
+class EditorExportPlatformIOS : public EditorExportPlatform {
+
+ GDCLASS(EditorExportPlatformIOS, EditorExportPlatform);
+
+ int version_code;
+
+ Ref<ImageTexture> logo;
+
+ void _fix_config_file(const Ref<EditorExportPreset> &p_preset, Vector<uint8_t> &pfile, const String &p_name, const String &p_binary);
+
+protected:
+ virtual void get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features);
+ virtual void get_export_options(List<ExportOption> *r_options);
+
+public:
+ virtual String get_name() const { return "iOS"; }
+ virtual String get_os_name() const { return "iOS"; }
+ virtual Ref<Texture> get_logo() const { return logo; }
+
+ virtual String get_binary_extension() const { return "xcodeproj"; }
+ virtual Error export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0);
+
+ virtual bool can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const;
+
+ virtual void get_platform_features(List<String> *r_features) {
+
+ r_features->push_back("mobile");
+ r_features->push_back("iOS");
+ }
+
+ EditorExportPlatformIOS();
+ ~EditorExportPlatformIOS();
+};
+
+void EditorExportPlatformIOS::get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) {
+
+ if (p_preset->get("texture_format/s3tc")) {
+ r_features->push_back("s3tc");
+ }
+ if (p_preset->get("texture_format/etc")) {
+ r_features->push_back("etc");
+ }
+ if (p_preset->get("texture_format/etc2")) {
+ r_features->push_back("etc2");
+ }
+}
+
+void EditorExportPlatformIOS::get_export_options(List<ExportOption> *r_options) {
+
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_package/debug", PROPERTY_HINT_GLOBAL_FILE, "zip"), ""));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_package/release", PROPERTY_HINT_GLOBAL_FILE, "zip"), ""));
+
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/name"), ""));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/info"), "Made with Godot Engine"));
+ // r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/icon", PROPERTY_HINT_FILE, "png"), ""));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/identifier"), "org.godotengine.iosgame"));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/signature"), "godotiosgame"));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/short_version"), "1.0"));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/version"), "1.0"));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/copyright"), ""));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "application/bits_mode", PROPERTY_HINT_ENUM, "Fat (32 & 64 bits),64 bits,32 bits"), 1));
+
+ r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/s3tc"), false));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/etc"), false));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/etc2"), true));
+
+ /* probably need some more info */
+}
+
+void EditorExportPlatformIOS::_fix_config_file(const Ref<EditorExportPreset> &p_preset, Vector<uint8_t> &pfile, const String &p_name, const String &p_binary) {
+
+ String str;
+ String strnew;
+ str.parse_utf8((const char *)pfile.ptr(), pfile.size());
+ Vector<String> lines = str.split("\n");
+ for (int i = 0; i < lines.size(); i++) {
+ if (lines[i].find("$binary") != -1) {
+ strnew += lines[i].replace("$binary", p_binary) + "\n";
+ } else if (lines[i].find("$name") != -1) {
+ strnew += lines[i].replace("$name", p_name) + "\n";
+ } else if (lines[i].find("$info") != -1) {
+ strnew += lines[i].replace("$info", p_preset->get("application/info")) + "\n";
+ } else if (lines[i].find("$identifier") != -1) {
+ strnew += lines[i].replace("$identifier", p_preset->get("application/identifier")) + "\n";
+ } else if (lines[i].find("$short_version") != -1) {
+ strnew += lines[i].replace("$short_version", p_preset->get("application/short_version")) + "\n";
+ } else if (lines[i].find("$version") != -1) {
+ strnew += lines[i].replace("$version", p_preset->get("application/version")) + "\n";
+ } else if (lines[i].find("$signature") != -1) {
+ strnew += lines[i].replace("$signature", p_preset->get("application/signature")) + "\n";
+ } else if (lines[i].find("$copyright") != -1) {
+ strnew += lines[i].replace("$copyright", p_preset->get("application/copyright")) + "\n";
+ } else {
+ strnew += lines[i] + "\n";
+ }
+ }
+
+ // !BAS! I'm assuming the 9 in the original code was a typo. I've added -1 or else it seems to also be adding our terminating zero...
+ // should apply the same fix in our OSX export.
+ CharString cs = strnew.utf8();
+ pfile.resize(cs.size() - 1);
+ for (int i = 0; i < cs.size() - 1; i++) {
+ pfile[i] = cs[i];
+ }
+}
+
+Error EditorExportPlatformIOS::export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags) {
+ String src_pkg_name;
+ String dest_dir = p_path.get_base_dir() + "/";
+ String binary_name = p_path.get_file().get_basename();
+
+ EditorProgress ep("export", "Exporting for iOS", 3);
+
+ if (p_debug)
+ src_pkg_name = p_preset->get("custom_package/debug");
+ else
+ src_pkg_name = p_preset->get("custom_package/release");
+
+ if (src_pkg_name == "") {
+ String err;
+ src_pkg_name = find_export_template("iphone.zip", &err);
+ if (src_pkg_name == "") {
+ EditorNode::add_io_error(err);
+ return ERR_FILE_NOT_FOUND;
+ }
+ }
+
+ FileAccess *src_f = NULL;
+ zlib_filefunc_def io = zipio_create_io_from_file(&src_f);
+
+ ep.step("Creating app", 0);
+
+ unzFile src_pkg_zip = unzOpen2(src_pkg_name.utf8().get_data(), &io);
+ if (!src_pkg_zip) {
+
+ EditorNode::add_io_error("Could not find template app to export:\n" + src_pkg_name);
+ return ERR_FILE_NOT_FOUND;
+ }
+
+ ERR_FAIL_COND_V(!src_pkg_zip, ERR_CANT_OPEN);
+ int ret = unzGoToFirstFile(src_pkg_zip);
+
+ String binary_to_use = "godot.iphone." + String(p_debug ? "debug" : "release") + ".";
+ int bits_mode = p_preset->get("application/bits_mode");
+ binary_to_use += String(bits_mode == 0 ? "fat" : bits_mode == 1 ? "arm64" : "armv7");
+
+ print_line("binary: " + binary_to_use);
+ String pkg_name;
+ if (p_preset->get("application/name") != "")
+ pkg_name = p_preset->get("application/name"); // app_name
+ else if (String(ProjectSettings::get_singleton()->get("application/config/name")) != "")
+ pkg_name = String(ProjectSettings::get_singleton()->get("application/config/name"));
+ else
+ pkg_name = "Unnamed";
+
+ DirAccess *tmp_app_path = DirAccess::create_for_path(dest_dir);
+ ERR_FAIL_COND_V(!tmp_app_path, ERR_CANT_CREATE)
+
+ /* Now process our template */
+ bool found_binary = false;
+ int total_size = 0;
+
+ while (ret == UNZ_OK) {
+ bool is_execute = false;
+
+ //get filename
+ unz_file_info info;
+ char fname[16384];
+ ret = unzGetCurrentFileInfo(src_pkg_zip, &info, fname, 16384, NULL, 0, NULL, 0);
+
+ String file = fname;
+
+ print_line("READ: " + file);
+ Vector<uint8_t> data;
+ data.resize(info.uncompressed_size);
+
+ //read
+ unzOpenCurrentFile(src_pkg_zip);
+ unzReadCurrentFile(src_pkg_zip, data.ptr(), data.size());
+ unzCloseCurrentFile(src_pkg_zip);
+
+ //write
+
+ file = file.replace_first("iphone/", "");
+
+ if (file == "godot_ios.xcodeproj/project.pbxproj") {
+ print_line("parse pbxproj");
+ _fix_config_file(p_preset, data, pkg_name, binary_name);
+ } else if (file == "godot_ios/godot_ios-Info.plist") {
+ print_line("parse plist");
+ _fix_config_file(p_preset, data, pkg_name, binary_name);
+ } else if (file.begins_with("godot.iphone")) {
+ if (file != binary_to_use) {
+ ret = unzGoToNextFile(src_pkg_zip);
+ continue; //ignore!
+ }
+ found_binary = true;
+ is_execute = true;
+ file = "godot_ios.iphone";
+ }
+
+ ///@TODO need to parse logo files
+
+ if (data.size() > 0) {
+ file = file.replace("godot_ios", binary_name);
+
+ print_line("ADDING: " + file + " size: " + itos(data.size()));
+ total_size += data.size();
+
+ /* write it into our folder structure */
+ file = dest_dir + file;
+
+ /* make sure this folder exists */
+ String dir_name = file.get_base_dir();
+ if (!tmp_app_path->dir_exists(dir_name)) {
+ print_line("Creating " + dir_name);
+ Error dir_err = tmp_app_path->make_dir_recursive(dir_name);
+ if (dir_err) {
+ ERR_PRINTS("Can't create '" + dir_name + "'.");
+ unzClose(src_pkg_zip);
+ return ERR_CANT_CREATE;
+ }
+ }
+
+ /* write the file */
+ FileAccess *f = FileAccess::open(file, FileAccess::WRITE);
+ if (!f) {
+ ERR_PRINTS("Can't write '" + file + "'.");
+ unzClose(src_pkg_zip);
+ return ERR_CANT_CREATE;
+ };
+ f->store_buffer(data.ptr(), data.size());
+ f->close();
+ memdelete(f);
+
+#ifdef OSX_ENABLED
+ if (is_execute) {
+ // we need execute rights on this file
+ chmod(file.utf8().get_data(), 0755);
+ }
+#endif
+ }
+
+ ret = unzGoToNextFile(src_pkg_zip);
+ }
+
+ /* we're done with our source zip */
+ unzClose(src_pkg_zip);
+
+ if (!found_binary) {
+ ERR_PRINTS("Requested template binary '" + binary_to_use + "' not found. It might be missing from your template archive.");
+ unzClose(src_pkg_zip);
+ return ERR_FILE_NOT_FOUND;
+ }
+
+ ep.step("Making PKG", 1);
+
+ String pack_path = dest_dir + binary_name + ".pck";
+ Error err = save_pack(p_preset, pack_path);
+
+ if (err) {
+ return err;
+ }
+
+#ifdef OSX_ENABLED
+ /* and open up xcode with our new project.... */
+ List<String> args;
+ args.push_back(p_path);
+ err = OS::get_singleton()->execute("/usr/bin/open", args, false);
+ ERR_FAIL_COND_V(err, err);
+
+#endif
+
+ return OK;
+}
+
+bool EditorExportPlatformIOS::can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const {
+
+ bool valid = true;
+ String err;
+
+ if (!exists_export_template("iphone.zip", &err)) {
+ valid = false;
+ }
+
+ if (p_preset->get("custom_package/debug") != "" && !FileAccess::exists(p_preset->get("custom_package/debug"))) {
+ valid = false;
+ err += "Custom debug package not found.\n";
+ }
+
+ if (p_preset->get("custom_package/release") != "" && !FileAccess::exists(p_preset->get("custom_package/release"))) {
+ valid = false;
+ err += "Custom release package not found.\n";
+ }
+
+ if (!err.empty())
+ r_error = err;
+
+ return valid;
+}
+
+EditorExportPlatformIOS::EditorExportPlatformIOS() {
+
+ ///@TODO need to create the correct logo
+ // Ref<Image> img = memnew(Image(_iphone_logo));
+ Ref<Image> img = memnew(Image(_osx_logo));
+ logo.instance();
+ logo->create_from_image(img);
+}
+
+EditorExportPlatformIOS::~EditorExportPlatformIOS() {
+}
+
+void register_iphone_exporter() {
+
+ Ref<EditorExportPlatformIOS> platform;
+ platform.instance();
+
+ EditorExport::get_singleton()->add_export_platform(platform);
+}
diff --git a/platform/iphone/export/export.h b/platform/iphone/export/export.h
new file mode 100644
index 0000000000..6e9324aed7
--- /dev/null
+++ b/platform/iphone/export/export.h
@@ -0,0 +1,30 @@
+/*************************************************************************/
+/* export.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+void register_iphone_exporter();
diff --git a/platform/iphone/gl_view.mm b/platform/iphone/gl_view.mm
index 6270fa85f2..f2778e8165 100644
--- a/platform/iphone/gl_view.mm
+++ b/platform/iphone/gl_view.mm
@@ -29,8 +29,8 @@
/*************************************************************************/
#import "gl_view.h"
-#include "core/global_config.h"
#include "core/os/keyboard.h"
+#include "core/project_settings.h"
#include "os_iphone.h"
#include "servers/audio_server.h"
@@ -77,7 +77,7 @@ void _hide_keyboard() {
};
bool _play_video(String p_path, float p_volume, String p_audio_track, String p_subtitle_track) {
- p_path = GlobalConfig::get_singleton()->globalize_path(p_path);
+ p_path = ProjectSettings::get_singleton()->globalize_path(p_path);
NSString *file_path = [[[NSString alloc] initWithUTF8String:p_path.utf8().get_data()] autorelease];
diff --git a/platform/iphone/globals/global_defaults.cpp b/platform/iphone/globals/global_defaults.cpp
index b320be2f85..aa4662302d 100644
--- a/platform/iphone/globals/global_defaults.cpp
+++ b/platform/iphone/globals/global_defaults.cpp
@@ -28,14 +28,14 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "global_defaults.h"
-#include "global_config.h"
+#include "project_settings.h"
void register_iphone_global_defaults() {
/*GLOBAL_DEF("rasterizer.iOS/use_fragment_lighting",false);
GLOBAL_DEF("rasterizer.iOS/fp16_framebuffer",false);
GLOBAL_DEF("display.iOS/driver","GLES2");
- GlobalConfig::get_singleton()->set_custom_property_info("display.iOS/driver",PropertyInfo(Variant::STRING,"display.iOS/driver",PROPERTY_HINT_ENUM,"GLES1,GLES2"));
+ ProjectSettings::get_singleton()->set_custom_property_info("display.iOS/driver",PropertyInfo(Variant::STRING,"display.iOS/driver",PROPERTY_HINT_ENUM,"GLES1,GLES2"));
GLOBAL_DEF("display.iOS/use_cadisplaylink",true);
*/
}
diff --git a/platform/iphone/ios.mm b/platform/iphone/ios.mm
index e9c164393b..6c95903241 100644
--- a/platform/iphone/ios.mm
+++ b/platform/iphone/ios.mm
@@ -36,7 +36,7 @@ void iOS::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_rate_url", "app_id"), &iOS::get_rate_url);
};
-void iOS::alert(const char* p_alert, const char* p_title) {
+void iOS::alert(const char *p_alert, const char *p_title) {
UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:[NSString stringWithUTF8String:p_title] message:[NSString stringWithUTF8String:p_alert] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil] autorelease];
[alert show];
}
diff --git a/platform/iphone/os_iphone.cpp b/platform/iphone/os_iphone.cpp
index b244edbff6..cb5c022764 100644
--- a/platform/iphone/os_iphone.cpp
+++ b/platform/iphone/os_iphone.cpp
@@ -38,10 +38,10 @@
#include "audio_driver_iphone.h"
#include "main/main.h"
-#include "core/global_config.h"
#include "core/io/file_access_pack.h"
#include "core/os/dir_access.h"
#include "core/os/file_access.h"
+#include "core/project_settings.h"
#include "sem_iphone.h"
@@ -109,7 +109,6 @@ void OSIPhone::initialize(const VideoMode &p_desired, int p_video_driver, int p_
RasterizerGLES3::register_config();
RasterizerGLES3::make_current();
- RasterizerStorageGLES3::system_fbo = gl_view_base_fb;
visual_server = memnew(VisualServerRaster());
/*
@@ -122,6 +121,9 @@ void OSIPhone::initialize(const VideoMode &p_desired, int p_video_driver, int p_
visual_server->init();
visual_server->cursor_set_visible(false, 0);
+ // reset this to what it should be, it will have been set to 0 after visual_server->init() is called
+ RasterizerStorageGLES3::system_fbo = gl_view_base_fb;
+
audio_driver = memnew(AudioDriverIphone);
audio_driver->set_singleton();
audio_driver->init();
@@ -138,28 +140,28 @@ void OSIPhone::initialize(const VideoMode &p_desired, int p_video_driver, int p_
/*
#ifdef IOS_SCORELOOP_ENABLED
scoreloop = memnew(ScoreloopIOS);
- GlobalConfig::get_singleton()->add_singleton(GlobalConfig::Singleton("Scoreloop", scoreloop));
+ ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("Scoreloop", scoreloop));
scoreloop->connect();
#endif
*/
#ifdef GAME_CENTER_ENABLED
game_center = memnew(GameCenter);
- GlobalConfig::get_singleton()->add_singleton(GlobalConfig::Singleton("GameCenter", game_center));
+ ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("GameCenter", game_center));
game_center->connect();
#endif
#ifdef STOREKIT_ENABLED
store_kit = memnew(InAppStore);
- GlobalConfig::get_singleton()->add_singleton(GlobalConfig::Singleton("InAppStore", store_kit));
+ ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("InAppStore", store_kit));
#endif
#ifdef ICLOUD_ENABLED
icloud = memnew(ICloud);
- GlobalConfig::get_singleton()->add_singleton(GlobalConfig::Singleton("ICloud", icloud));
+ ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("ICloud", icloud));
//icloud->connect();
#endif
- GlobalConfig::get_singleton()->add_singleton(GlobalConfig::Singleton("iOS", memnew(iOS)));
+ ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("iOS", memnew(iOS)));
};
MainLoop *OSIPhone::get_main_loop() const {
@@ -434,7 +436,8 @@ bool OSIPhone::can_draw() const {
int OSIPhone::set_base_framebuffer(int p_fb) {
- RasterizerStorageGLES3::system_fbo = gl_view_base_fb;
+ // gl_view_base_fb has not been updated yet
+ RasterizerStorageGLES3::system_fbo = p_fb;
return 0;
};
@@ -517,7 +520,7 @@ Error OSIPhone::native_video_play(String p_path, float p_volume, String p_audio_
print("Unable to play %S using the native player as it resides in a .pck file\n", p_path.c_str());
return ERR_INVALID_PARAMETER;
} else {
- p_path = p_path.replace("res:/", GlobalConfig::get_singleton()->get_resource_path());
+ p_path = p_path.replace("res:/", ProjectSettings::get_singleton()->get_resource_path());
}
} else if (p_path.begins_with("user://"))
p_path = p_path.replace("user:/", get_data_dir());
@@ -552,6 +555,11 @@ void OSIPhone::native_video_stop() {
_stop_video();
}
+bool OSIPhone::_check_internal_feature_support(const String &p_feature) {
+
+ return p_feature == "mobile" || p_feature == "etc" || p_feature == "pvrtc" || p_feature == "etc2";
+}
+
OSIPhone::OSIPhone(int width, int height) {
main_loop = NULL;
diff --git a/platform/iphone/os_iphone.h b/platform/iphone/os_iphone.h
index 4031b7524c..b15e9fdffb 100644
--- a/platform/iphone/os_iphone.h
+++ b/platform/iphone/os_iphone.h
@@ -200,6 +200,7 @@ public:
virtual void native_video_focus_out();
virtual void native_video_stop();
+ virtual bool _check_internal_feature_support(const String &p_feature);
OSIPhone(int width, int height);
~OSIPhone();
};
diff --git a/platform/javascript/SCsub b/platform/javascript/SCsub
index 02ff2090f9..b804863ee1 100644
--- a/platform/javascript/SCsub
+++ b/platform/javascript/SCsub
@@ -19,29 +19,34 @@ javascript_objects = []
for x in javascript_files:
javascript_objects.append(env_javascript.Object(x))
-env.Append(LINKFLAGS=["-s", "EXPORTED_FUNCTIONS=\"['_main','_audio_server_mix_function','_main_after_fs_sync']\""])
+env.Append(LINKFLAGS=["-s", "EXPORTED_FUNCTIONS=\"['_main','_audio_server_mix_function','_main_after_fs_sync','_send_notification']\""])
env.Append(LINKFLAGS=["--shell-file", '"platform/javascript/godot_shell.html"'])
-html_file = env.Program('#bin/godot', javascript_objects, PROGSUFFIX=env["PROGSUFFIX"] + ".html")[0]
+# output file name without file extension
+basename = "godot" + env["PROGSUFFIX"]
+target_dir = env.Dir("#bin")
+js_file = target_dir.File(basename + ".js")
+implicit_targets = [js_file]
+
+zip_dir = target_dir.Dir('.javascript_zip')
+zip_files = env.InstallAs([zip_dir.File("godot.js"), zip_dir.File("godotfs.js")], [js_file, "#misc/dist/html_fs/godotfs.js"])
+
+if env['wasm'] == 'yes':
+ wasm_file = target_dir.File(basename+'.wasm')
+ implicit_targets.append(wasm_file)
+ zip_files.append(InstallAs(zip_dir.File('godot.wasm'), wasm_file))
+else:
+ asmjs_files = [target_dir.File(basename+'.asm.js'), target_dir.File(basename+'.html.mem')]
+ zip_files.append(InstallAs([zip_dir.File('godot.asm.js'), zip_dir.File('godot.mem')], asmjs_files))
+ implicit_targets.extend(asmjs_files)
+
+# HTML file must be the first target in the list
+html_file = env.Program(["#bin/godot"] + implicit_targets, javascript_objects, PROGSUFFIX=env["PROGSUFFIX"]+".html")[0]
Depends(html_file, "godot_shell.html")
-basename = "godot" + env["PROGSUFFIX"] # output file name without file extension
# Emscripten hardcodes file names, so replace common base name with
# placeholder while leaving extension; also change `.html.mem` to just `.mem`
fixup_html = env.Substfile(html_file, SUBST_DICT=[(basename, '$$GODOT_BASE'), ('.html.mem', '.mem')], SUBSTFILESUFFIX='.fixup.html')
-zip_dir = env.Dir('#bin/.javascript_zip')
-zip_files = []
-js_file = env.SideEffect(html_file.File(basename+'.js'), html_file)
-zip_files.append(env.InstallAs(
- [zip_dir.File('godot.html'), zip_dir.File('godot.js'), zip_dir.File('godotfs.js')],
- [fixup_html, js_file, '#misc/dist/html_fs/godotfs.js']))
-
-if env['wasm'] == 'yes':
- wasm_file = env.SideEffect(html_file.File(basename+'.wasm'), html_file)
- zip_files.append(env.InstallAs(zip_dir.File('godot.wasm'), wasm_file))
-else:
- asmjs_files = env.SideEffect([html_file.File(basename+'.asm.js'), html_file.File(basename+'.html.mem')], html_file)
- zip_files.append(env.InstallAs([zip_dir.File('godot.asm.js'), zip_dir.File('godot.mem')], asmjs_files))
-
-Zip('#bin/godot', zip_files, ZIPSUFFIX=env['PROGSUFFIX']+env['ZIPSUFFIX'], ZIPROOT=zip_dir)
+zip_files.append(InstallAs(zip_dir.File('godot.html'), fixup_html))
+Zip('#bin/godot', zip_files, ZIPSUFFIX=env['PROGSUFFIX']+env['ZIPSUFFIX'], ZIPROOT=zip_dir, ZIPCOMSTR="Archving $SOURCES as $TARGET")
diff --git a/platform/javascript/detect.py b/platform/javascript/detect.py
index 41fe3fb027..68c8d1eea5 100644
--- a/platform/javascript/detect.py
+++ b/platform/javascript/detect.py
@@ -1,6 +1,6 @@
import os
-import sys
import string
+import sys
def is_active():
@@ -12,7 +12,8 @@ def get_name():
def can_build():
- return os.environ.has_key("EMSCRIPTEN_ROOT")
+
+ return (os.environ.has_key("EMSCRIPTEN_ROOT"))
def get_opts():
@@ -27,12 +28,12 @@ def get_flags():
return [
('tools', 'no'),
- ('module_etc1_enabled', 'no'),
('module_theora_enabled', 'no'),
]
def create(env):
+
# remove Windows' .exe suffix
return env.Clone(tools=['textfile', 'zip'], PROGSUFFIX='')
@@ -45,10 +46,26 @@ def escape_target_backslashes(target, source, env, for_signature):
def configure(env):
- env['ENV'] = os.environ
- env.Append(CPPPATH=['#platform/javascript'])
+ ## Build type
+
+ if (env["target"] == "release"):
+ env.Append(CCFLAGS=['-O3'])
+ env.Append(LINKFLAGS=['-O3'])
+ elif (env["target"] == "release_debug"):
+ env.Append(CCFLAGS=['-O2', '-DDEBUG_ENABLED'])
+ env.Append(LINKFLAGS=['-O2', '-s', 'ASSERTIONS=1'])
+ # retain function names at the cost of file size, for backtraces and profiling
+ env.Append(LINKFLAGS=['--profiling-funcs'])
+
+ elif (env["target"] == "debug"):
+ env.Append(CCFLAGS=['-O1', '-D_DEBUG', '-g', '-DDEBUG_ENABLED'])
+ env.Append(LINKFLAGS=['-O1', '-g'])
+
+ ## Compiler configuration
+
+ env['ENV'] = os.environ
env.PrependENVPath('PATH', os.environ['EMSCRIPTEN_ROOT'])
env['CC'] = 'emcc'
env['CXX'] = 'em++'
@@ -57,6 +74,7 @@ def configure(env):
# Emscripten's ar has issues with duplicate file names, so use cc
env['AR'] = 'emcc'
env['ARFLAGS'] = '-o'
+
if (os.name == 'nt'):
# use TempFileMunge on Windows since some commands get too long for
# cmd.exe even with spawn_fix
@@ -68,26 +86,20 @@ def configure(env):
env['OBJSUFFIX'] = '.bc'
env['LIBSUFFIX'] = '.bc'
- if (env["target"] == "release"):
- env.Append(CCFLAGS=['-O3'])
- env.Append(LINKFLAGS=['-O3'])
- elif (env["target"] == "release_debug"):
- env.Append(CCFLAGS=['-O2', '-DDEBUG_ENABLED'])
- env.Append(LINKFLAGS=['-O2', '-s', 'ASSERTIONS=1'])
- # retain function names at the cost of file size, for backtraces and profiling
- env.Append(LINKFLAGS=['--profiling-funcs'])
- elif (env["target"] == "debug"):
- env.Append(CCFLAGS=['-O1', '-D_DEBUG', '-g', '-DDEBUG_ENABLED'])
- env.Append(LINKFLAGS=['-O1', '-g'])
+ ## Compile flags
- # TODO: Move that to opus module's config
- if("module_opus_enabled" in env and env["module_opus_enabled"] != "no"):
- env.opus_fixed_point = "yes"
+ env.Append(CPPPATH=['#platform/javascript'])
+ env.Append(CPPFLAGS=['-DJAVASCRIPT_ENABLED', '-DUNIX_ENABLED', '-DPTHREAD_NO_RENAME', '-DTYPED_METHOD_BIND', '-DNO_THREADS'])
+ env.Append(CPPFLAGS=['-DGLES3_ENABLED'])
# These flags help keep the file size down
env.Append(CPPFLAGS=["-fno-exceptions", '-DNO_SAFE_CAST', '-fno-rtti'])
- env.Append(CPPFLAGS=['-DJAVASCRIPT_ENABLED', '-DUNIX_ENABLED', '-DPTHREAD_NO_RENAME', '-DTYPED_METHOD_BIND', '-DNO_THREADS'])
- env.Append(CPPFLAGS=['-DGLES3_ENABLED'])
+
+ if env['javascript_eval'] == 'yes':
+ env.Append(CPPFLAGS=['-DJAVASCRIPT_EVAL_ENABLED'])
+
+ ## Link flags
+
env.Append(LINKFLAGS=['-s', 'USE_WEBGL2=1'])
if (env['wasm'] == 'yes'):
@@ -101,8 +113,6 @@ def configure(env):
env.Append(LINKFLAGS=['-s', 'ASM_JS=1'])
env.Append(LINKFLAGS=['--separate-asm'])
- if env['javascript_eval'] == 'yes':
- env.Append(CPPFLAGS=['-DJAVASCRIPT_EVAL_ENABLED'])
-
-
- import methods
+ # TODO: Move that to opus module's config
+ if("module_opus_enabled" in env and env["module_opus_enabled"] != "no"):
+ env.opus_fixed_point = "yes"
diff --git a/platform/javascript/export/export.cpp b/platform/javascript/export/export.cpp
index 4bdfdae39e..b436d52363 100644
--- a/platform/javascript/export/export.cpp
+++ b/platform/javascript/export/export.cpp
@@ -61,6 +61,7 @@ public:
virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const;
virtual String get_name() const;
+ virtual String get_os_name() const;
virtual Ref<Texture> get_logo() const;
virtual bool can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const;
@@ -74,6 +75,12 @@ public:
virtual Error run(const Ref<EditorExportPreset> &p_preset, int p_device, int p_debug_flags);
virtual Ref<Texture> get_run_icon() const;
+ virtual void get_platform_features(List<String> *r_features) {
+
+ r_features->push_back("web");
+ r_features->push_back("JavaScript");
+ }
+
EditorExportPlatformJavaScript();
};
@@ -167,6 +174,11 @@ String EditorExportPlatformJavaScript::get_name() const {
return "HTML5";
}
+String EditorExportPlatformJavaScript::get_os_name() const {
+
+ return "JavaScript";
+}
+
Ref<Texture> EditorExportPlatformJavaScript::get_logo() const {
return logo;
diff --git a/platform/javascript/godot_shell.html b/platform/javascript/godot_shell.html
index 6c7069a8f0..ee7399a129 100644
--- a/platform/javascript/godot_shell.html
+++ b/platform/javascript/godot_shell.html
@@ -83,6 +83,10 @@
color: white;
}
+ #canvas:focus {
+ outline: none;
+ }
+
/* Status display
* ============== */
@@ -147,7 +151,7 @@ $GODOT_HEAD_INCLUDE
</head>
<body>
<div id="container">
- <canvas id="canvas" width="640" height="480" onclick="canvas.ownerDocument.defaultView.focus();" oncontextmenu="event.preventDefault();">
+ <canvas id="canvas" width="640" height="480" tabindex="0" oncontextmenu="event.preventDefault();">
HTML5 canvas appears to be unsupported in the current browser.<br />
Please try updating or use a different browser.
</canvas>
diff --git a/platform/javascript/os_javascript.cpp b/platform/javascript/os_javascript.cpp
index 9df26f1471..0708d46196 100644
--- a/platform/javascript/os_javascript.cpp
+++ b/platform/javascript/os_javascript.cpp
@@ -29,8 +29,8 @@
/*************************************************************************/
#include "os_javascript.h"
-#include "core/global_config.h"
#include "core/io/file_access_buffered_fa.h"
+#include "core/project_settings.h"
#include "dom_keys.h"
#include "drivers/gles3/rasterizer_gles3.h"
#include "drivers/unix/dir_access_unix.h"
@@ -145,6 +145,31 @@ static EM_BOOL _fullscreen_change_callback(int event_type, const EmscriptenFulls
static InputDefault *_input;
+static bool is_canvas_focused() {
+
+ /* clang-format off */
+ return EM_ASM_INT_V(
+ return document.activeElement == Module.canvas;
+ );
+ /* clang-format on */
+}
+
+static void focus_canvas() {
+
+ /* clang-format off */
+ EM_ASM(
+ Module.canvas.focus();
+ );
+ /* clang-format on */
+}
+
+static bool _cursor_inside_canvas = true;
+
+static bool is_cursor_inside_canvas() {
+
+ return _cursor_inside_canvas;
+}
+
static EM_BOOL _mousebutton_callback(int event_type, const EmscriptenMouseEvent *mouse_event, void *user_data) {
ERR_FAIL_COND_V(event_type != EMSCRIPTEN_EVENT_MOUSEDOWN && event_type != EMSCRIPTEN_EVENT_MOUSEUP, false);
@@ -164,26 +189,42 @@ static EM_BOOL _mousebutton_callback(int event_type, const EmscriptenMouseEvent
}
int mask = _input->get_mouse_button_mask();
- if (ev->is_pressed())
+ if (ev->is_pressed()) {
+ // since the event is consumed, focus manually
+ if (!is_canvas_focused()) {
+ focus_canvas();
+ }
mask |= 1 << ev->get_button_index();
- else
+ } else if (mask & (1 << ev->get_button_index())) {
mask &= ~(1 << ev->get_button_index());
+ } else {
+ // release event, but press was outside the canvas, so ignore
+ return false;
+ }
ev->set_button_mask(mask >> 1);
_input->parse_input_event(ev);
+ // prevent selection dragging
return true;
}
static EM_BOOL _mousemove_callback(int event_type, const EmscriptenMouseEvent *mouse_event, void *user_data) {
ERR_FAIL_COND_V(event_type != EMSCRIPTEN_EVENT_MOUSEMOVE, false);
+ OS_JavaScript *os = static_cast<OS_JavaScript *>(user_data);
+ int input_mask = _input->get_mouse_button_mask();
+ Point2 pos = Point2(mouse_event->canvasX, mouse_event->canvasY);
+ // outside the canvas, only read mouse movement if dragging started inside
+ // the canvas; imitating desktop app behaviour
+ if (!is_cursor_inside_canvas() && !input_mask)
+ return false;
Ref<InputEventMouseMotion> ev;
ev.instance();
dom2godot_mod(mouse_event, ev);
- ev->set_button_mask(_input->get_mouse_button_mask() >> 1);
+ ev->set_button_mask(input_mask >> 1);
- ev->set_position(Point2(mouse_event->canvasX, mouse_event->canvasY));
+ ev->set_position(pos);
ev->set_global_position(ev->get_position());
ev->set_relative(_input->get_mouse_position() - ev->get_position());
@@ -191,12 +232,20 @@ static EM_BOOL _mousemove_callback(int event_type, const EmscriptenMouseEvent *m
ev->set_speed(_input->get_last_mouse_speed());
_input->parse_input_event(ev);
- return true;
+ // don't suppress mouseover/leave events
+ return false;
}
static EM_BOOL _wheel_callback(int event_type, const EmscriptenWheelEvent *wheel_event, void *user_data) {
ERR_FAIL_COND_V(event_type != EMSCRIPTEN_EVENT_WHEEL, false);
+ if (!is_canvas_focused()) {
+ if (is_cursor_inside_canvas()) {
+ focus_canvas();
+ } else {
+ return false;
+ }
+ }
Ref<InputEventMouseButton> ev;
ev.instance();
@@ -387,6 +436,15 @@ static EM_BOOL joy_callback_func(int p_type, const EmscriptenGamepadEvent *p_eve
return false;
}
+extern "C" {
+void send_notification(int notif) {
+ if (notif == MainLoop::NOTIFICATION_WM_MOUSE_ENTER || notif == MainLoop::NOTIFICATION_WM_MOUSE_EXIT) {
+ _cursor_inside_canvas = notif == MainLoop::NOTIFICATION_WM_MOUSE_ENTER;
+ }
+ OS_JavaScript::get_singleton()->get_main_loop()->notification(notif);
+}
+}
+
void OS_JavaScript::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) {
print_line("Init OS");
@@ -465,17 +523,17 @@ void OS_JavaScript::initialize(const VideoMode &p_desired, int p_video_driver, i
EM_CHECK(ev)
EMSCRIPTEN_RESULT result;
- SET_EM_CALLBACK("#canvas", mousemove, _mousemove_callback)
+ SET_EM_CALLBACK("#window", mousemove, _mousemove_callback)
SET_EM_CALLBACK("#canvas", mousedown, _mousebutton_callback)
- SET_EM_CALLBACK("#canvas", mouseup, _mousebutton_callback)
- SET_EM_CALLBACK("#canvas", wheel, _wheel_callback)
- SET_EM_CALLBACK("#canvas", touchstart, _touchpress_callback)
- SET_EM_CALLBACK("#canvas", touchmove, _touchmove_callback)
- SET_EM_CALLBACK("#canvas", touchend, _touchpress_callback)
- SET_EM_CALLBACK("#canvas", touchcancel, _touchpress_callback)
- SET_EM_CALLBACK(NULL, keydown, _keydown_callback)
- SET_EM_CALLBACK(NULL, keypress, _keypress_callback)
- SET_EM_CALLBACK(NULL, keyup, _keyup_callback)
+ SET_EM_CALLBACK("#window", mouseup, _mousebutton_callback)
+ SET_EM_CALLBACK("#window", wheel, _wheel_callback)
+ SET_EM_CALLBACK("#window", touchstart, _touchpress_callback)
+ SET_EM_CALLBACK("#window", touchmove, _touchmove_callback)
+ SET_EM_CALLBACK("#window", touchend, _touchpress_callback)
+ SET_EM_CALLBACK("#window", touchcancel, _touchpress_callback)
+ SET_EM_CALLBACK("#canvas", keydown, _keydown_callback)
+ SET_EM_CALLBACK("#canvas", keypress, _keypress_callback)
+ SET_EM_CALLBACK("#canvas", keyup, _keyup_callback)
SET_EM_CALLBACK(NULL, resize, _browser_resize_callback)
SET_EM_CALLBACK(NULL, fullscreenchange, _fullscreen_change_callback)
SET_EM_CALLBACK_NODATA(gamepadconnected, joy_callback_func)
@@ -485,9 +543,24 @@ void OS_JavaScript::initialize(const VideoMode &p_desired, int p_video_driver, i
#undef SET_EM_CALLBACK
#undef EM_CHECK
+ /* clang-format off */
+ EM_ASM_ARGS({
+ const send_notification = Module.cwrap('send_notification', null, ['number']);
+ const notifs = arguments;
+ (['mouseover', 'mouseleave', 'focus', 'blur']).forEach(function(event, i) {
+ Module.canvas.addEventListener(event, send_notification.bind(this, notifs[i]));
+ });
+ },
+ MainLoop::NOTIFICATION_WM_MOUSE_ENTER,
+ MainLoop::NOTIFICATION_WM_MOUSE_EXIT,
+ MainLoop::NOTIFICATION_WM_FOCUS_IN,
+ MainLoop::NOTIFICATION_WM_FOCUS_OUT
+ );
+/* clang-format on */
+
#ifdef JAVASCRIPT_EVAL_ENABLED
javascript_eval = memnew(JavaScript);
- GlobalConfig::get_singleton()->add_singleton(GlobalConfig::Singleton("JavaScript", javascript_eval));
+ ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("JavaScript", javascript_eval));
#endif
visual_server->init();
@@ -777,20 +850,6 @@ void OS_JavaScript::main_loop_end() {
main_loop->finish();
}
-void OS_JavaScript::main_loop_focusout() {
-
- if (main_loop)
- main_loop->notification(MainLoop::NOTIFICATION_WM_FOCUS_OUT);
- //audio_driver_javascript.set_pause(true);
-}
-
-void OS_JavaScript::main_loop_focusin() {
-
- if (main_loop)
- main_loop->notification(MainLoop::NOTIFICATION_WM_FOCUS_IN);
- //audio_driver_javascript.set_pause(false);
-}
-
void OS_JavaScript::process_accelerometer(const Vector3 &p_accelerometer) {
input->set_accelerometer(p_accelerometer);
@@ -828,7 +887,7 @@ String OS_JavaScript::get_data_dir() const {
return get_data_dir_func();
*/
return "/userfs";
- //return GlobalConfig::get_singleton()->get_singleton_object("GodotOS")->call("get_data_dir");
+ //return ProjectSettings::get_singleton()->get_singleton_object("GodotOS")->call("get_data_dir");
};
String OS_JavaScript::get_executable_path() const {
@@ -911,6 +970,11 @@ int OS_JavaScript::get_power_percent_left() {
return power_manager->get_power_percent_left();
}
+bool OS_JavaScript::_check_internal_feature_support(const String &p_feature) {
+
+ return p_feature == "web" || p_feature == "s3tc"; // TODO check for these features really being available
+}
+
OS_JavaScript::OS_JavaScript(const char *p_execpath, GetDataDirFunc p_get_data_dir_func) {
set_cmdline(p_execpath, get_cmdline_args());
main_loop = NULL;
diff --git a/platform/javascript/os_javascript.h b/platform/javascript/os_javascript.h
index 65269148ec..24e96e20dd 100644
--- a/platform/javascript/os_javascript.h
+++ b/platform/javascript/os_javascript.h
@@ -164,6 +164,8 @@ public:
virtual int get_power_seconds_left();
virtual int get_power_percent_left();
+ virtual bool _check_internal_feature_support(const String &p_feature);
+
OS_JavaScript(const char *p_execpath, GetDataDirFunc p_get_data_dir_func);
~OS_JavaScript();
};
diff --git a/platform/osx/audio_driver_osx.cpp b/platform/osx/audio_driver_osx.cpp
index 7469d52976..d7a91b1653 100644
--- a/platform/osx/audio_driver_osx.cpp
+++ b/platform/osx/audio_driver_osx.cpp
@@ -31,11 +31,15 @@
#include "audio_driver_osx.h"
-Error AudioDriverOSX::init() {
+static OSStatus outputDeviceAddressCB(AudioObjectID inObjectID, UInt32 inNumberAddresses, const AudioObjectPropertyAddress *inAddresses, void *__nullable inClientData) {
+ AudioDriverOSX *driver = (AudioDriverOSX *)inClientData;
- active = false;
- channels = 2;
+ driver->reopen();
+ return noErr;
+}
+
+Error AudioDriverOSX::initDevice() {
AudioStreamBasicDescription strdesc;
strdesc.mFormatID = kAudioFormatLinearPCM;
strdesc.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger | kLinearPCMFormatFlagIsPacked;
@@ -43,12 +47,10 @@ Error AudioDriverOSX::init() {
strdesc.mSampleRate = 44100;
strdesc.mFramesPerPacket = 1;
strdesc.mBitsPerChannel = 16;
- strdesc.mBytesPerFrame =
- strdesc.mBitsPerChannel * strdesc.mChannelsPerFrame / 8;
- strdesc.mBytesPerPacket =
- strdesc.mBytesPerFrame * strdesc.mFramesPerPacket;
+ strdesc.mBytesPerFrame = strdesc.mBitsPerChannel * strdesc.mChannelsPerFrame / 8;
+ strdesc.mBytesPerPacket = strdesc.mBytesPerFrame * strdesc.mFramesPerPacket;
- OSStatus result = noErr;
+ OSStatus result;
AURenderCallbackStruct callback;
AudioComponentDescription desc;
AudioComponent comp = NULL;
@@ -58,83 +60,130 @@ Error AudioDriverOSX::init() {
zeromem(&desc, sizeof(desc));
desc.componentType = kAudioUnitType_Output;
- desc.componentSubType = 0; /* !!! FIXME: ? */
- comp = AudioComponentFindNext(NULL, &desc);
+ desc.componentSubType = kAudioUnitSubType_HALOutput;
desc.componentManufacturer = kAudioUnitManufacturer_Apple;
+ comp = AudioComponentFindNext(NULL, &desc);
+ ERR_FAIL_COND_V(comp == NULL, FAILED);
+
result = AudioComponentInstanceNew(comp, &audio_unit);
ERR_FAIL_COND_V(result != noErr, FAILED);
- ERR_FAIL_COND_V(comp == NULL, FAILED);
- result = AudioUnitSetProperty(audio_unit,
- kAudioUnitProperty_StreamFormat,
- scope, bus, &strdesc, sizeof(strdesc));
+ result = AudioUnitSetProperty(audio_unit, kAudioUnitProperty_StreamFormat, scope, bus, &strdesc, sizeof(strdesc));
ERR_FAIL_COND_V(result != noErr, FAILED);
zeromem(&callback, sizeof(AURenderCallbackStruct));
callback.inputProc = &AudioDriverOSX::output_callback;
callback.inputProcRefCon = this;
- result = AudioUnitSetProperty(audio_unit,
- kAudioUnitProperty_SetRenderCallback,
- scope, bus, &callback, sizeof(callback));
+ result = AudioUnitSetProperty(audio_unit, kAudioUnitProperty_SetRenderCallback, scope, bus, &callback, sizeof(callback));
ERR_FAIL_COND_V(result != noErr, FAILED);
result = AudioUnitInitialize(audio_unit);
ERR_FAIL_COND_V(result != noErr, FAILED);
- result = AudioOutputUnitStart(audio_unit);
+ return OK;
+}
+
+Error AudioDriverOSX::finishDevice() {
+ OSStatus result;
+
+ if (active) {
+ result = AudioOutputUnitStop(audio_unit);
+ ERR_FAIL_COND_V(result != noErr, FAILED);
+
+ active = false;
+ }
+
+ result = AudioUnitUninitialize(audio_unit);
+ ERR_FAIL_COND_V(result != noErr, FAILED);
+
+ return OK;
+}
+
+Error AudioDriverOSX::init() {
+ OSStatus result;
+
+ mutex = Mutex::create();
+ active = false;
+ channels = 2;
+
+ outputDeviceAddress.mSelector = kAudioHardwarePropertyDefaultOutputDevice;
+ outputDeviceAddress.mScope = kAudioObjectPropertyScopeGlobal;
+ outputDeviceAddress.mElement = kAudioObjectPropertyElementMaster;
+
+ result = AudioObjectAddPropertyListener(kAudioObjectSystemObject, &outputDeviceAddress, &outputDeviceAddressCB, this);
ERR_FAIL_COND_V(result != noErr, FAILED);
const int samples = 1024;
samples_in = memnew_arr(int32_t, samples); // whatever
buffer_frames = samples / channels;
- return OK;
+ return initDevice();
};
+Error AudioDriverOSX::reopen() {
+ Error err;
+ bool restart = false;
+
+ lock();
+
+ if (active) {
+ restart = true;
+ }
+
+ err = finishDevice();
+ if (err != OK) {
+ ERR_PRINT("finishDevice failed");
+ unlock();
+ return err;
+ }
+
+ err = initDevice();
+ if (err != OK) {
+ ERR_PRINT("initDevice failed");
+ unlock();
+ return err;
+ }
+
+ if (restart) {
+ start();
+ }
+
+ unlock();
+
+ return OK;
+}
+
OSStatus AudioDriverOSX::output_callback(void *inRefCon,
AudioUnitRenderActionFlags *ioActionFlags,
const AudioTimeStamp *inTimeStamp,
UInt32 inBusNumber, UInt32 inNumberFrames,
AudioBufferList *ioData) {
- AudioBuffer *abuf;
AudioDriverOSX *ad = (AudioDriverOSX *)inRefCon;
- bool mix = true;
-
- if (!ad->active)
- mix = false;
- else if (ad->mutex) {
- mix = ad->mutex->try_lock() == OK;
- };
-
- if (!mix) {
+ if (!ad->active || !ad->try_lock()) {
for (unsigned int i = 0; i < ioData->mNumberBuffers; i++) {
- abuf = &ioData->mBuffers[i];
+ AudioBuffer *abuf = &ioData->mBuffers[i];
zeromem(abuf->mData, abuf->mDataByteSize);
};
return 0;
};
- int frames_left;
-
for (unsigned int i = 0; i < ioData->mNumberBuffers; i++) {
- abuf = &ioData->mBuffers[i];
- frames_left = inNumberFrames;
+ AudioBuffer *abuf = &ioData->mBuffers[i];
+ int frames_left = inNumberFrames;
int16_t *out = (int16_t *)abuf->mData;
while (frames_left) {
int frames = MIN(frames_left, ad->buffer_frames);
- //ad->lock();
ad->audio_server_process(frames, ad->samples_in);
- //ad->unlock();
- for (int i = 0; i < frames * ad->channels; i++) {
+ for (int j = 0; j < frames * ad->channels; j++) {
- out[i] = ad->samples_in[i] >> 16;
+ out[j] = ad->samples_in[j] >> 16;
}
frames_left -= frames;
@@ -142,14 +191,20 @@ OSStatus AudioDriverOSX::output_callback(void *inRefCon,
};
};
- if (ad->mutex)
- ad->mutex->unlock();
+ ad->unlock();
return 0;
};
void AudioDriverOSX::start() {
- active = true;
+ if (!active) {
+ OSStatus result = AudioOutputUnitStart(audio_unit);
+ if (result != noErr) {
+ ERR_PRINT("AudioOutputUnitStart failed");
+ } else {
+ active = true;
+ }
+ }
};
int AudioDriverOSX::get_mix_rate() const {
@@ -161,29 +216,47 @@ AudioDriver::SpeakerMode AudioDriverOSX::get_speaker_mode() const {
};
void AudioDriverOSX::lock() {
- if (active && mutex)
+ if (mutex)
mutex->lock();
};
+
void AudioDriverOSX::unlock() {
- if (active && mutex)
+ if (mutex)
mutex->unlock();
};
+bool AudioDriverOSX::try_lock() {
+ if (mutex)
+ return mutex->try_lock() == OK;
+ return true;
+}
+
void AudioDriverOSX::finish() {
+ OSStatus result;
- if (active)
- AudioOutputUnitStop(audio_unit);
+ finishDevice();
- memdelete_arr(samples_in);
-};
+ result = AudioObjectRemovePropertyListener(kAudioObjectSystemObject, &outputDeviceAddress, &outputDeviceAddressCB, this);
+ if (result != noErr) {
+ ERR_PRINT("AudioObjectRemovePropertyListener failed");
+ }
-AudioDriverOSX::AudioDriverOSX() {
+ if (mutex) {
+ memdelete(mutex);
+ mutex = NULL;
+ }
- mutex = Mutex::create(); //NULL;
+ if (samples_in) {
+ memdelete_arr(samples_in);
+ samples_in = NULL;
+ }
};
-AudioDriverOSX::~AudioDriverOSX(){
-
+AudioDriverOSX::AudioDriverOSX() {
+ mutex = NULL;
+ samples_in = NULL;
};
+AudioDriverOSX::~AudioDriverOSX(){};
+
#endif
diff --git a/platform/osx/audio_driver_osx.h b/platform/osx/audio_driver_osx.h
index 9b48dab405..287c9d6cbf 100644
--- a/platform/osx/audio_driver_osx.h
+++ b/platform/osx/audio_driver_osx.h
@@ -35,10 +35,12 @@
#include "servers/audio_server.h"
#include <AudioUnit/AudioUnit.h>
+#include <CoreAudio/AudioHardware.h>
class AudioDriverOSX : public AudioDriver {
AudioComponentInstance audio_unit;
+ AudioObjectPropertyAddress outputDeviceAddress;
bool active;
Mutex *mutex;
@@ -52,6 +54,9 @@ class AudioDriverOSX : public AudioDriver {
UInt32 inBusNumber, UInt32 inNumberFrames,
AudioBufferList *ioData);
+ Error initDevice();
+ Error finishDevice();
+
public:
const char *get_name() const {
return "AudioUnit";
@@ -65,6 +70,9 @@ public:
virtual void unlock();
virtual void finish();
+ bool try_lock();
+ Error reopen();
+
AudioDriverOSX();
~AudioDriverOSX();
};
diff --git a/platform/osx/detect.py b/platform/osx/detect.py
index 39ee33ae82..d9891dda61 100644
--- a/platform/osx/detect.py
+++ b/platform/osx/detect.py
@@ -1,4 +1,3 @@
-
import os
import sys
@@ -22,9 +21,7 @@ def can_build():
def get_opts():
return [
- ('force_64_bits', 'Force 64 bits binary', 'no'),
('osxcross_sdk', 'OSXCross SDK version', 'darwin14'),
-
]
@@ -36,36 +33,37 @@ def get_flags():
def configure(env):
- env.Append(CPPPATH=['#platform/osx'])
-
- if (env["bits"] == "default"):
- env["bits"] = "32"
+ ## Build type
if (env["target"] == "release"):
-
- env.Append(CCFLAGS=['-O2', '-ffast-math', '-fomit-frame-pointer', '-ftree-vectorize', '-msse2'])
+ env.Prepend(CCFLAGS=['-O2', '-ffast-math', '-fomit-frame-pointer', '-ftree-vectorize', '-msse2'])
elif (env["target"] == "release_debug"):
-
- env.Append(CCFLAGS=['-O2', '-DDEBUG_ENABLED'])
+ env.Prepend(CCFLAGS=['-O2', '-DDEBUG_ENABLED'])
elif (env["target"] == "debug"):
+ env.Prepend(CCFLAGS=['-g3', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED'])
- env.Append(CCFLAGS=['-g3', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED'])
+ ## Architecture
- if (not os.environ.has_key("OSXCROSS_ROOT")):
- # regular native build
- if (env["bits"] == "64"):
- env.Append(CCFLAGS=['-arch', 'x86_64'])
- env.Append(LINKFLAGS=['-arch', 'x86_64'])
+ is64 = sys.maxsize > 2**32
+ if (env["bits"] == "default"):
+ env["bits"] = "64" if is64 else "32"
+
+ ## Compiler configuration
+
+ if (not os.environ.has_key("OSXCROSS_ROOT")): # regular native build
+ if (env["bits"] == "fat"):
+ env.Append(CCFLAGS=['-arch', 'i386', '-arch', 'x86_64'])
+ env.Append(LINKFLAGS=['-arch', 'i386', '-arch', 'x86_64'])
elif (env["bits"] == "32"):
env.Append(CCFLAGS=['-arch', 'i386'])
env.Append(LINKFLAGS=['-arch', 'i386'])
- else:
- env.Append(CCFLAGS=['-arch', 'i386', '-arch', 'x86_64'])
- env.Append(LINKFLAGS=['-arch', 'i386', '-arch', 'x86_64'])
- else:
- # osxcross build
+ else: # 64-bit, default
+ env.Append(CCFLAGS=['-arch', 'x86_64'])
+ env.Append(LINKFLAGS=['-arch', 'x86_64'])
+
+ else: # osxcross build
root = os.environ.get("OSXCROSS_ROOT", 0)
if env["bits"] == "64":
basecmd = root + "/target/bin/x86_64-apple-" + env["osxcross_sdk"] + "-"
@@ -78,26 +76,22 @@ def configure(env):
env['RANLIB'] = basecmd + "ranlib"
env['AS'] = basecmd + "as"
- env.Append(CPPFLAGS=["-DAPPLE_STYLE_KEYS"])
- env.Append(CPPFLAGS=['-DUNIX_ENABLED', '-DGLES2_ENABLED', '-DOSX_ENABLED'])
- env.Append(CPPFLAGS=["-mmacosx-version-min=10.9"])
- env.Append(LIBS=['pthread'])
- #env.Append(CPPFLAGS=['-F/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks', '-isysroot', '/Developer/SDKs/MacOSX10.4u.sdk', '-mmacosx-version-min=10.4'])
- #env.Append(LINKFLAGS=['-mmacosx-version-min=10.4', '-isysroot', '/Developer/SDKs/MacOSX10.4u.sdk', '-Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk'])
- env.Append(LINKFLAGS=['-framework', 'Cocoa', '-framework', 'Carbon', '-framework', 'OpenGL', '-framework', 'AGL', '-framework', 'AudioUnit', '-lz', '-framework', 'IOKit', '-framework', 'ForceFeedback'])
- env.Append(LINKFLAGS=["-mmacosx-version-min=10.9"])
-
if (env["CXX"] == "clang++"):
env.Append(CPPFLAGS=['-DTYPED_METHOD_BIND'])
env["CC"] = "clang"
env["LD"] = "clang++"
- import methods
+ ## Dependencies
+
+ if (env['builtin_libtheora'] != 'no'):
+ env["x86_libtheora_opt_gcc"] = True
- env.Append(BUILDERS={'GLSL120': env.Builder(action=methods.build_legacygl_headers, suffix='glsl.h', src_suffix='.glsl')})
- env.Append(BUILDERS={'GLSL': env.Builder(action=methods.build_glsl_headers, suffix='glsl.h', src_suffix='.glsl')})
- env.Append(BUILDERS={'GLSL120GLES': env.Builder(action=methods.build_gles2_headers, suffix='glsl.h', src_suffix='.glsl')})
- #env.Append( BUILDERS = { 'HLSL9' : env.Builder(action = methods.build_hlsl_dx9_headers, suffix = 'hlsl.h',src_suffix = '.hlsl') } )
+ ## Flags
+
+ env.Append(CPPPATH=['#platform/osx'])
+ env.Append(CPPFLAGS=['-DOSX_ENABLED', '-DUNIX_ENABLED', '-DGLES2_ENABLED', '-DAPPLE_STYLE_KEYS'])
+ env.Append(LINKFLAGS=['-framework', 'Cocoa', '-framework', 'Carbon', '-framework', 'OpenGL', '-framework', 'AGL', '-framework', 'AudioUnit', '-framework', 'CoreAudio', '-lz', '-framework', 'IOKit', '-framework', 'ForceFeedback'])
+ env.Append(LIBS=['pthread'])
- env["x86_libtheora_opt_gcc"] = True
-
+ env.Append(CPPFLAGS=['-mmacosx-version-min=10.9'])
+ env.Append(LINKFLAGS=['-mmacosx-version-min=10.9'])
diff --git a/platform/osx/export/export.cpp b/platform/osx/export/export.cpp
index 066adde780..03f424de8d 100644
--- a/platform/osx/export/export.cpp
+++ b/platform/osx/export/export.cpp
@@ -32,15 +32,16 @@
#include "editor/editor_export.h"
#include "editor/editor_node.h"
#include "editor/editor_settings.h"
-#include "global_config.h"
#include "io/marshalls.h"
#include "io/resource_saver.h"
#include "io/zip_io.h"
#include "os/file_access.h"
#include "os/os.h"
#include "platform/osx/logo.gen.h"
+#include "project_settings.h"
#include "string.h"
#include "version.h"
+#include <sys/stat.h>
class EditorExportPlatformOSX : public EditorExportPlatform {
@@ -52,6 +53,10 @@ class EditorExportPlatformOSX : public EditorExportPlatform {
void _fix_plist(const Ref<EditorExportPreset> &p_preset, Vector<uint8_t> &plist, const String &p_binary);
void _make_icon(const Ref<Image> &p_icon, Vector<uint8_t> &p_data);
+#ifdef OSX_ENABLED
+ Error _code_sign(const Ref<EditorExportPreset> &p_preset, const String &p_path);
+ Error _create_dmg(const String &p_dmg_path, const String &p_pkg_name, const String &p_app_path_name);
+#endif
protected:
virtual void get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features);
@@ -59,13 +64,25 @@ protected:
public:
virtual String get_name() const { return "Mac OSX"; }
+ virtual String get_os_name() const { return "OSX"; }
virtual Ref<Texture> get_logo() const { return logo; }
+#ifdef OSX_ENABLED
+ virtual String get_binary_extension() const { return "dmg"; }
+#else
virtual String get_binary_extension() const { return "zip"; }
+#endif
virtual Error export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0);
virtual bool can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const;
+ virtual void get_platform_features(List<String> *r_features) {
+
+ r_features->push_back("pc");
+ r_features->push_back("s3tc");
+ r_features->push_back("OSX");
+ }
+
EditorExportPlatformOSX();
~EditorExportPlatformOSX();
};
@@ -90,6 +107,11 @@ void EditorExportPlatformOSX::get_export_options(List<ExportOption> *r_options)
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/copyright"), ""));
r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "application/bits_mode", PROPERTY_HINT_ENUM, "Fat (32 & 64 bits),64 bits,32 bits"), 0));
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "display/high_res"), false));
+
+#ifdef OSX_ENABLED
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "codesign/identity"), ""));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "codesign/entitlements"), ""));
+#endif
}
void EditorExportPlatformOSX::_make_icon(const Ref<Image> &p_icon, Vector<uint8_t> &p_data) {
@@ -171,27 +193,68 @@ void EditorExportPlatformOSX::_fix_plist(const Ref<EditorExportPreset> &p_preset
}
CharString cs = strnew.utf8();
- plist.resize(cs.size());
- for (int i = 9; i < cs.size(); i++) {
+ plist.resize(cs.size() - 1);
+ for (int i = 0; i < cs.size() - 1; i++) {
plist[i] = cs[i];
}
}
+#ifdef OSX_ENABLED
+/**
+ If we're running the OSX version of the Godot editor we'll:
+ - export our application bundle to a temporary folder
+ - attempt to code sign it
+ - and then wrap it up in a DMG
+**/
+
+Error EditorExportPlatformOSX::_code_sign(const Ref<EditorExportPreset> &p_preset, const String &p_path) {
+ List<String> args;
+ if (p_preset->get("codesign/entitlements") != "") {
+ /* this should point to our entitlements.plist file that sandboxes our application, I don't know if this should also be placed in our app bundle */
+ args.push_back("-entitlements");
+ args.push_back(p_preset->get("codesign/entitlements"));
+ }
+ args.push_back("-s");
+ args.push_back(p_preset->get("codesign/identity"));
+ args.push_back("-v"); /* provide some more feedback */
+ args.push_back(p_path);
+ Error err = OS::get_singleton()->execute("/usr/bin/codesign", args, true);
+ ERR_FAIL_COND_V(err, err);
+
+ return OK;
+}
+
+Error EditorExportPlatformOSX::_create_dmg(const String &p_dmg_path, const String &p_pkg_name, const String &p_app_path_name) {
+ List<String> args;
+ args.push_back("create");
+ args.push_back(p_dmg_path);
+ args.push_back("-volname");
+ args.push_back(p_pkg_name);
+ args.push_back("-fs");
+ args.push_back("HFS+");
+ args.push_back("-srcfolder");
+ args.push_back(p_app_path_name);
+ Error err = OS::get_singleton()->execute("/usr/bin/hdiutil", args, true);
+ ERR_FAIL_COND_V(err, err);
+
+ return OK;
+}
+
Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags) {
- String src_pkg;
+ String src_pkg_name;
- EditorProgress ep("export", "Exporting for OSX", 104);
+ EditorProgress ep("export", "Exporting for OSX", 3);
if (p_debug)
- src_pkg = p_preset->get("custom_package/debug");
+ src_pkg_name = p_preset->get("custom_package/debug");
else
- src_pkg = p_preset->get("custom_package/release");
+ src_pkg_name = p_preset->get("custom_package/release");
- if (src_pkg == "") {
+ if (src_pkg_name == "") {
String err;
- src_pkg = find_export_template("osx.zip", &err);
- if (src_pkg == "") {
+ src_pkg_name = find_export_template("osx.zip", &err);
+ if (src_pkg_name == "") {
EditorNode::add_io_error(err);
return ERR_FILE_NOT_FOUND;
}
@@ -202,20 +265,15 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p
ep.step("Creating app", 0);
- unzFile pkg = unzOpen2(src_pkg.utf8().get_data(), &io);
- if (!pkg) {
+ unzFile src_pkg_zip = unzOpen2(src_pkg_name.utf8().get_data(), &io);
+ if (!src_pkg_zip) {
- EditorNode::add_io_error("Could not find template app to export:\n" + src_pkg);
+ EditorNode::add_io_error("Could not find template app to export:\n" + src_pkg_name);
return ERR_FILE_NOT_FOUND;
}
- ERR_FAIL_COND_V(!pkg, ERR_CANT_OPEN);
- int ret = unzGoToFirstFile(pkg);
-
- zlib_filefunc_def io2 = io;
- FileAccess *dst_f = NULL;
- io2.opaque = &dst_f;
- zipFile dpkg = zipOpen2(p_path.utf8().get_data(), APPEND_STATUS_CREATE, NULL, &io2);
+ ERR_FAIL_COND_V(!src_pkg_zip, ERR_CANT_OPEN);
+ int ret = unzGoToFirstFile(src_pkg_zip);
String binary_to_use = "godot_osx_" + String(p_debug ? "debug" : "release") + ".";
int bits_mode = p_preset->get("application/bits_mode");
@@ -225,19 +283,39 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p
String pkg_name;
if (p_preset->get("application/name") != "")
pkg_name = p_preset->get("application/name"); // app_name
- else if (String(GlobalConfig::get_singleton()->get("application/name")) != "")
- pkg_name = String(GlobalConfig::get_singleton()->get("application/name"));
+ else if (String(ProjectSettings::get_singleton()->get("application/config/name")) != "")
+ pkg_name = String(ProjectSettings::get_singleton()->get("application/config/name"));
else
pkg_name = "Unnamed";
+ // We're on OSX so we can export to DMG, but first we create our application bundle
+ String tmp_app_path_name = p_path.get_base_dir() + "/" + pkg_name + ".app";
+ print_line("Exporting to " + tmp_app_path_name);
+ DirAccess *tmp_app_path = DirAccess::create_for_path(tmp_app_path_name);
+ ERR_FAIL_COND_V(!tmp_app_path, ERR_CANT_CREATE)
+
+ ///@TODO We should delete the existing application bundle especially if we attempt to code sign it, but what is a safe way to do this? Maybe call system function so it moves to trash?
+ // tmp_app_path->erase_contents_recursive();
+
+ // Create our folder structure or rely on unzip?
+ print_line("Creating " + tmp_app_path_name + "/Contents/MacOS");
+ Error dir_err = tmp_app_path->make_dir_recursive(tmp_app_path_name + "/Contents/MacOS");
+ ERR_FAIL_COND_V(dir_err, ERR_CANT_CREATE)
+ print_line("Creating " + tmp_app_path_name + "/Contents/Resources");
+ dir_err = tmp_app_path->make_dir_recursive(tmp_app_path_name + "/Contents/Resources");
+ ERR_FAIL_COND_V(dir_err, ERR_CANT_CREATE)
+
+ /* Now process our template */
bool found_binary = false;
+ int total_size = 0;
while (ret == UNZ_OK) {
+ bool is_execute = false;
//get filename
unz_file_info info;
char fname[16384];
- ret = unzGetCurrentFileInfo(pkg, &info, fname, 16384, NULL, 0, NULL, 0);
+ ret = unzGetCurrentFileInfo(src_pkg_zip, &info, fname, 16384, NULL, 0, NULL, 0);
String file = fname;
@@ -246,9 +324,9 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p
data.resize(info.uncompressed_size);
//read
- unzOpenCurrentFile(pkg);
- unzReadCurrentFile(pkg, data.ptr(), data.size());
- unzCloseCurrentFile(pkg);
+ unzOpenCurrentFile(src_pkg_zip);
+ unzReadCurrentFile(src_pkg_zip, data.ptr(), data.size());
+ unzCloseCurrentFile(src_pkg_zip);
//write
@@ -261,10 +339,11 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p
if (file.begins_with("Contents/MacOS/godot_")) {
if (file != "Contents/MacOS/" + binary_to_use) {
- ret = unzGoToNextFile(pkg);
+ ret = unzGoToNextFile(src_pkg_zip);
continue; //ignore!
}
found_binary = true;
+ is_execute = true;
file = "Contents/MacOS/" + pkg_name;
}
@@ -274,7 +353,7 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p
if (p_preset->get("application/icon") != "")
iconpath = p_preset->get("application/icon");
else
- iconpath = GlobalConfig::get_singleton()->get("application/icon");
+ iconpath = ProjectSettings::get_singleton()->get("application/config/icon");
print_line("icon? " + iconpath);
if (iconpath != "") {
Ref<Image> icon;
@@ -288,11 +367,206 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p
//bleh?
}
- file = pkg_name + ".app/" + file;
+ if (data.size() > 0) {
+ print_line("ADDING: " + file + " size: " + itos(data.size()));
+ total_size += data.size();
+
+ /* write it into our application bundle */
+ file = tmp_app_path_name + "/" + file;
+
+ /* write the file, need to add chmod */
+ FileAccess *f = FileAccess::open(file, FileAccess::WRITE);
+ ERR_FAIL_COND_V(!f, ERR_CANT_CREATE)
+ f->store_buffer(data.ptr(), data.size());
+ f->close();
+ memdelete(f);
+
+ if (is_execute) {
+ // we need execute rights on this file
+ chmod(file.utf8().get_data(), 0755);
+ } else {
+ // seems to already be set correctly
+ // chmod(file.utf8().get_data(), 0644);
+ }
+ }
+
+ ret = unzGoToNextFile(src_pkg_zip);
+ }
+
+ /* we're done with our source zip */
+ unzClose(src_pkg_zip);
+
+ if (!found_binary) {
+ ERR_PRINTS("Requested template binary '" + binary_to_use + "' not found. It might be missing from your template archive.");
+ unzClose(src_pkg_zip);
+ return ERR_FILE_NOT_FOUND;
+ }
+
+ ep.step("Making PKG", 1);
+
+ String pack_path = tmp_app_path_name + "/Contents/Resources/" + pkg_name + ".pck";
+ Error err = save_pack(p_preset, pack_path);
+ // chmod(pack_path.utf8().get_data(), 0644);
+
+ if (err) {
+ return err;
+ }
+
+ /* see if we can code sign our new package */
+ if (p_preset->get("codesign/identity") != "") {
+ ep.step("Code signing bundle", 2);
+
+ /* the order in which we code sign is important, this is a bit of a shame or we could do this in our loop that extracts the files from our ZIP */
+
+ // start with our application
+ err = _code_sign(p_preset, tmp_app_path_name + "/Contents/MacOS/" + pkg_name);
+ ERR_FAIL_COND_V(err, err);
+
+ ///@TODO we should check the contents of /Contents/Frameworks for frameworks to sign
+
+ // we should probably loop through all resources and sign them?
+ err = _code_sign(p_preset, tmp_app_path_name + "/Contents/Resources/icon.icns");
+ ERR_FAIL_COND_V(err, err);
+ err = _code_sign(p_preset, pack_path);
+ ERR_FAIL_COND_V(err, err);
+ err = _code_sign(p_preset, tmp_app_path_name + "/Contents/Info.plist");
+ ERR_FAIL_COND_V(err, err);
+ }
+
+ /* and finally create a DMG */
+ ep.step("Making DMG", 3);
+ err = _create_dmg(p_path, pkg_name, tmp_app_path_name);
+ ERR_FAIL_COND_V(err, err);
+
+ return OK;
+}
+
+#else
+
+/**
+ When exporting for OSX from any other platform we don't have access to code signing or creating DMGs so we'll wrap the bundle into a zip file.
+
+ Should probably find a nicer way to have just one export method instead of duplicating the method like this but I would the code got very
+ messy with switches inside of it.
+**/
+Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags) {
+
+ String src_pkg_name;
+
+ EditorProgress ep("export", "Exporting for OSX", 104);
+
+ if (p_debug)
+ src_pkg_name = p_preset->get("custom_package/debug");
+ else
+ src_pkg_name = p_preset->get("custom_package/release");
+
+ if (src_pkg_name == "") {
+ String err;
+ src_pkg_name = find_export_template("osx.zip", &err);
+ if (src_pkg_name == "") {
+ EditorNode::add_io_error(err);
+ return ERR_FILE_NOT_FOUND;
+ }
+ }
+
+ FileAccess *src_f = NULL;
+ zlib_filefunc_def io = zipio_create_io_from_file(&src_f);
+
+ ep.step("Creating app", 0);
+
+ unzFile src_pkg_zip = unzOpen2(src_pkg_name.utf8().get_data(), &io);
+ if (!src_pkg_zip) {
+
+ EditorNode::add_io_error("Could not find template app to export:\n" + src_pkg_name);
+ return ERR_FILE_NOT_FOUND;
+ }
+
+ ERR_FAIL_COND_V(!src_pkg_zip, ERR_CANT_OPEN);
+ int ret = unzGoToFirstFile(src_pkg_zip);
+
+ String binary_to_use = "godot_osx_" + String(p_debug ? "debug" : "release") + ".";
+ int bits_mode = p_preset->get("application/bits_mode");
+ binary_to_use += String(bits_mode == 0 ? "fat" : bits_mode == 1 ? "64" : "32");
+
+ print_line("binary: " + binary_to_use);
+ String pkg_name;
+ if (p_preset->get("application/name") != "")
+ pkg_name = p_preset->get("application/name"); // app_name
+ else if (String(ProjectSettings::get_singleton()->get("application/config/name")) != "")
+ pkg_name = String(ProjectSettings::get_singleton()->get("application/config/name"));
+ else
+ pkg_name = "Unnamed";
+
+ /* Open our destination zip file */
+ zlib_filefunc_def io2 = io;
+ FileAccess *dst_f = NULL;
+ io2.opaque = &dst_f;
+ zipFile dst_pkg_zip = zipOpen2(p_path.utf8().get_data(), APPEND_STATUS_CREATE, NULL, &io2);
+
+ bool found_binary = false;
+
+ while (ret == UNZ_OK) {
+
+ //get filename
+ unz_file_info info;
+ char fname[16384];
+ ret = unzGetCurrentFileInfo(src_pkg_zip, &info, fname, 16384, NULL, 0, NULL, 0);
+
+ String file = fname;
+
+ print_line("READ: " + file);
+ Vector<uint8_t> data;
+ data.resize(info.uncompressed_size);
+
+ //read
+ unzOpenCurrentFile(src_pkg_zip);
+ unzReadCurrentFile(src_pkg_zip, data.ptr(), data.size());
+ unzCloseCurrentFile(src_pkg_zip);
+
+ //write
+
+ file = file.replace_first("osx_template.app/", "");
+
+ if (file == "Contents/Info.plist") {
+ print_line("parse plist");
+ _fix_plist(p_preset, data, pkg_name);
+ }
+
+ if (file.begins_with("Contents/MacOS/godot_")) {
+ if (file != "Contents/MacOS/" + binary_to_use) {
+ ret = unzGoToNextFile(src_pkg_zip);
+ continue; //ignore!
+ }
+ found_binary = true;
+ file = "Contents/MacOS/" + pkg_name;
+ }
+
+ if (file == "Contents/Resources/icon.icns") {
+ //see if there is an icon
+ String iconpath;
+ if (p_preset->get("application/icon") != "")
+ iconpath = p_preset->get("application/icon");
+ else
+ iconpath = ProjectSettings::get_singleton()->get("application/config/icon");
+ print_line("icon? " + iconpath);
+ if (iconpath != "") {
+ Ref<Image> icon;
+ icon.instance();
+ icon->load(iconpath);
+ if (!icon->empty()) {
+ print_line("loaded?");
+ _make_icon(icon, data);
+ }
+ }
+ //bleh?
+ }
if (data.size() > 0) {
print_line("ADDING: " + file + " size: " + itos(data.size()));
+ /* add it to our zip file */
+ file = pkg_name + ".app/" + file;
+
zip_fileinfo fi;
fi.tmz_date.tm_hour = info.tmu_date.tm_hour;
fi.tmz_date.tm_min = info.tmu_date.tm_min;
@@ -304,7 +578,7 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p
fi.internal_fa = info.internal_fa;
fi.external_fa = info.external_fa;
- int err = zipOpenNewFileInZip(dpkg,
+ int err = zipOpenNewFileInZip(dst_pkg_zip,
file.utf8().get_data(),
&fi,
NULL,
@@ -316,37 +590,37 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p
Z_DEFAULT_COMPRESSION);
print_line("OPEN ERR: " + itos(err));
- err = zipWriteInFileInZip(dpkg, data.ptr(), data.size());
+ err = zipWriteInFileInZip(dst_pkg_zip, data.ptr(), data.size());
print_line("WRITE ERR: " + itos(err));
- zipCloseFileInZip(dpkg);
+ zipCloseFileInZip(dst_pkg_zip);
}
- ret = unzGoToNextFile(pkg);
+ ret = unzGoToNextFile(src_pkg_zip);
}
if (!found_binary) {
ERR_PRINTS("Requested template binary '" + binary_to_use + "' not found. It might be missing from your template archive.");
- zipClose(dpkg, NULL);
- unzClose(pkg);
+ zipClose(dst_pkg_zip, NULL);
+ unzClose(src_pkg_zip);
return ERR_FILE_NOT_FOUND;
}
ep.step("Making PKG", 1);
- String pack_path = EditorSettings::get_singleton()->get_settings_path() + "/tmp/data.pck";
+ String pack_path = EditorSettings::get_singleton()->get_settings_path() + "/tmp/" + pkg_name + ".pck";
Error err = save_pack(p_preset, pack_path);
if (err) {
- zipClose(dpkg, NULL);
- unzClose(pkg);
+ zipClose(dst_pkg_zip, NULL);
+ unzClose(src_pkg_zip);
return err;
}
{
//write datapack
- zipOpenNewFileInZip(dpkg,
- (pkg_name + ".app/Contents/Resources/data.pck").utf8().get_data(),
+ zipOpenNewFileInZip(dst_pkg_zip,
+ (pkg_name + ".app/Contents/Resources/" + pkg_name + ".pck").utf8().get_data(),
NULL,
NULL,
0,
@@ -366,17 +640,18 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p
int r = pf->get_buffer(buf, BSIZE);
if (r <= 0)
break;
- zipWriteInFileInZip(dpkg, buf, r);
+ zipWriteInFileInZip(dst_pkg_zip, buf, r);
}
- zipCloseFileInZip(dpkg);
+ zipCloseFileInZip(dst_pkg_zip);
memdelete(pf);
}
- zipClose(dpkg, NULL);
- unzClose(pkg);
+ zipClose(dst_pkg_zip, NULL);
+ unzClose(src_pkg_zip);
return OK;
}
+#endif
bool EditorExportPlatformOSX::can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const {
diff --git a/platform/osx/os_osx.h b/platform/osx/os_osx.h
index dc3e88df2c..cb9dd1dd8e 100644
--- a/platform/osx/os_osx.h
+++ b/platform/osx/os_osx.h
@@ -101,11 +101,7 @@ public:
bool maximized;
bool zoomed;
- Vector<Rect2> screens;
- Vector<int> screen_dpi;
-
Size2 window_size;
- int current_screen;
Rect2 restore_rect;
power_osx *power_manager;
@@ -117,6 +113,8 @@ public:
return 1.0;
}
+ void _update_window();
+
float display_scale;
protected:
@@ -208,6 +206,8 @@ public:
virtual int get_power_seconds_left();
virtual int get_power_percent_left();
+ virtual bool _check_internal_feature_support(const String &p_feature);
+
void run();
void set_mouse_mode(MouseMode p_mode);
diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm
index ad1e308ae0..4a01532d89 100644
--- a/platform/osx/os_osx.mm
+++ b/platform/osx/os_osx.mm
@@ -80,6 +80,7 @@ static int mouse_y = 0;
static int prev_mouse_x = 0;
static int prev_mouse_y = 0;
static int button_mask = 0;
+static bool mouse_down_control = false;
@interface GodotApplication : NSApplication
@end
@@ -151,6 +152,46 @@ static int button_mask = 0;
return NO;
}
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
+- (void)windowDidEnterFullScreen:(NSNotification *)notification {
+ OS_OSX::singleton->zoomed = true;
+}
+
+- (void)windowDidExitFullScreen:(NSNotification *)notification {
+ OS_OSX::singleton->zoomed = false;
+}
+#endif // MAC_OS_X_VERSION_MAX_ALLOWED
+
+- (void)windowDidChangeBackingProperties:(NSNotification *)notification {
+ if (!OS_OSX::singleton)
+ return;
+
+ NSWindow *window = (NSWindow *)[notification object];
+ CGFloat newBackingScaleFactor = [window backingScaleFactor];
+ CGFloat oldBackingScaleFactor = [[[notification userInfo] objectForKey:@"NSBackingPropertyOldScaleFactorKey"] doubleValue];
+
+ if (newBackingScaleFactor != oldBackingScaleFactor) {
+ //Set new display scale and window size
+ OS_OSX::singleton->display_scale = newBackingScaleFactor;
+
+ const NSRect contentRect = [OS_OSX::singleton->window_view frame];
+ const NSRect fbRect = contentRect; //convertRectToBacking(contentRect);
+
+ OS_OSX::singleton->window_size.width = fbRect.size.width * OS_OSX::singleton->display_scale;
+ OS_OSX::singleton->window_size.height = fbRect.size.height * OS_OSX::singleton->display_scale;
+
+ //Update context
+ if (OS_OSX::singleton->main_loop) {
+ [OS_OSX::singleton->context update];
+
+ //Force window resize ???
+ NSRect frame = [OS_OSX::singleton->window_object frame];
+ [OS_OSX::singleton->window_object setFrame:NSMakeRect(frame.origin.x, frame.origin.y, 1, 1) display:YES];
+ [OS_OSX::singleton->window_object setFrame:frame display:YES];
+ }
+ }
+}
+
- (void)windowDidResize:(NSNotification *)notification {
[OS_OSX::singleton->context update];
@@ -160,6 +201,12 @@ static int button_mask = 0;
OS_OSX::singleton->window_size.width = fbRect.size.width * OS_OSX::singleton->display_scale;
OS_OSX::singleton->window_size.height = fbRect.size.height * OS_OSX::singleton->display_scale;
+ if (OS_OSX::singleton->main_loop) {
+ Main::force_redraw();
+ //Event retrieval blocks until resize is over. Call Main::iteration() directly.
+ Main::iteration();
+ }
+
/*
_GodotInputFramebufferSize(window, fbRect.size.width, fbRect.size.height);
_GodotInputWindowSize(window, contentRect.size.width, contentRect.size.height);
@@ -285,41 +332,48 @@ static int button_mask = 0;
//setModeCursor(window, window->cursorMode);
}
-- (void)mouseDown:(NSEvent *)event {
-
- button_mask |= BUTTON_MASK_LEFT;
+static void _mouseDownEvent(NSEvent *event, int index, int mask, bool pressed) {
+ if (pressed) {
+ button_mask |= mask;
+ } else {
+ button_mask &= ~mask;
+ }
Ref<InputEventMouseButton> mb;
mb.instance();
get_key_modifier_state([event modifierFlags], mb);
- mb->set_button_index(BUTTON_LEFT);
- mb->set_pressed(true);
+ mb->set_button_index(index);
+ mb->set_pressed(pressed);
mb->set_position(Vector2(mouse_x, mouse_y));
mb->set_global_position(Vector2(mouse_x, mouse_y));
mb->set_button_mask(button_mask);
- mb->set_doubleclick([event clickCount] == 2);
+ if (index == BUTTON_LEFT && pressed) {
+ mb->set_doubleclick([event clickCount] == 2);
+ }
OS_OSX::singleton->push_input(mb);
}
+- (void)mouseDown:(NSEvent *)event {
+ if (([event modifierFlags] & NSControlKeyMask)) {
+ mouse_down_control = true;
+ _mouseDownEvent(event, BUTTON_RIGHT, BUTTON_MASK_RIGHT, true);
+ } else {
+ mouse_down_control = false;
+ _mouseDownEvent(event, BUTTON_LEFT, BUTTON_MASK_LEFT, true);
+ }
+}
+
- (void)mouseDragged:(NSEvent *)event {
[self mouseMoved:event];
}
- (void)mouseUp:(NSEvent *)event {
-
- button_mask &= ~BUTTON_MASK_LEFT;
- Ref<InputEventMouseButton> mb;
- mb.instance();
-
- get_key_modifier_state([event modifierFlags], mb);
- mb->set_button_index(BUTTON_LEFT);
- mb->set_pressed(false);
- mb->set_position(Vector2(mouse_x, mouse_y));
- mb->set_global_position(Vector2(mouse_x, mouse_y));
- mb->set_button_mask(button_mask);
- mb->set_doubleclick([event clickCount] == 2);
- OS_OSX::singleton->push_input(mb);
+ if (mouse_down_control) {
+ _mouseDownEvent(event, BUTTON_RIGHT, BUTTON_MASK_RIGHT, false);
+ } else {
+ _mouseDownEvent(event, BUTTON_LEFT, BUTTON_MASK_LEFT, false);
+ }
}
- (void)mouseMoved:(NSEvent *)event {
@@ -347,20 +401,7 @@ static int button_mask = 0;
}
- (void)rightMouseDown:(NSEvent *)event {
-
- button_mask |= BUTTON_MASK_RIGHT;
-
- Ref<InputEventMouseButton> mb;
- mb.instance();
-
- get_key_modifier_state([event modifierFlags], mb);
- mb->set_button_index(BUTTON_RIGHT);
- mb->set_pressed(true);
- mb->set_position(Vector2(mouse_x, mouse_y));
- mb->set_global_position(Vector2(mouse_x, mouse_y));
- mb->set_button_mask(button_mask);
- mb->set_doubleclick([event clickCount] == 2);
- OS_OSX::singleton->push_input(mb);
+ _mouseDownEvent(event, BUTTON_RIGHT, BUTTON_MASK_RIGHT, true);
}
- (void)rightMouseDragged:(NSEvent *)event {
@@ -368,20 +409,7 @@ static int button_mask = 0;
}
- (void)rightMouseUp:(NSEvent *)event {
-
- button_mask &= ~BUTTON_MASK_RIGHT;
-
- Ref<InputEventMouseButton> mb;
- mb.instance();
-
- get_key_modifier_state([event modifierFlags], mb);
- mb->set_button_index(BUTTON_RIGHT);
- mb->set_pressed(false);
- mb->set_position(Vector2(mouse_x, mouse_y));
- mb->set_global_position(Vector2(mouse_x, mouse_y));
- mb->set_button_mask(button_mask);
- mb->set_doubleclick([event clickCount] == 2);
- OS_OSX::singleton->push_input(mb);
+ _mouseDownEvent(event, BUTTON_RIGHT, BUTTON_MASK_RIGHT, false);
}
- (void)otherMouseDown:(NSEvent *)event {
@@ -389,19 +417,7 @@ static int button_mask = 0;
if ((int)[event buttonNumber] != 2)
return;
- button_mask |= BUTTON_MASK_MIDDLE;
-
- Ref<InputEventMouseButton> mb;
- mb.instance();
-
- get_key_modifier_state([event modifierFlags], mb);
- mb->set_button_index(BUTTON_MIDDLE);
- mb->set_pressed(true);
- mb->set_position(Vector2(mouse_x, mouse_y));
- mb->set_global_position(Vector2(mouse_x, mouse_y));
- mb->set_button_mask(button_mask);
- mb->set_doubleclick([event clickCount] == 2);
- OS_OSX::singleton->push_input(mb);
+ _mouseDownEvent(event, BUTTON_MIDDLE, BUTTON_MASK_MIDDLE, true);
}
- (void)otherMouseDragged:(NSEvent *)event {
@@ -413,19 +429,7 @@ static int button_mask = 0;
if ((int)[event buttonNumber] != 2)
return;
- button_mask &= ~BUTTON_MASK_MIDDLE;
-
- Ref<InputEventMouseButton> mb;
- mb.instance();
-
- get_key_modifier_state([event modifierFlags], mb);
- mb->set_button_index(BUTTON_MIDDLE);
- mb->set_pressed(false);
- mb->set_position(Vector2(mouse_x, mouse_y));
- mb->set_global_position(Vector2(mouse_x, mouse_y));
- mb->set_button_mask(button_mask);
- mb->set_doubleclick([event clickCount] == 2);
- OS_OSX::singleton->push_input(mb);
+ _mouseDownEvent(event, BUTTON_MIDDLE, BUTTON_MASK_MIDDLE, false);
}
- (void)mouseExited:(NSEvent *)event {
@@ -554,7 +558,7 @@ static int translateKey(unsigned int key) {
/* 49 */ KEY_UNKNOWN, /* VolumeDown */
/* 4a */ KEY_UNKNOWN, /* Mute */
/* 4b */ KEY_KP_DIVIDE,
- /* 4c */ KEY_KP_ENTER,
+ /* 4c */ KEY_ENTER,
/* 4d */ KEY_UNKNOWN,
/* 4e */ KEY_KP_SUBTRACT,
/* 4f */ KEY_UNKNOWN,
@@ -921,6 +925,8 @@ void OS_OSX::initialize(const VideoMode &p_desired, int p_video_driver, int p_au
[NSApp activateIgnoringOtherApps:YES];
+ _update_window();
+
[window_object makeKeyAndOrderFront:nil];
if (p_desired.fullscreen)
@@ -970,32 +976,6 @@ void OS_OSX::initialize(const VideoMode &p_desired, int p_video_driver, int p_au
_ensure_data_dir();
- NSArray *screenArray = [NSScreen screens];
- printf("nscreen count %i\n", (int)[screenArray count]);
- for (int i = 0; i < [screenArray count]; i++) {
-
- float displayScale = 1.0;
-
- if (display_scale > 1.0 && [[screenArray objectAtIndex:i] respondsToSelector:@selector(backingScaleFactor)]) {
- displayScale = [[screenArray objectAtIndex:i] backingScaleFactor];
- }
-
- NSRect nsrect = [[screenArray objectAtIndex:i] visibleFrame];
- Rect2 rect = Rect2(nsrect.origin.x, nsrect.origin.y, nsrect.size.width, nsrect.size.height);
- rect.position *= displayScale;
- rect.size *= displayScale;
- screens.push_back(rect);
-
- NSDictionary *description = [[screenArray objectAtIndex:i] deviceDescription];
- NSSize displayPixelSize = [[description objectForKey:NSDeviceSize] sizeValue];
- CGSize displayPhysicalSize = CGDisplayScreenSize(
- [[description objectForKey:@"NSScreenNumber"] unsignedIntValue]);
-
- //printf("width: %i pwidth %i rect width %i\n",int(displayPixelSize.width*displayScale),int(displayPhysicalSize.width*displayScale),int(nsrect.size.width));
- int dpi = (displayPixelSize.width * 25.4f / displayPhysicalSize.width) * displayScale;
-
- screen_dpi.push_back(dpi);
- };
restore_rect = Rect2(get_window_position(), get_window_size());
}
@@ -1016,8 +996,6 @@ void OS_OSX::finalize() {
physics_2d_server->finish();
memdelete(physics_2d_server);
-
- screens.clear();
}
void OS_OSX::set_main_loop(MainLoop *p_main_loop) {
@@ -1267,37 +1245,105 @@ void OS_OSX::get_fullscreen_mode_list(List<VideoMode> *p_list, int p_screen) con
}
int OS_OSX::get_screen_count() const {
-
- return screens.size();
+ NSArray *screenArray = [NSScreen screens];
+ return [screenArray count];
};
int OS_OSX::get_current_screen() const {
-
- return current_screen;
+ Vector2 wpos = get_window_position();
+
+ int count = get_screen_count();
+ for (int i = 0; i < count; i++) {
+ Point2 pos = get_screen_position(i);
+ Size2 size = get_screen_size(i);
+ if ((wpos.x >= pos.x && wpos.x < pos.x + size.width) && (wpos.y >= pos.y && wpos.y < pos.y + size.height))
+ return i;
+ }
+ return 0;
};
void OS_OSX::set_current_screen(int p_screen) {
-
- current_screen = p_screen;
+ Vector2 wpos = get_window_position() - get_screen_position(get_current_screen());
+ set_window_position(wpos + get_screen_position(p_screen));
};
Point2 OS_OSX::get_screen_position(int p_screen) const {
+ NSArray *screenArray = [NSScreen screens];
+ if (p_screen < [screenArray count]) {
+ float displayScale = 1.0;
- ERR_FAIL_INDEX_V(p_screen, screens.size(), Point2());
- return screens[p_screen].position;
-};
+ if (display_scale > 1.0 && [[screenArray objectAtIndex:p_screen] respondsToSelector:@selector(backingScaleFactor)]) {
+ displayScale = [[screenArray objectAtIndex:p_screen] backingScaleFactor];
+ }
+
+ NSRect nsrect = [[screenArray objectAtIndex:p_screen] frame];
+ return Point2(nsrect.origin.x, nsrect.origin.y) * displayScale;
+ }
+
+ return Point2();
+}
int OS_OSX::get_screen_dpi(int p_screen) const {
+ NSArray *screenArray = [NSScreen screens];
+ if (p_screen < [screenArray count]) {
+ float displayScale = 1.0;
+
+ if (display_scale > 1.0 && [[screenArray objectAtIndex:p_screen] respondsToSelector:@selector(backingScaleFactor)]) {
+ displayScale = [[screenArray objectAtIndex:p_screen] backingScaleFactor];
+ }
+
+ NSDictionary *description = [[screenArray objectAtIndex:p_screen] deviceDescription];
+ NSSize displayPixelSize = [[description objectForKey:NSDeviceSize] sizeValue];
+ CGSize displayPhysicalSize = CGDisplayScreenSize(
+ [[description objectForKey:@"NSScreenNumber"] unsignedIntValue]);
+
+ return (displayPixelSize.width * 25.4f / displayPhysicalSize.width) * displayScale;
+ }
- ERR_FAIL_INDEX_V(p_screen, screens.size(), 72);
- return screen_dpi[p_screen];
+ return 72;
}
Size2 OS_OSX::get_screen_size(int p_screen) const {
+ NSArray *screenArray = [NSScreen screens];
+ if (p_screen < [screenArray count]) {
+ float displayScale = 1.0;
- ERR_FAIL_INDEX_V(p_screen, screens.size(), Point2());
- return screens[p_screen].size;
-};
+ if (display_scale > 1.0 && [[screenArray objectAtIndex:p_screen] respondsToSelector:@selector(backingScaleFactor)]) {
+ displayScale = [[screenArray objectAtIndex:p_screen] backingScaleFactor];
+ }
+
+ // Note: Use frame to get the whole screen size
+ NSRect nsrect = [[screenArray objectAtIndex:p_screen] frame];
+ return Size2(nsrect.size.width, nsrect.size.height) * displayScale;
+ }
+
+ return Size2();
+}
+
+void OS_OSX::_update_window() {
+ bool borderless_full = false;
+
+ if (get_borderless_window()) {
+ NSRect frameRect = [window_object frame];
+ NSRect screenRect = [[window_object screen] frame];
+
+ // Check if our window covers up the screen
+ if (frameRect.origin.x <= screenRect.origin.x && frameRect.origin.y <= frameRect.origin.y &&
+ frameRect.size.width >= screenRect.size.width && frameRect.size.height >= screenRect.size.height) {
+ borderless_full = true;
+ }
+ }
+
+ if (borderless_full) {
+ // If the window covers up the screen set the level to above the main menu and hide on deactivate
+ [window_object setLevel:NSMainMenuWindowLevel + 1];
+ [window_object setHidesOnDeactivate:YES];
+ } else {
+ // Reset these when our window is not a borderless window that covers up the screen
+ [window_object setLevel:NSNormalWindowLevel];
+ [window_object setHidesOnDeactivate:NO];
+ }
+}
Point2 OS_OSX::get_window_position() const {
@@ -1311,6 +1357,8 @@ void OS_OSX::set_window_position(const Point2 &p_position) {
Point2 size = p_position;
size /= display_scale;
[window_object setFrame:NSMakeRect(size.x, size.y, [window_object frame].size.width, [window_object frame].size.height) display:YES];
+
+ _update_window();
};
Size2 OS_OSX::get_window_size() const {
@@ -1322,17 +1370,22 @@ void OS_OSX::set_window_size(const Size2 p_size) {
Size2 size = p_size;
- // NSRect used by setFrame includes the title bar, so add it to our size.y
- CGFloat menuBarHeight = [[[NSApplication sharedApplication] mainMenu] menuBarHeight];
- if (menuBarHeight != 0.f) {
- size.y += menuBarHeight;
+ if (get_borderless_window() == false) {
+ // NSRect used by setFrame includes the title bar, so add it to our size.y
+ CGFloat menuBarHeight = [[[NSApplication sharedApplication] mainMenu] menuBarHeight];
+ if (menuBarHeight != 0.f) {
+ size.y += menuBarHeight;
#if MAC_OS_X_VERSION_MAX_ALLOWED <= 101104
- } else {
- size.y += [[NSStatusBar systemStatusBar] thickness];
+ } else {
+ size.y += [[NSStatusBar systemStatusBar] thickness];
#endif
+ }
}
+
NSRect frame = [window_object frame];
[window_object setFrame:NSMakeRect(frame.origin.x, frame.origin.y, size.x, size.y) display:YES];
+
+ _update_window();
};
void OS_OSX::set_window_fullscreen(bool p_enabled) {
@@ -1390,7 +1443,7 @@ void OS_OSX::set_window_maximized(bool p_enabled) {
if (p_enabled) {
restore_rect = Rect2(get_window_position(), get_window_size());
- [window_object setFrame:[[[NSScreen screens] objectAtIndex:current_screen] visibleFrame] display:YES];
+ [window_object setFrame:[[[NSScreen screens] objectAtIndex:get_current_screen()] visibleFrame] display:YES];
} else {
set_window_size(restore_rect.size);
set_window_position(restore_rect.position);
@@ -1416,9 +1469,12 @@ void OS_OSX::request_attention() {
void OS_OSX::set_borderless_window(int p_borderless) {
- if (p_borderless)
+ // OrderOut prevents a lose focus bug with the window
+ [window_object orderOut:nil];
+
+ if (p_borderless) {
[window_object setStyleMask:NSWindowStyleMaskBorderless];
- else {
+ } else {
[window_object setStyleMask:NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask];
// Force update of the window styles
@@ -1429,6 +1485,10 @@ void OS_OSX::set_borderless_window(int p_borderless) {
// Restore the window title
[window_object setTitle:[NSString stringWithUTF8String:title.utf8().get_data()]];
}
+
+ _update_window();
+
+ [window_object makeKeyAndOrderFront:nil];
}
bool OS_OSX::get_borderless_window() {
@@ -1661,12 +1721,52 @@ OS_OSX::OS_OSX() {
// In case we are unbundled, make us a proper UI application
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
-#if 0
// Menu bar setup must go between sharedApplication above and
// finishLaunching below, in order to properly emulate the behavior
// of NSApplicationMain
- createMenuBar();
-#endif
+ NSMenuItem *menu_item;
+ NSString *title;
+
+ NSString *nsappname = [[[NSBundle mainBundle] performSelector:@selector(localizedInfoDictionary)] objectForKey:@"CFBundleName"];
+ if (nsappname == nil)
+ nsappname = [[NSProcessInfo processInfo] processName];
+
+ // Setup Apple menu
+ NSMenu *apple_menu = [[NSMenu alloc] initWithTitle:@""];
+ title = [NSString stringWithFormat:NSLocalizedString(@"About %@", nil), nsappname];
+ [apple_menu addItemWithTitle:title action:@selector(orderFrontStandardAboutPanel:) keyEquivalent:@""];
+
+ [apple_menu addItem:[NSMenuItem separatorItem]];
+
+ NSMenu *services = [[NSMenu alloc] initWithTitle:@""];
+ menu_item = [apple_menu addItemWithTitle:NSLocalizedString(@"Services", nil) action:nil keyEquivalent:@""];
+ [apple_menu setSubmenu:services forItem:menu_item];
+ [NSApp setServicesMenu:services];
+ [services release];
+
+ [apple_menu addItem:[NSMenuItem separatorItem]];
+
+ title = [NSString stringWithFormat:NSLocalizedString(@"Hide %@", nil), nsappname];
+ [apple_menu addItemWithTitle:title action:@selector(hide:) keyEquivalent:@"h"];
+
+ menu_item = [apple_menu addItemWithTitle:NSLocalizedString(@"Hide Others", nil) action:@selector(hideOtherApplications:) keyEquivalent:@"h"];
+ [menu_item setKeyEquivalentModifierMask:(NSAlternateKeyMask | NSCommandKeyMask)];
+
+ [apple_menu addItemWithTitle:NSLocalizedString(@"Show all", nil) action:@selector(unhideAllApplications:) keyEquivalent:@""];
+
+ [apple_menu addItem:[NSMenuItem separatorItem]];
+
+ title = [NSString stringWithFormat:NSLocalizedString(@"Quit %@", nil), nsappname];
+ [apple_menu addItemWithTitle:title action:@selector(terminate:) keyEquivalent:@"q"];
+
+ // Setup menu bar
+ NSMenu *main_menu = [[NSMenu alloc] initWithTitle:@""];
+ menu_item = [main_menu addItemWithTitle:@"" action:nil keyEquivalent:@""];
+ [main_menu setSubmenu:apple_menu forItem:menu_item];
+ [NSApp setMainMenu:main_menu];
+
+ [main_menu release];
+ [apple_menu release];
[NSApp finishLaunching];
@@ -1676,11 +1776,13 @@ OS_OSX::OS_OSX() {
cursor_shape = CURSOR_ARROW;
- current_screen = 0;
-
maximized = false;
minimized = false;
window_size = Vector2(1024, 600);
zoomed = false;
display_scale = 1.0;
}
+
+bool OS_OSX::_check_internal_feature_support(const String &p_feature) {
+ return p_feature == "pc" || p_feature == "s3tc";
+}
diff --git a/platform/server/detect.py b/platform/server/detect.py
index 32f3c55135..2bb4b59e94 100644
--- a/platform/server/detect.py
+++ b/platform/server/detect.py
@@ -1,4 +1,3 @@
-
import os
import sys
@@ -13,17 +12,16 @@ def get_name():
def can_build():
- if (os.name != "posix"):
+ if (os.name != "posix" or sys.platform == "darwin"):
return False
- return True # enabled
+ return True
def get_opts():
return [
- ('use_llvm', 'Use llvm compiler', 'no'),
- ('force_32_bits', 'Force 32 bits binary', 'no')
+ ('use_llvm', 'Use the LLVM compiler', 'no'),
]
@@ -35,46 +33,59 @@ def get_flags():
def configure(env):
- env.Append(CPPPATH=['#platform/server'])
- if (env["use_llvm"] == "yes"):
- env["CC"] = "clang"
- env["CXX"] = "clang++"
- env["LD"] = "clang++"
-
- is64 = sys.maxsize > 2**32
-
- if (env["bits"] == "default"):
- if (is64):
- env["bits"] = "64"
- else:
- env["bits"] = "32"
-
- # if (env["tools"]=="no"):
- # #no tools suffix
- # env['OBJSUFFIX'] = ".nt"+env['OBJSUFFIX']
- # env['LIBSUFFIX'] = ".nt"+env['LIBSUFFIX']
+ ## Build type
if (env["target"] == "release"):
-
env.Append(CCFLAGS=['-O2', '-ffast-math', '-fomit-frame-pointer'])
elif (env["target"] == "release_debug"):
-
env.Append(CCFLAGS=['-O2', '-ffast-math', '-DDEBUG_ENABLED'])
elif (env["target"] == "debug"):
-
env.Append(CCFLAGS=['-g2', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED'])
+ ## Architecture
+
+ is64 = sys.maxsize > 2**32
+ if (env["bits"] == "default"):
+ env["bits"] = "64" if is64 else "32"
+
+ ## Compiler configuration
+
+ if (env["use_llvm"] == "yes"):
+ if ('clang++' not in env['CXX']):
+ env["CC"] = "clang"
+ env["CXX"] = "clang++"
+ env["LD"] = "clang++"
+ env.Append(CPPFLAGS=['-DTYPED_METHOD_BIND'])
+ env.extra_suffix = ".llvm" + env.extra_suffix
+
+ ## Dependencies
- # Shared libraries, when requested
+ # FIXME: Check for existence of the libs before parsing their flags with pkg-config
if (env['builtin_openssl'] == 'no'):
+ # Currently not compatible with OpenSSL 1.1.0+
+ # https://github.com/godotengine/godot/issues/8624
+ import subprocess
+ openssl_version = subprocess.check_output(['pkg-config', 'openssl', '--modversion']).strip('\n')
+ if (openssl_version >= "1.1.0"):
+ print("Error: Found system-installed OpenSSL %s, currently only supporting version 1.0.x." % openssl_version)
+ print("Aborting.. You can compile with 'builtin_openssl=yes' to use the bundled version.\n")
+ sys.exit(255)
+
env.ParseConfig('pkg-config openssl --cflags --libs')
if (env['builtin_libwebp'] == 'no'):
env.ParseConfig('pkg-config libwebp --cflags --libs')
+ # freetype depends on libpng and zlib, so bundling one of them while keeping others
+ # as shared libraries leads to weird issues
+ if (env['builtin_freetype'] == 'yes' or env['builtin_libpng'] == 'yes' or env['builtin_zlib'] == 'yes'):
+ env['builtin_freetype'] = 'yes'
+ env['builtin_libpng'] = 'yes'
+ env['builtin_zlib'] = 'yes'
+
if (env['builtin_freetype'] == 'no'):
env.ParseConfig('pkg-config freetype2 --cflags --libs')
@@ -109,11 +120,12 @@ def configure(env):
if (env['builtin_libogg'] == 'no'):
env.ParseConfig('pkg-config ogg --cflags --libs')
+ ## Flags
- env.Append(CPPFLAGS=['-DSERVER_ENABLED', '-DUNIX_ENABLED'])
- env.Append(LIBS=['pthread', 'z']) # TODO detect linux/BSD!
+ # Linkflags below this line should typically stay the last ones
+ if (env['builtin_zlib'] == 'no'):
+ env.ParseConfig('pkg-config zlib --cflags --libs')
- if (env["CXX"] == "clang++"):
- env.Append(CPPFLAGS=['-DTYPED_METHOD_BIND'])
- env["CC"] = "clang"
- env["LD"] = "clang++"
+ env.Append(CPPPATH=['#platform/server'])
+ env.Append(CPPFLAGS=['-DSERVER_ENABLED', '-DUNIX_ENABLED'])
+ env.Append(LIBS=['pthread'])
diff --git a/platform/uwp/detect.py b/platform/uwp/detect.py
index baff7f9788..64dac93f1f 100644
--- a/platform/uwp/detect.py
+++ b/platform/uwp/detect.py
@@ -1,8 +1,7 @@
+import methods
import os
-
-import sys
import string
-import methods
+import sys
def is_active():
@@ -26,7 +25,9 @@ def can_build():
def get_opts():
- return []
+
+ return [
+ ]
def get_flags():
@@ -39,16 +40,36 @@ def get_flags():
def configure(env):
- if(env["bits"] != "default"):
- print "Error: bits argument is disabled for MSVC"
- print ("Bits argument is not supported for MSVC compilation. Architecture depends on the Native/Cross Compile Tools Prompt/Developer Console (or Visual Studio settings)"
- + " that is being used to run SCons. As a consequence, bits argument is disabled. Run scons again without bits argument (example: scons p=uwp) and SCons will attempt to detect what MSVC compiler"
- + " will be executed and inform you.")
+ if (env["bits"] != "default"):
+ print("Error: bits argument is disabled for MSVC")
+ print("""
+ Bits argument is not supported for MSVC compilation. Architecture depends on the Native/Cross Compile Tools Prompt/Developer Console
+ (or Visual Studio settings) that is being used to run SCons. As a consequence, bits argument is disabled. Run scons again without bits
+ argument (example: scons p=uwp) and SCons will attempt to detect what MSVC compiler will be executed and inform you.
+ """)
sys.exit()
- arch = ""
- env['ENV'] = os.environ
+ ## Build type
+ if (env["target"] == "release"):
+ env.Append(CPPFLAGS=['/O2', '/GL'])
+ env.Append(CPPFLAGS=['/MD'])
+ env.Append(LINKFLAGS=['/SUBSYSTEM:WINDOWS', '/LTCG'])
+
+ elif (env["target"] == "release_debug"):
+ env.Append(CCFLAGS=['/O2', '/Zi', '/DDEBUG_ENABLED'])
+ env.Append(CPPFLAGS=['/MD'])
+ env.Append(LINKFLAGS=['/SUBSYSTEM:CONSOLE'])
+
+ elif (env["target"] == "debug"):
+ env.Append(CCFLAGS=['/Zi', '/DDEBUG_ENABLED', '/DDEBUG_MEMORY_ENABLED'])
+ env.Append(CPPFLAGS=['/MDd'])
+ env.Append(LINKFLAGS=['/SUBSYSTEM:CONSOLE'])
+ env.Append(LINKFLAGS=['/DEBUG'])
+
+ ## Compiler configuration
+
+ env['ENV'] = os.environ
vc_base_path = os.environ['VCTOOLSINSTALLDIR'] if "VCTOOLSINSTALLDIR" in os.environ else os.environ['VCINSTALLDIR']
# ANGLE
@@ -60,9 +81,12 @@ def configure(env):
if os.path.isfile(str(os.getenv("ANGLE_SRC_PATH")) + "/winrt/10/src/angle.sln"):
env["build_angle"] = True
+ ## Architecture
+
+ arch = ""
if os.getenv('Platform') == "ARM":
- print "Compiled program architecture will be an ARM executable. (forcing bits=32)."
+ print("Compiled program architecture will be an ARM executable. (forcing bits=32).")
arch = "arm"
env["bits"] = "32"
@@ -74,17 +98,16 @@ def configure(env):
env.Append(LIBPATH=[angle_root + '/winrt/10/src/Release_ARM/lib'])
else:
-
compiler_version_str = methods.detect_visual_c_compiler_version(env['ENV'])
if(compiler_version_str == "amd64" or compiler_version_str == "x86_amd64"):
env["bits"] = "64"
- print "Compiled program architecture will be a x64 executable (forcing bits=64)."
+ print("Compiled program architecture will be a x64 executable (forcing bits=64).")
elif (compiler_version_str == "x86" or compiler_version_str == "amd64_x86"):
env["bits"] = "32"
- print "Compiled program architecture will be a x86 executable. (forcing bits=32)."
+ print("Compiled program architecture will be a x86 executable. (forcing bits=32).")
else:
- print "Failed to detect MSVC compiler architecture version... Defaulting to 32bit executable settings (forcing bits=32). Compilation attempt will continue, but SCons can not detect for what architecture this build is compiled for. You should check your settings/compilation setup."
+ print("Failed to detect MSVC compiler architecture version... Defaulting to 32bit executable settings (forcing bits=32). Compilation attempt will continue, but SCons can not detect for what architecture this build is compiled for. You should check your settings/compilation setup.")
env["bits"] = "32"
if (env["bits"] == "32"):
@@ -92,7 +115,6 @@ def configure(env):
angle_build_cmd += "Win32"
- env.Append(CPPFLAGS=['/DPNG_ABORT=abort'])
env.Append(LINKFLAGS=['/MACHINE:X86'])
env.Append(LIBPATH=[vc_base_path + 'lib/store'])
env.Append(LIBPATH=[angle_root + '/winrt/10/src/Release_Win32/lib'])
@@ -106,48 +128,30 @@ def configure(env):
env.Append(LIBPATH=[os.environ['VCINSTALLDIR'] + 'lib/store/amd64'])
env.Append(LIBPATH=[angle_root + '/winrt/10/src/Release_x64/lib'])
- env.Append(CPPPATH=['#platform/uwp', '#drivers/windows'])
- env.Append(LINKFLAGS=['/MANIFEST:NO', '/NXCOMPAT', '/DYNAMICBASE', '/WINMD', '/APPCONTAINER', '/ERRORREPORT:PROMPT', '/NOLOGO', '/TLBID:1', '/NODEFAULTLIB:"kernel32.lib"', '/NODEFAULTLIB:"ole32.lib"'])
- env.Append(CPPFLAGS=['/D', '__WRL_NO_DEFAULT_LIB__', '/D', 'WIN32'])
-
- env.Append(CPPFLAGS=['/AI', vc_base_path + 'lib/store/references'])
- env.Append(CPPFLAGS=['/AI', vc_base_path + 'lib/x86/store/references'])
+ env["PROGSUFFIX"] = "." + arch + env["PROGSUFFIX"]
+ env["OBJSUFFIX"] = "." + arch + env["OBJSUFFIX"]
+ env["LIBSUFFIX"] = "." + arch + env["LIBSUFFIX"]
- if (env["target"] == "release"):
+ ## Compile flags
- env.Append(CPPFLAGS=['/O2', '/GL'])
- env.Append(CPPFLAGS=['/MD'])
- env.Append(LINKFLAGS=['/SUBSYSTEM:WINDOWS', '/LTCG'])
-
- elif (env["target"] == "release_debug"):
-
- env.Append(CCFLAGS=['/O2', '/Zi', '/DDEBUG_ENABLED'])
- env.Append(CPPFLAGS=['/MD'])
- env.Append(LINKFLAGS=['/SUBSYSTEM:CONSOLE'])
+ env.Append(CPPPATH=['#platform/uwp', '#drivers/windows'])
+ env.Append(CCFLAGS=['/DUWP_ENABLED', '/DWINDOWS_ENABLED', '/DTYPED_METHOD_BIND'])
+ env.Append(CCFLAGS=['/DGLES2_ENABLED', '/DGL_GLEXT_PROTOTYPES', '/DEGL_EGLEXT_PROTOTYPES', '/DANGLE_ENABLED'])
+ winver = "0x0602" # Windows 8 is the minimum target for UWP build
+ env.Append(CCFLAGS=['/DWINVER=%s' % winver, '/D_WIN32_WINNT=%s' % winver])
- elif (env["target"] == "debug"):
+ env.Append(CPPFLAGS=['/D', '__WRL_NO_DEFAULT_LIB__', '/D', 'WIN32', '/DPNG_ABORT=abort'])
- env.Append(CCFLAGS=['/Zi', '/DDEBUG_ENABLED', '/DDEBUG_MEMORY_ENABLED'])
- env.Append(CPPFLAGS=['/MDd'])
- env.Append(LINKFLAGS=['/SUBSYSTEM:CONSOLE'])
- env.Append(LINKFLAGS=['/DEBUG'])
+ env.Append(CPPFLAGS=['/AI', vc_base_path + 'lib/store/references'])
+ env.Append(CPPFLAGS=['/AI', vc_base_path + 'lib/x86/store/references'])
env.Append(CCFLAGS=string.split('/FS /MP /GS /wd"4453" /wd"28204" /wd"4291" /Zc:wchar_t /Gm- /fp:precise /D "_UNICODE" /D "UNICODE" /D "WINAPI_FAMILY=WINAPI_FAMILY_APP" /errorReport:prompt /WX- /Zc:forScope /Gd /EHsc /nologo'))
env.Append(CXXFLAGS=string.split('/ZW /FS'))
env.Append(CCFLAGS=['/AI', vc_base_path + '\\vcpackages', '/AI', os.environ['WINDOWSSDKDIR'] + '\\References\\CommonConfiguration\\Neutral'])
- env["PROGSUFFIX"] = "." + arch + env["PROGSUFFIX"]
- env["OBJSUFFIX"] = "." + arch + env["OBJSUFFIX"]
- env["LIBSUFFIX"] = "." + arch + env["LIBSUFFIX"]
-
- env.Append(CCFLAGS=['/DUWP_ENABLED'])
- env.Append(CCFLAGS=['/DWINDOWS_ENABLED'])
- env.Append(CCFLAGS=['/DTYPED_METHOD_BIND'])
-
- env.Append(CCFLAGS=['/DGLES2_ENABLED', '/DGL_GLEXT_PROTOTYPES', '/DEGL_EGLEXT_PROTOTYPES', '/DANGLE_ENABLED'])
+ ## Link flags
- winver = "0x0602" # Windows 8 is the minimum target for UWP build
- env.Append(CCFLAGS=['/DWINVER=%s' % winver, '/D_WIN32_WINNT=%s' % winver])
+ env.Append(LINKFLAGS=['/MANIFEST:NO', '/NXCOMPAT', '/DYNAMICBASE', '/WINMD', '/APPCONTAINER', '/ERRORREPORT:PROMPT', '/NOLOGO', '/TLBID:1', '/NODEFAULTLIB:"kernel32.lib"', '/NODEFAULTLIB:"ole32.lib"'])
LIBS = [
'WindowsApp',
@@ -164,8 +168,3 @@ def configure(env):
env['BUILDERS']['Program'] = methods.precious_program
env.Append(BUILDERS={'ANGLE': env.Builder(action=angle_build_cmd)})
-
- env.Append(BUILDERS={'GLSL120': env.Builder(action=methods.build_legacygl_headers, suffix='glsl.h', src_suffix='.glsl')})
- env.Append(BUILDERS={'GLSL': env.Builder(action=methods.build_glsl_headers, suffix='glsl.h', src_suffix='.glsl')})
- env.Append(BUILDERS={'HLSL9': env.Builder(action=methods.build_hlsl_dx9_headers, suffix='hlsl.h', src_suffix='.hlsl')})
- env.Append(BUILDERS={'GLSL120GLES': env.Builder(action=methods.build_gles2_headers, suffix='glsl.h', src_suffix='.glsl')})
diff --git a/platform/uwp/export/export.cpp b/platform/uwp/export/export.cpp
index 976e6208ee..a1aa58a5e7 100644
--- a/platform/uwp/export/export.cpp
+++ b/platform/uwp/export/export.cpp
@@ -28,55 +28,16 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-/*************************************************************************
- * The code for signing the package was ported from fb-util-for-appx
- * available at https://github.com/facebook/fb-util-for-appx
- * and distributed also under the following license:
-
-BSD License
-
-For fb-util-for-appx software
-
-Copyright (c) 2016, Facebook, Inc. All rights reserved.
-
-Redistribution and use in source and binary forms, with or without modification,
-are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice, this
- list of conditions and the following disclaimer.
-
- * Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
- * Neither the name Facebook nor the names of its contributors may be used to
- endorse or promote products derived from this software without specific
- prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
-ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-*************************************************************************/
-
-#if 0
#include "export.h"
#include "bind/core_bind.h"
-#include "editor/editor_import_export.h"
+#include "editor/editor_export.h"
#include "editor/editor_node.h"
-#include "global_config.h"
#include "io/marshalls.h"
#include "io/zip_io.h"
#include "object.h"
#include "os/file_access.h"
-#include "platform/uwp/logo.h"
+#include "platform/uwp/logo.gen.h"
+#include "project_settings.h"
#include "version.h"
#include "thirdparty/minizip/unzip.h"
@@ -87,7 +48,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <zlib.h>
// Capabilities
-static const char* uwp_capabilities[] = {
+static const char *uwp_capabilities[] = {
"allJoyn",
"codeGeneration",
"internetClient",
@@ -95,7 +56,7 @@ static const char* uwp_capabilities[] = {
"privateNetworkClientServer",
NULL
};
-static const char* uwp_uap_capabilities[] = {
+static const char *uwp_uap_capabilities[] = {
"appointments",
"blockedChatMessages",
"chat",
@@ -112,7 +73,7 @@ static const char* uwp_uap_capabilities[] = {
"voipCall",
NULL
};
-static const char* uwp_device_capabilites[] = {
+static const char *uwp_device_capabilites[] = {
"bluetooth",
"location",
"microphone",
@@ -121,166 +82,6 @@ static const char* uwp_device_capabilites[] = {
NULL
};
-#ifdef OPENSSL_ENABLED
-#include <openssl/asn1.h>
-#include <openssl/asn1t.h>
-#include <openssl/bio.h>
-#include <openssl/err.h>
-#include <openssl/ossl_typ.h>
-#include <openssl/pkcs12.h>
-#include <openssl/pkcs7.h>
-#include <openssl/x509.h>
-
-namespace asn1 {
- // https://msdn.microsoft.com/en-us/gg463180.aspx
-
- struct SPCStatementType {
- ASN1_OBJECT *type;
- };
- DECLARE_ASN1_FUNCTIONS(SPCStatementType)
-
- struct SPCSpOpusInfo {
- ASN1_TYPE *programName;
- ASN1_TYPE *moreInfo;
- };
- DECLARE_ASN1_FUNCTIONS(SPCSpOpusInfo)
-
- struct DigestInfo {
- X509_ALGOR *digestAlgorithm;
- ASN1_OCTET_STRING *digest;
- };
- DECLARE_ASN1_FUNCTIONS(DigestInfo)
-
- struct SPCAttributeTypeAndOptionalValue {
- ASN1_OBJECT *type;
- ASN1_TYPE *value; // SPCInfoValue
- };
- DECLARE_ASN1_FUNCTIONS(SPCAttributeTypeAndOptionalValue)
-
- // Undocumented.
- struct SPCInfoValue {
- ASN1_INTEGER *i1;
- ASN1_OCTET_STRING *s1;
- ASN1_INTEGER *i2;
- ASN1_INTEGER *i3;
- ASN1_INTEGER *i4;
- ASN1_INTEGER *i5;
- ASN1_INTEGER *i6;
- };
- DECLARE_ASN1_FUNCTIONS(SPCInfoValue)
-
- struct SPCIndirectDataContent {
- SPCAttributeTypeAndOptionalValue *data;
- DigestInfo *messageDigest;
- };
- DECLARE_ASN1_FUNCTIONS(SPCIndirectDataContent)
-
- IMPLEMENT_ASN1_FUNCTIONS(SPCIndirectDataContent)
- ASN1_SEQUENCE(SPCIndirectDataContent) = {
- ASN1_SIMPLE(SPCIndirectDataContent, data,
- SPCAttributeTypeAndOptionalValue),
- ASN1_SIMPLE(SPCIndirectDataContent, messageDigest, DigestInfo),
- } ASN1_SEQUENCE_END(SPCIndirectDataContent)
-
- IMPLEMENT_ASN1_FUNCTIONS(SPCAttributeTypeAndOptionalValue)
- ASN1_SEQUENCE(SPCAttributeTypeAndOptionalValue) = {
- ASN1_SIMPLE(SPCAttributeTypeAndOptionalValue, type,
- ASN1_OBJECT),
- ASN1_OPT(SPCAttributeTypeAndOptionalValue, value, ASN1_ANY),
- } ASN1_SEQUENCE_END(SPCAttributeTypeAndOptionalValue)
-
- IMPLEMENT_ASN1_FUNCTIONS(SPCInfoValue)
- ASN1_SEQUENCE(SPCInfoValue) = {
- ASN1_SIMPLE(SPCInfoValue, i1, ASN1_INTEGER),
- ASN1_SIMPLE(SPCInfoValue, s1, ASN1_OCTET_STRING),
- ASN1_SIMPLE(SPCInfoValue, i2, ASN1_INTEGER),
- ASN1_SIMPLE(SPCInfoValue, i3, ASN1_INTEGER),
- ASN1_SIMPLE(SPCInfoValue, i4, ASN1_INTEGER),
- ASN1_SIMPLE(SPCInfoValue, i5, ASN1_INTEGER),
- ASN1_SIMPLE(SPCInfoValue, i6, ASN1_INTEGER),
- } ASN1_SEQUENCE_END(SPCInfoValue)
-
- IMPLEMENT_ASN1_FUNCTIONS(DigestInfo)
- ASN1_SEQUENCE(DigestInfo) = {
- ASN1_SIMPLE(DigestInfo, digestAlgorithm, X509_ALGOR),
- ASN1_SIMPLE(DigestInfo, digest, ASN1_OCTET_STRING),
- } ASN1_SEQUENCE_END(DigestInfo)
-
- ASN1_SEQUENCE(SPCSpOpusInfo) = {
- ASN1_OPT(SPCSpOpusInfo, programName, ASN1_ANY),
- ASN1_OPT(SPCSpOpusInfo, moreInfo, ASN1_ANY),
- } ASN1_SEQUENCE_END(SPCSpOpusInfo)
- IMPLEMENT_ASN1_FUNCTIONS(SPCSpOpusInfo)
-
- ASN1_SEQUENCE(SPCStatementType) = {
- ASN1_SIMPLE(SPCStatementType, type, ASN1_OBJECT),
- } ASN1_SEQUENCE_END(SPCStatementType)
- IMPLEMENT_ASN1_FUNCTIONS(SPCStatementType)
-}
-
-class EncodedASN1 {
-
- uint8_t* i_data;
- size_t i_size;
-
- EncodedASN1(uint8_t** p_data, size_t p_size) {
-
- i_data = *p_data;
- i_size = p_size;
- }
-
-public:
-
- template <typename T, int(*TEncode)(T *, uint8_t **)>
- static EncodedASN1 FromItem(T *item) {
- uint8_t *dataRaw = NULL;
- int size = TEncode(item, &dataRaw);
-
- return EncodedASN1(&dataRaw, size);
- }
-
- const uint8_t *data() const {
- return i_data;
- }
-
- size_t size() const {
- return i_size;
- }
-
- // Assumes the encoded ASN.1 represents a SEQUENCE and puts it into
- // an ASN1_STRING.
- //
- // The returned object holds a copy of this object's data.
- ASN1_STRING* ToSequenceString() {
- ASN1_STRING* string = ASN1_STRING_new();
- if (!string) {
- return NULL;
- }
- if (!ASN1_STRING_set(string, i_data, i_size)) {
- return NULL;
- }
- return string;
- }
-
- // Assumes the encoded ASN.1 represents a SEQUENCE and puts it into
- // an ASN1_TYPE.
- //
- // The returned object holds a copy of this object's data.
- ASN1_TYPE* ToSequenceType() {
- ASN1_STRING* string = ToSequenceString();
- ASN1_TYPE* type = ASN1_TYPE_new();
- if (!type) {
- return NULL;
- }
- type->type = V_ASN1_SEQUENCE;
- type->value.sequence = string;
- return type;
- }
-
-};
-
-#endif // OPENSSL_ENABLED
-
class AppxPackager {
enum {
@@ -336,34 +137,33 @@ class AppxPackager {
ZPOS64_T end_of_central_dir_offset;
Vector<uint8_t> central_dir_data;
- String hash_block(uint8_t* p_block_data, size_t p_block_len);
+ String hash_block(uint8_t *p_block_data, size_t p_block_len);
void make_block_map();
void make_content_types();
-
- _FORCE_INLINE_ unsigned int buf_put_int16(uint16_t p_val, uint8_t * p_buf) {
+ _FORCE_INLINE_ unsigned int buf_put_int16(uint16_t p_val, uint8_t *p_buf) {
for (int i = 0; i < 2; i++) {
*p_buf++ = (p_val >> (i * 8)) & 0xFF;
}
return 2;
}
- _FORCE_INLINE_ unsigned int buf_put_int32(uint32_t p_val, uint8_t * p_buf) {
+ _FORCE_INLINE_ unsigned int buf_put_int32(uint32_t p_val, uint8_t *p_buf) {
for (int i = 0; i < 4; i++) {
*p_buf++ = (p_val >> (i * 8)) & 0xFF;
}
return 4;
}
- _FORCE_INLINE_ unsigned int buf_put_int64(uint64_t p_val, uint8_t * p_buf) {
+ _FORCE_INLINE_ unsigned int buf_put_int64(uint64_t p_val, uint8_t *p_buf) {
for (int i = 0; i < 8; i++) {
*p_buf++ = (p_val >> (i * 8)) & 0xFF;
}
return 8;
}
- _FORCE_INLINE_ unsigned int buf_put_string(String p_val, uint8_t * p_buf) {
+ _FORCE_INLINE_ unsigned int buf_put_string(String p_val, uint8_t *p_buf) {
for (int i = 0; i < p_val.length(); i++) {
*p_buf++ = p_val.utf8().get(i);
}
@@ -376,168 +176,19 @@ class AppxPackager {
String content_type(String p_extension);
-#ifdef OPENSSL_ENABLED
-
- // Signing methods and structs:
-
- String certificate_path;
- String certificate_pass;
- bool sign_package;
-
- struct CertFile {
-
- EVP_PKEY* private_key;
- X509* certificate;
- };
-
- SHA256_CTX axpc_context; // SHA256 context for ZIP file entries
- SHA256_CTX axcd_context; // SHA256 context for ZIP directory entries
-
- struct AppxDigests {
-
- uint8_t axpc[SHA256_DIGEST_LENGTH]; // ZIP file entries
- uint8_t axcd[SHA256_DIGEST_LENGTH]; // ZIP directory entry
- uint8_t axct[SHA256_DIGEST_LENGTH]; // Content types XML
- uint8_t axbm[SHA256_DIGEST_LENGTH]; // Block map XML
- uint8_t axci[SHA256_DIGEST_LENGTH]; // Code Integrity file (optional)
- };
-
- CertFile cert_file;
- AppxDigests digests;
-
- void MakeSPCInfoValue(asn1::SPCInfoValue &info);
- Error MakeIndirectDataContent(asn1::SPCIndirectDataContent &idc);
- Error add_attributes(PKCS7_SIGNER_INFO *signerInfo);
- void make_digests();
- void write_digest(Vector<uint8_t> &p_out_buffer);
-
- Error openssl_error(unsigned long p_err);
- Error read_cert_file(const String &p_path, const String &p_password, CertFile* p_out_cf);
- Error sign(const CertFile &p_cert, const AppxDigests &digests, PKCS7* p_out_signature);
-
-#endif // OPENSSL_ENABLED
-
public:
-
- enum SignOption {
-
- SIGN,
- DONT_SIGN,
- };
-
void set_progress_task(String p_task) { progress_task = p_task; }
- void init(FileAccess* p_fa, SignOption p_sign, String &p_certificate_path, String &p_certificate_password);
- void add_file(String p_file_name, const uint8_t* p_buffer, size_t p_len, int p_file_no, int p_total_files, bool p_compress = false);
+ void init(FileAccess *p_fa);
+ void add_file(String p_file_name, const uint8_t *p_buffer, size_t p_len, int p_file_no, int p_total_files, bool p_compress = false);
void finish();
AppxPackager();
~AppxPackager();
};
-class EditorExportPlatformUWP : public EditorExportPlatform {
-
- GDCLASS(EditorExportPlatformUWP, EditorExportPlatform);
-
- Ref<ImageTexture> logo;
-
- enum Platform {
- ARM,
- X86,
- X64
- } arch;
-
- bool is_debug;
-
- String custom_release_package;
- String custom_debug_package;
-
- String cmdline;
-
- String display_name;
- String short_name;
- String unique_name;
- String description;
- String publisher;
- String publisher_display_name;
-
- String product_guid;
- String publisher_guid;
-
- int version_major;
- int version_minor;
- int version_build;
- int version_revision;
-
- bool orientation_landscape;
- bool orientation_portrait;
- bool orientation_landscape_flipped;
- bool orientation_portrait_flipped;
-
- String background_color;
- Ref<ImageTexture> store_logo;
- Ref<ImageTexture> square44;
- Ref<ImageTexture> square71;
- Ref<ImageTexture> square150;
- Ref<ImageTexture> square310;
- Ref<ImageTexture> wide310;
- Ref<ImageTexture> splash;
-
- bool name_on_square150;
- bool name_on_square310;
- bool name_on_wide;
-
- Set<String> capabilities;
- Set<String> uap_capabilities;
- Set<String> device_capabilities;
-
- bool sign_package;
- String certificate_path;
- String certificate_pass;
-
- _FORCE_INLINE_ bool array_has(const char** p_array, const char* p_value) const {
- while (*p_array) {
- if (String(*p_array) == String(p_value)) return true;
- p_array++;
- }
- return false;
- }
-
- bool _valid_resource_name(const String &p_name) const;
- bool _valid_guid(const String &p_guid) const;
- bool _valid_bgcolor(const String &p_color) const;
- bool _valid_image(const Ref<ImageTexture> p_image, int p_width, int p_height) const;
-
- Vector<uint8_t> _fix_manifest(const Vector<uint8_t> &p_template, bool p_give_internet) const;
- Vector<uint8_t> _get_image_data(const String &p_path);
-
- static Error save_appx_file(void *p_userdata, const String& p_path, const Vector<uint8_t>& p_data, int p_file, int p_total);
- static bool _should_compress_asset(const String& p_path, const Vector<uint8_t>& p_data);
-
-protected:
-
- bool _set(const StringName& p_name, const Variant& p_value);
- bool _get(const StringName& p_name, Variant &r_ret) const;
- void _get_property_list(List<PropertyInfo> *p_list) const;
-
-public:
-
- virtual String get_name() const { return "Windows Universal"; }
- virtual ImageCompression get_image_compression() const { return IMAGE_COMPRESSION_ETC1; }
- virtual Ref<Texture> get_logo() const { return logo; }
-
- virtual bool can_export(String *r_error = NULL) const;
- virtual String get_binary_extension() const { return "appx"; }
-
- virtual Error export_project(const String& p_path, bool p_debug, int p_flags = 0);
-
- EditorExportPlatformUWP();
- ~EditorExportPlatformUWP();
-};
-
-
///////////////////////////////////////////////////////////////////////////
-String AppxPackager::hash_block(uint8_t * p_block_data, size_t p_block_len) {
+String AppxPackager::hash_block(uint8_t *p_block_data, size_t p_block_len) {
char hash[32];
char base64[45];
@@ -545,7 +196,7 @@ String AppxPackager::hash_block(uint8_t * p_block_data, size_t p_block_len) {
sha256_context ctx;
sha256_init(&ctx);
sha256_hash(&ctx, p_block_data, p_block_len);
- sha256_done(&ctx, (uint8_t*)hash);
+ sha256_done(&ctx, (uint8_t *)hash);
base64_encode(base64, hash, 32);
base64[44] = '\0';
@@ -555,7 +206,7 @@ String AppxPackager::hash_block(uint8_t * p_block_data, size_t p_block_len) {
void AppxPackager::make_block_map() {
- FileAccess* tmp_file = FileAccess::open(tmp_blockmap_file_path, FileAccess::WRITE);
+ FileAccess *tmp_file = FileAccess::open(tmp_blockmap_file_path, FileAccess::WRITE);
tmp_file->store_string("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>");
tmp_file->store_string("<BlockMap xmlns=\"http://schemas.microsoft.com/appx/2010/blockmap\" HashMethod=\"http://www.w3.org/2001/04/xmlenc#sha256\">");
@@ -565,15 +216,11 @@ void AppxPackager::make_block_map() {
FileMeta file = file_metadata[i];
tmp_file->store_string(
- "<File Name=\"" + file.name.replace("/", "\\")
- + "\" Size=\"" + itos(file.uncompressed_size)
- + "\" LfhSize=\"" + itos(file.lfh_size) + "\">");
-
+ "<File Name=\"" + file.name.replace("/", "\\") + "\" Size=\"" + itos(file.uncompressed_size) + "\" LfhSize=\"" + itos(file.lfh_size) + "\">");
for (int j = 0; j < file.hashes.size(); j++) {
- tmp_file->store_string("<Block Hash=\""
- + file.hashes[j].base64_hash + "\" ");
+ tmp_file->store_string("<Block Hash=\"" + file.hashes[j].base64_hash + "\" ");
if (file.compressed)
tmp_file->store_string("Size=\"" + itos(file.hashes[j].compressed_size) + "\" ");
tmp_file->store_string("/>");
@@ -605,12 +252,12 @@ String AppxPackager::content_type(String p_extension) {
void AppxPackager::make_content_types() {
- FileAccess* tmp_file = FileAccess::open(tmp_content_types_file_path, FileAccess::WRITE);
+ FileAccess *tmp_file = FileAccess::open(tmp_content_types_file_path, FileAccess::WRITE);
tmp_file->store_string("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
tmp_file->store_string("<Types xmlns=\"http://schemas.openxmlformats.org/package/2006/content-types\">");
- Map<String, String> types;
+ Map<String, String> types;
for (int i = 0; i < file_metadata.size(); i++) {
@@ -688,7 +335,6 @@ void AppxPackager::store_central_dir_header(const FileMeta p_file, bool p_do_has
int offs = buf.size();
buf.resize(buf.size() + BASE_CENTRAL_DIR_SIZE + p_file.name.length());
-
// Write magic
offs += buf_put_int32(CENTRAL_DIR_MAGIC, &buf[offs]);
@@ -732,12 +378,6 @@ void AppxPackager::store_central_dir_header(const FileMeta p_file, bool p_do_has
// File name
offs += buf_put_string(p_file.name, &buf[offs]);
-#ifdef OPENSSL_ENABLED
- // Calculate the hash for signing
- if (p_do_hash)
- SHA256_Update(&axcd_context, buf.ptr(), buf.size());
-#endif // OPENSSL_ENABLED
-
// Done!
}
@@ -811,23 +451,16 @@ Vector<uint8_t> AppxPackager::make_end_of_central_record() {
return buf;
}
-void AppxPackager::init(FileAccess * p_fa, SignOption p_sign, String &p_certificate_path, String &p_certificate_password) {
+void AppxPackager::init(FileAccess *p_fa) {
package = p_fa;
central_dir_offset = 0;
end_of_central_dir_offset = 0;
tmp_blockmap_file_path = EditorSettings::get_singleton()->get_settings_path() + "/tmp/tmpblockmap.xml";
tmp_content_types_file_path = EditorSettings::get_singleton()->get_settings_path() + "/tmp/tmpcontenttypes.xml";
-#ifdef OPENSSL_ENABLED
- certificate_path = p_certificate_path;
- certificate_pass = p_certificate_password;
- sign_package = p_sign == SIGN;
- SHA256_Init(&axpc_context);
- SHA256_Init(&axcd_context);
-#endif // OPENSSL_ENABLED
}
-void AppxPackager::add_file(String p_file_name, const uint8_t * p_buffer, size_t p_len, int p_file_no, int p_total_files, bool p_compress) {
+void AppxPackager::add_file(String p_file_name, const uint8_t *p_buffer, size_t p_len, int p_file_no, int p_total_files, bool p_compress) {
if (p_file_no >= 1 && p_total_files >= 1) {
EditorNode::progress_task_step(progress_task, "File: " + p_file_name, (p_file_no * 100) / p_total_files);
@@ -846,7 +479,7 @@ void AppxPackager::add_file(String p_file_name, const uint8_t * p_buffer, size_t
// Data for compression
z_stream strm;
- FileAccess* strm_f = NULL;
+ FileAccess *strm_f = NULL;
Vector<uint8_t> strm_in;
strm_in.resize(BLOCK_SIZE);
Vector<uint8_t> strm_out;
@@ -892,11 +525,6 @@ void AppxPackager::add_file(String p_file_name, const uint8_t * p_buffer, size_t
file_buffer.resize(file_buffer.size() + bh.compressed_size);
for (int i = 0; i < bh.compressed_size; i++)
file_buffer[start + i] = strm_out[i];
-#ifdef OPENSSL_ENABLED
- if (do_hash)
- SHA256_Update(&axpc_context, strm_out.ptr(), strm.total_out - total_out_before);
-#endif // OPENSSL_ENABLED
-
} else {
bh.compressed_size = block_size;
//package->store_buffer(strm_in.ptr(), block_size);
@@ -904,10 +532,6 @@ void AppxPackager::add_file(String p_file_name, const uint8_t * p_buffer, size_t
file_buffer.resize(file_buffer.size() + block_size);
for (int i = 0; i < bh.compressed_size; i++)
file_buffer[start + i] = strm_in[i];
-#ifdef OPENSSL_ENABLED
- if (do_hash)
- SHA256_Update(&axpc_context, strm_in.ptr(), block_size);
-#endif // OPENSSL_ENABLED
}
meta.hashes.push_back(bh);
@@ -931,10 +555,6 @@ void AppxPackager::add_file(String p_file_name, const uint8_t * p_buffer, size_t
file_buffer.resize(file_buffer.size() + (strm.total_out - total_out_before));
for (int i = 0; i < (strm.total_out - total_out_before); i++)
file_buffer[start + i] = strm_out[i];
-#ifdef OPENSSL_ENABLED
- if (do_hash)
- SHA256_Update(&axpc_context, strm_out.ptr(), strm.total_out - total_out_before);
-#endif // OPENSSL_ENABLED
deflateEnd(&strm);
meta.compressed_size = strm.total_out;
@@ -953,14 +573,6 @@ void AppxPackager::add_file(String p_file_name, const uint8_t * p_buffer, size_t
Vector<uint8_t> file_header = make_file_header(meta);
meta.lfh_size = file_header.size();
-#ifdef OPENSSL_ENABLED
- // Hash the data for signing
- if (do_hash) {
- SHA256_Update(&axpc_context, file_header.ptr(), file_header.size());
- SHA256_Update(&axpc_context, file_buffer.ptr(), file_buffer.size());
- }
-#endif // OPENSSL_ENABLED
-
// Store the header and file;
package->store_buffer(file_header.ptr(), file_header.size());
package->store_buffer(file_buffer.ptr(), file_buffer.size());
@@ -974,22 +586,12 @@ void AppxPackager::finish() {
EditorNode::progress_task_step("export", "Creating block map...", 4);
make_block_map();
- FileAccess* blockmap_file = FileAccess::open(tmp_blockmap_file_path, FileAccess::READ);
+ FileAccess *blockmap_file = FileAccess::open(tmp_blockmap_file_path, FileAccess::READ);
Vector<uint8_t> blockmap_buffer;
blockmap_buffer.resize(blockmap_file->get_len());
blockmap_file->get_buffer(blockmap_buffer.ptr(), blockmap_buffer.size());
-#ifdef OPENSSL_ENABLED
- // Hash the file for signing
- if (sign_package) {
- SHA256_CTX axbm_context;
- SHA256_Init(&axbm_context);
- SHA256_Update(&axbm_context, blockmap_buffer.ptr(), blockmap_buffer.size());
- SHA256_Final(digests.axbm, &axbm_context);
- }
-#endif // OPENSSL_ENABLED
-
add_file("AppxBlockMap.xml", blockmap_buffer.ptr(), blockmap_buffer.size(), -1, -1, true);
blockmap_file->close();
@@ -1000,22 +602,12 @@ void AppxPackager::finish() {
EditorNode::progress_task_step("export", "Setting content types...", 5);
make_content_types();
- FileAccess* types_file = FileAccess::open(tmp_content_types_file_path, FileAccess::READ);
+ FileAccess *types_file = FileAccess::open(tmp_content_types_file_path, FileAccess::READ);
Vector<uint8_t> types_buffer;
types_buffer.resize(types_file->get_len());
types_file->get_buffer(types_buffer.ptr(), types_buffer.size());
-#ifdef OPENSSL_ENABLED
- if (sign_package) {
- // Hash the file for signing
- SHA256_CTX axct_context;
- SHA256_Init(&axct_context);
- SHA256_Update(&axct_context, types_buffer.ptr(), types_buffer.size());
- SHA256_Final(digests.axct, &axct_context);
- }
-#endif // OPENSSL_ENABLED
-
add_file("[Content_Types].xml", types_buffer.ptr(), types_buffer.size(), -1, -1, true);
types_file->close();
@@ -1027,76 +619,6 @@ void AppxPackager::finish() {
store_central_dir_header(file_metadata[i]);
}
-#ifdef OPENSSL_ENABLED
- // Create the signature file
- if (sign_package) {
-
- Error err = read_cert_file(certificate_path, certificate_pass, &cert_file);
-
- if (err != OK) {
- EditorNode::add_io_error(TTR("Couldn't read the certificate file. Are the path and password both correct?"));
- package->close();
- memdelete(package);
- package = NULL;
- return;
- }
-
-
- // Make a temp end of the zip for hashing
- central_dir_offset = package->get_pos();
- end_of_central_dir_offset = central_dir_offset + central_dir_data.size();
- Vector<uint8_t> zip_end_dir = make_end_of_central_record();
-
- // Hash the end directory
- SHA256_Update(&axcd_context, zip_end_dir.ptr(), zip_end_dir.size());
-
- // Finish the hashes
- make_digests();
-
- PKCS7* signature = PKCS7_new();
- if (!signature) {
- EditorNode::add_io_error(TTR("Error creating the signature object."));
- package->close();
- memdelete(package);
- package = NULL;
- return;
- }
-
- err = sign(cert_file, digests, signature);
-
- if (err != OK) {
- EditorNode::add_io_error(TTR("Error creating the package signature."));
- package->close();
- memdelete(package);
- package = NULL;
- return;
- }
-
- // Read the signature as bytes
- BIO* bio_out = BIO_new(BIO_s_mem());
- i2d_PKCS7_bio(bio_out, signature);
-
- BIO_flush(bio_out);
-
- uint8_t* bio_ptr;
- size_t bio_size = BIO_get_mem_data(bio_out, &bio_ptr);
-
- // Create the signature buffer with magic number
- Vector<uint8_t> signature_file;
- signature_file.resize(4 + bio_size);
- buf_put_int32(P7X_SIGNATURE, signature_file.ptr());
- for (int i = 0; i < bio_size; i++)
- signature_file[i + 4] = bio_ptr[i];
-
- // Add the signature to the package
- add_file("AppxSignature.p7x", signature_file.ptr(), signature_file.size(), -1, -1, true);
-
- // Add central directory entry
- store_central_dir_header(file_metadata[file_metadata.size() - 1], false);
- }
-#endif // OPENSSL_ENABLED
-
-
// Write central directory
EditorNode::progress_task_step("export", "Finishing package...", 6);
central_dir_offset = package->get_pos();
@@ -1112,1284 +634,759 @@ void AppxPackager::finish() {
package = NULL;
}
-#ifdef OPENSSL_ENABLED
-// https://support.microsoft.com/en-us/kb/287547
-const char SPC_INDIRECT_DATA_OBJID[] = "1.3.6.1.4.1.311.2.1.4";
-const char SPC_STATEMENT_TYPE_OBJID[] = "1.3.6.1.4.1.311.2.1.11";
-const char SPC_SP_OPUS_INFO_OBJID[] = "1.3.6.1.4.1.311.2.1.12";
-const char SPC_SIPINFO_OBJID[] = "1.3.6.1.4.1.311.2.1.30";
-#endif // OPENSSL_ENABLED
-
AppxPackager::AppxPackager() {}
AppxPackager::~AppxPackager() {}
-
////////////////////////////////////////////////////////////////////
-#ifdef OPENSSL_ENABLED
-Error AppxPackager::openssl_error(unsigned long p_err) {
-
- ERR_load_crypto_strings();
-
- char buffer[256];
- ERR_error_string_n(p_err, buffer, sizeof(buffer));
+class EditorExportUWP : public EditorExportPlatform {
- String err(buffer);
+ GDCLASS(EditorExportUWP, EditorExportPlatform);
- ERR_EXPLAIN(err);
- ERR_FAIL_V(FAILED);
-}
-
-void AppxPackager::MakeSPCInfoValue(asn1::SPCInfoValue &info) {
+ Ref<ImageTexture> logo;
- // I have no idea what these numbers mean.
- static uint8_t s1Magic[] = {
- 0x4B, 0xDF, 0xC5, 0x0A, 0x07, 0xCE, 0xE2, 0x4D,
- 0xB7, 0x6E, 0x23, 0xC8, 0x39, 0xA0, 0x9F, 0xD1,
+ enum Platform {
+ ARM,
+ X86,
+ X64
};
- ASN1_INTEGER_set(info.i1, 0x01010000);
- ASN1_OCTET_STRING_set(info.s1, s1Magic, sizeof(s1Magic));
- ASN1_INTEGER_set(info.i2, 0x00000000);
- ASN1_INTEGER_set(info.i3, 0x00000000);
- ASN1_INTEGER_set(info.i4, 0x00000000);
- ASN1_INTEGER_set(info.i5, 0x00000000);
- ASN1_INTEGER_set(info.i6, 0x00000000);
-}
-
-Error AppxPackager::MakeIndirectDataContent(asn1::SPCIndirectDataContent &idc) {
-
- using namespace asn1;
- ASN1_TYPE* algorithmParameter = ASN1_TYPE_new();
- if (!algorithmParameter) {
- return openssl_error(ERR_peek_last_error());
- }
- algorithmParameter->type = V_ASN1_NULL;
-
- SPCInfoValue* infoValue = SPCInfoValue_new();
- if (!infoValue) {
- return openssl_error(ERR_peek_last_error());
- }
- MakeSPCInfoValue(*infoValue);
+ bool _valid_resource_name(const String &p_name) const {
- ASN1_TYPE* value =
- EncodedASN1::FromItem<asn1::SPCInfoValue,
- asn1::i2d_SPCInfoValue>(infoValue)
- .ToSequenceType();
+ if (p_name.empty()) return false;
+ if (p_name.ends_with(".")) return false;
- {
- Vector<uint8_t> digest;
- write_digest(digest);
- if (!ASN1_OCTET_STRING_set(idc.messageDigest->digest,
- digest.ptr(), digest.size())) {
+ static const char *invalid_names[] = {
+ "CON", "PRN", "AUX", "NUL", "COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7",
+ "COM8", "COM9", "LPT1", "LPT2", "LPT3", "LPT4", "LPT5", "LPT6", "LPT7", "LPT8", "LPT9",
+ NULL
+ };
- return openssl_error(ERR_peek_last_error());
+ const char **t = invalid_names;
+ while (*t) {
+ if (p_name == *t) return false;
+ t++;
}
- }
-
- idc.data->type = OBJ_txt2obj(SPC_SIPINFO_OBJID, 1);
- idc.data->value = value;
- idc.messageDigest->digestAlgorithm->algorithm = OBJ_nid2obj(NID_sha256);
- idc.messageDigest->digestAlgorithm->parameter = algorithmParameter;
-
- return OK;
-}
-
-Error AppxPackager::add_attributes(PKCS7_SIGNER_INFO * p_signer_info) {
-
- // Add opus attribute
- asn1::SPCSpOpusInfo* opus = asn1::SPCSpOpusInfo_new();
- if (!opus) return openssl_error(ERR_peek_last_error());
-
- ASN1_STRING* opus_value =
- EncodedASN1::FromItem<asn1::SPCSpOpusInfo,
- asn1::i2d_SPCSpOpusInfo>(opus)
- .ToSequenceString();
-
- if (!PKCS7_add_signed_attribute(
- p_signer_info,
- OBJ_txt2nid(SPC_SP_OPUS_INFO_OBJID),
- V_ASN1_SEQUENCE,
- opus_value
- )) {
-
- asn1::SPCSpOpusInfo_free(opus);
-
- ASN1_STRING_free(opus_value);
- return openssl_error(ERR_peek_last_error());
- }
-
- // Add content type attribute
- if (!PKCS7_add_signed_attribute(
- p_signer_info,
- NID_pkcs9_contentType,
- V_ASN1_OBJECT,
- OBJ_txt2obj(SPC_INDIRECT_DATA_OBJID, 1)
- )) {
-
- asn1::SPCSpOpusInfo_free(opus);
- ASN1_STRING_free(opus_value);
- return openssl_error(ERR_peek_last_error());
- }
-
- // Add statement type attribute
- asn1::SPCStatementType* statement_type = asn1::SPCStatementType_new();
- if (!statement_type) return openssl_error(ERR_peek_last_error());
-
- statement_type->type = OBJ_nid2obj(NID_ms_code_ind);
- ASN1_STRING* statement_type_value =
- EncodedASN1::FromItem<asn1::SPCStatementType,
- asn1::i2d_SPCStatementType>(statement_type)
- .ToSequenceString();
-
- if (!PKCS7_add_signed_attribute(
- p_signer_info,
- OBJ_txt2nid(SPC_STATEMENT_TYPE_OBJID),
- V_ASN1_SEQUENCE,
- statement_type_value
- )) {
-
- ASN1_STRING_free(opus_value);
- asn1::SPCStatementType_free(statement_type);
- ASN1_STRING_free(statement_type_value);
-
- return openssl_error(ERR_peek_last_error());
- }
-
- return OK;
-
-}
-
-void AppxPackager::make_digests() {
-
- // AXPC
- SHA256_Final(digests.axpc, &axpc_context);
-
- // AXCD
- SHA256_Final(digests.axcd, &axcd_context);
-
- // AXCI
- for (int i = 0; i < SHA256_DIGEST_LENGTH; i++)
- digests.axci[i] = 0;
-
-}
-
-void AppxPackager::write_digest(Vector<uint8_t>& p_out_buffer) {
-
- // Size of digests plus 6 32-bit magic numbers
- p_out_buffer.resize((SHA256_DIGEST_LENGTH * 5) + (6 * 4));
-
- int offs = 0;
-
- // APPX
- uint32_t sig = 0x58505041;
- offs += buf_put_int32(sig, &p_out_buffer[offs]);
-
- // AXPC
- uint32_t axpc_sig = 0x43505841;
- offs += buf_put_int32(axpc_sig, &p_out_buffer[offs]);
- for (int i = 0; i < SHA256_DIGEST_LENGTH; i++) {
- p_out_buffer[offs++] = digests.axpc[i];
- }
-
- // AXCD
- uint32_t axcd_sig = 0x44435841;
- offs += buf_put_int32(axcd_sig, &p_out_buffer[offs]);
- for (int i = 0; i < SHA256_DIGEST_LENGTH; i++) {
- p_out_buffer[offs++] = digests.axcd[i];
- }
-
- // AXCT
- uint32_t axct_sig = 0x54435841;
- offs += buf_put_int32(axct_sig, &p_out_buffer[offs]);
- for (int i = 0; i < SHA256_DIGEST_LENGTH; i++) {
- p_out_buffer[offs++] = digests.axct[i];
- }
-
- // AXBM
- uint32_t axbm_sig = 0x4D425841;
- offs += buf_put_int32(axbm_sig, &p_out_buffer[offs]);
- for (int i = 0; i < SHA256_DIGEST_LENGTH; i++) {
- p_out_buffer[offs++] = digests.axbm[i];
- }
-
- // AXCI
- uint32_t axci_sig = 0x49435841;
- offs += buf_put_int32(axci_sig, &p_out_buffer[offs]);
- for (int i = 0; i < SHA256_DIGEST_LENGTH; i++) {
- p_out_buffer[offs++] = digests.axci[i];
- }
-
- // Done!
-}
-
-Error AppxPackager::read_cert_file(const String & p_path, const String &p_password, CertFile* p_out_cf) {
-
- ERR_FAIL_COND_V(!p_out_cf, ERR_INVALID_PARAMETER);
-
- BIO* bio = BIO_new_file(p_path.utf8().get_data(), "rb");
- if (!bio) {
- return openssl_error(ERR_peek_last_error());
- }
-
- PKCS12* data = d2i_PKCS12_bio(bio, NULL);
- if (!data) {
- BIO_free(bio);
- return openssl_error(ERR_peek_last_error());
- }
-
- /* Fails to link with GCC, need to solve when implement signing
- if (!PKCS12_parse(data, p_password.utf8().get_data(), &p_out_cf->private_key, &p_out_cf->certificate, NULL)) {
- PKCS12_free(data);
- BIO_free(bio);
- return openssl_error(ERR_peek_last_error());
- }*/
-
- if (!p_out_cf->private_key) {
- PKCS12_free(data);
- BIO_free(bio);
- return openssl_error(ERR_peek_last_error());
- }
-
- if (!p_out_cf->certificate) {
- PKCS12_free(data);
- BIO_free(bio);
- return openssl_error(ERR_peek_last_error());
- }
-
- PKCS12_free(data);
- BIO_free(bio);
-
- return OK;
-}
-
-Error AppxPackager::sign(const CertFile & p_cert, const AppxDigests & digests, PKCS7 * p_out_signature) {
-
- OpenSSL_add_all_algorithms();
-
- // Register object IDs
- OBJ_create_and_add_object(SPC_INDIRECT_DATA_OBJID, NULL, NULL);
- OBJ_create_and_add_object(SPC_SIPINFO_OBJID, NULL, NULL);
- OBJ_create_and_add_object(SPC_SP_OPUS_INFO_OBJID, NULL, NULL);
- OBJ_create_and_add_object(SPC_STATEMENT_TYPE_OBJID, NULL, NULL);
- if (!PKCS7_set_type(p_out_signature, NID_pkcs7_signed)) {
-
- return openssl_error(ERR_peek_last_error());
- }
-
- PKCS7_SIGNER_INFO *signer_info = PKCS7_add_signature(p_out_signature, p_cert.certificate, p_cert.private_key, EVP_sha256());
- if (!signer_info) return openssl_error(ERR_peek_last_error());
-
- add_attributes(signer_info);
-
- if (!PKCS7_content_new(p_out_signature, NID_pkcs7_data)) {
+ return true;
+ }
+
+ bool _valid_guid(const String &p_guid) const {
+
+ Vector<String> parts = p_guid.split("-");
+
+ if (parts.size() != 5) return false;
+ if (parts[0].length() != 8) return false;
+ for (int i = 1; i < 4; i++)
+ if (parts[i].length() != 4) return false;
+ if (parts[4].length() != 12) return false;
+
+ return true;
+ }
+
+ bool _valid_bgcolor(const String &p_color) const {
+
+ if (p_color.empty()) return true;
+ if (p_color.begins_with("#") && p_color.is_valid_html_color()) return true;
+
+ // Colors from https://msdn.microsoft.com/en-us/library/windows/apps/dn934817.aspx
+ static const char *valid_colors[] = {
+ "aliceBlue", "antiqueWhite", "aqua", "aquamarine", "azure", "beige",
+ "bisque", "black", "blanchedAlmond", "blue", "blueViolet", "brown",
+ "burlyWood", "cadetBlue", "chartreuse", "chocolate", "coral", "cornflowerBlue",
+ "cornsilk", "crimson", "cyan", "darkBlue", "darkCyan", "darkGoldenrod",
+ "darkGray", "darkGreen", "darkKhaki", "darkMagenta", "darkOliveGreen", "darkOrange",
+ "darkOrchid", "darkRed", "darkSalmon", "darkSeaGreen", "darkSlateBlue", "darkSlateGray",
+ "darkTurquoise", "darkViolet", "deepPink", "deepSkyBlue", "dimGray", "dodgerBlue",
+ "firebrick", "floralWhite", "forestGreen", "fuchsia", "gainsboro", "ghostWhite",
+ "gold", "goldenrod", "gray", "green", "greenYellow", "honeydew",
+ "hotPink", "indianRed", "indigo", "ivory", "khaki", "lavender",
+ "lavenderBlush", "lawnGreen", "lemonChiffon", "lightBlue", "lightCoral", "lightCyan",
+ "lightGoldenrodYellow", "lightGreen", "lightGray", "lightPink", "lightSalmon", "lightSeaGreen",
+ "lightSkyBlue", "lightSlateGray", "lightSteelBlue", "lightYellow", "lime", "limeGreen",
+ "linen", "magenta", "maroon", "mediumAquamarine", "mediumBlue", "mediumOrchid",
+ "mediumPurple", "mediumSeaGreen", "mediumSlateBlue", "mediumSpringGreen", "mediumTurquoise", "mediumVioletRed",
+ "midnightBlue", "mintCream", "mistyRose", "moccasin", "navajoWhite", "navy",
+ "oldLace", "olive", "oliveDrab", "orange", "orangeRed", "orchid",
+ "paleGoldenrod", "paleGreen", "paleTurquoise", "paleVioletRed", "papayaWhip", "peachPuff",
+ "peru", "pink", "plum", "powderBlue", "purple", "red",
+ "rosyBrown", "royalBlue", "saddleBrown", "salmon", "sandyBrown", "seaGreen",
+ "seaShell", "sienna", "silver", "skyBlue", "slateBlue", "slateGray",
+ "snow", "springGreen", "steelBlue", "tan", "teal", "thistle",
+ "tomato", "transparent", "turquoise", "violet", "wheat", "white",
+ "whiteSmoke", "yellow", "yellowGreen",
+ NULL
+ };
+
+ const char **color = valid_colors;
+
+ while (*color) {
+ if (p_color == *color) return true;
+ color++;
+ }
- return openssl_error(ERR_peek_last_error());
+ return false;
}
- if (!PKCS7_add_certificate(p_out_signature, p_cert.certificate)) {
+ bool _valid_image(const StreamTexture *p_image, int p_width, int p_height) const {
- return openssl_error(ERR_peek_last_error());
- }
+ if (!p_image) {
+ return false;
+ }
- asn1::SPCIndirectDataContent* idc = asn1::SPCIndirectDataContent_new();
+ // TODO: Add resource creation or image rescaling to enable other scales:
+ // 1.25, 1.5, 2.0
+ real_t scales[] = { 1.0 };
+ bool valid_w = false;
+ bool valid_h = false;
- MakeIndirectDataContent(*idc);
- EncodedASN1 idc_encoded =
- EncodedASN1::FromItem<asn1::SPCIndirectDataContent, asn1::i2d_SPCIndirectDataContent>(idc);
+ for (int i = 0; i < 1; i++) {
- BIO* signed_data = PKCS7_dataInit(p_out_signature, NULL);
+ int w = ceil(p_width * scales[i]);
+ int h = ceil(p_height * scales[i]);
- if (idc_encoded.size() < 2) {
+ if (w == p_image->get_width())
+ valid_w = true;
+ if (h == p_image->get_height())
+ valid_h = true;
+ }
- ERR_EXPLAIN("Invalid encoded size");
- ERR_FAIL_V(FAILED);
+ return valid_w && valid_h;
}
- if ((idc_encoded.data()[1] & 0x80) == 0x00) {
+ Vector<uint8_t> _fix_manifest(const Ref<EditorExportPreset> &p_preset, const Vector<uint8_t> &p_template, bool p_give_internet) const {
- ERR_EXPLAIN("Invalid encoded data");
- ERR_FAIL_V(FAILED);
- }
+ String result = String::utf8((const char *)p_template.ptr(), p_template.size());
- size_t skip = 4;
+ result = result.replace("$godot_version$", VERSION_FULL_NAME);
- if (BIO_write(signed_data, idc_encoded.data() + skip, idc_encoded.size() - skip)
- != idc_encoded.size() - skip) {
+ result = result.replace("$identity_name$", p_preset->get("package/unique_name"));
+ result = result.replace("$publisher$", p_preset->get("package/publisher"));
- return openssl_error(ERR_peek_last_error());
- }
- if (BIO_flush(signed_data) != 1) {
+ result = result.replace("$product_guid$", p_preset->get("identity/product_guid"));
+ result = result.replace("$publisher_guid$", p_preset->get("identity/publisher_guid"));
- return openssl_error(ERR_peek_last_error());
- }
+ String version = itos(p_preset->get("version/major")) + "." + itos(p_preset->get("version/minor")) + "." + itos(p_preset->get("version/build")) + "." + itos(p_preset->get("version/revision"));
+ result = result.replace("$version_string$", version);
- if (!PKCS7_dataFinal(p_out_signature, signed_data)) {
+ Platform arch = (Platform)(int)p_preset->get("architecture/target");
+ String architecture = arch == ARM ? "ARM" : arch == X86 ? "x86" : "x64";
+ result = result.replace("$architecture$", architecture);
- return openssl_error(ERR_peek_last_error());
- }
+ result = result.replace("$display_name$", String(p_preset->get("package/display_name")).empty() ? (String)ProjectSettings::get_singleton()->get("application/config/name") : String(p_preset->get("package/display_name")));
- PKCS7* content = PKCS7_new();
- if (!content) {
+ result = result.replace("$publisher_display_name$", p_preset->get("package/publisher_display_name"));
+ result = result.replace("$app_description$", p_preset->get("package/description"));
+ result = result.replace("$bg_color$", p_preset->get("images/background_color"));
+ result = result.replace("$short_name$", p_preset->get("package/short_name"));
- return openssl_error(ERR_peek_last_error());
- }
+ String name_on_tiles = "";
+ if ((bool)p_preset->get("tiles/show_name_on_square150x150")) {
+ name_on_tiles += " <uap:ShowOn Tile=\"square150x150Logo\" />\n";
+ }
+ if ((bool)p_preset->get("tiles/show_name_on_wide310x150")) {
+ name_on_tiles += " <uap:ShowOn Tile=\"wide310x150Logo\" />\n";
+ }
+ if ((bool)p_preset->get("tiles/show_name_on_square310x310")) {
+ name_on_tiles += " <uap:ShowOn Tile=\"square310x310Logo\" />\n";
+ }
- content->type = OBJ_txt2obj(SPC_INDIRECT_DATA_OBJID, 1);
+ String show_name_on_tiles = "";
+ if (!name_on_tiles.empty()) {
+ show_name_on_tiles = "<uap:ShowNameOnTiles>\n" + name_on_tiles + " </uap:ShowNameOnTiles>";
+ }
- ASN1_TYPE* idc_sequence = idc_encoded.ToSequenceType();
- content->d.other = idc_sequence;
+ result = result.replace("$name_on_tiles$", name_on_tiles);
- if (!PKCS7_set_content(p_out_signature, content)) {
+ String rotations = "";
+ if ((bool)p_preset->get("orientation/landscape")) {
+ rotations += " <uap:Rotation Preference=\"landscape\" />\n";
+ }
+ if ((bool)p_preset->get("orientation/portrait")) {
+ rotations += " <uap:Rotation Preference=\"portrait\" />\n";
+ }
+ if ((bool)p_preset->get("orientation/landscape_flipped")) {
+ rotations += " <uap:Rotation Preference=\"landscapeFlipped\" />\n";
+ }
+ if ((bool)p_preset->get("orientation/portrait_flipped")) {
+ rotations += " <uap:Rotation Preference=\"portraitFlipped\" />\n";
+ }
- return openssl_error(ERR_peek_last_error());
- }
+ String rotation_preference = "";
+ if (!rotations.empty()) {
+ rotation_preference = "<uap:InitialRotationPreference>\n" + rotations + " </uap:InitialRotationPreference>";
+ }
- return OK;
-}
+ result = result.replace("$rotation_preference$", rotation_preference);
-#endif // OPENSSL_ENABLED
+ String capabilities_elements = "";
+ const char **basic = uwp_capabilities;
+ while (*basic) {
+ if ((bool)p_preset->get("capabilities/" + String(*basic))) {
+ capabilities_elements += " <Capability Name=\"" + String(*basic) + "\" />\n";
+ }
+ basic++;
+ }
+ const char **uap = uwp_uap_capabilities;
+ while (*uap) {
+ if ((bool)p_preset->get("capabilities/" + String(*uap))) {
+ capabilities_elements += " <uap:Capability Name=\"" + String(*uap) + "\" />\n";
+ }
+ uap++;
+ }
+ const char **device = uwp_device_capabilites;
+ while (*device) {
+ if ((bool)p_preset->get("capabilities/" + String(*device))) {
+ capabilities_elements += " <DeviceCapability Name=\"" + String(*device) + "\" />\n";
+ }
+ device++;
+ }
-////////////////////////////////////////////////////////////////////
+ if (!((bool)p_preset->get("capabilities/internetClient")) && p_give_internet) {
+ capabilities_elements += " <Capability Name=\"internetClient\" />\n";
+ }
+ String capabilities_string = "<Capabilities />";
+ if (!capabilities_elements.empty()) {
+ capabilities_string = "<Capabilities>\n" + capabilities_elements + " </Capabilities>";
+ }
-bool EditorExportPlatformUWP::_valid_resource_name(const String &p_name) const {
+ result = result.replace("$capabilities_place$", capabilities_string);
- if (p_name.empty()) return false;
- if (p_name.ends_with(".")) return false;
+ Vector<uint8_t> r_ret;
+ r_ret.resize(result.length());
- static const char* invalid_names[] = {
- "CON","PRN","AUX","NUL","COM1","COM2","COM3","COM4","COM5","COM6","COM7",
- "COM8","COM9","LPT1","LPT2","LPT3","LPT4","LPT5","LPT6","LPT7","LPT8","LPT9",
- NULL
- };
+ for (int i = 0; i < result.length(); i++)
+ r_ret[i] = result.utf8().get(i);
- const char** t = invalid_names;
- while (*t) {
- if (p_name == *t) return false;
- t++;
+ return r_ret;
}
- return true;
-}
+ Vector<uint8_t> _get_image_data(const Ref<EditorExportPreset> &p_preset, const String &p_path) {
-bool EditorExportPlatformUWP::_valid_guid(const String & p_guid) const {
+ Vector<uint8_t> data;
+ StreamTexture *image;
+
+ if (p_path.find("StoreLogo") != -1) {
+ image = p_preset->get("images/store_logo").is_zero() ? NULL : ((Object *)p_preset->get("images/store_logo"))->cast_to<StreamTexture>();
+ } else if (p_path.find("Square44x44Logo") != -1) {
+ image = p_preset->get("images/square44x44_logo").is_zero() ? NULL : ((Object *)p_preset->get("images/square44x44_logo"))->cast_to<StreamTexture>();
+ } else if (p_path.find("Square71x71Logo") != -1) {
+ image = p_preset->get("images/square71x71_logo").is_zero() ? NULL : ((Object *)p_preset->get("images/square71x71_logo"))->cast_to<StreamTexture>();
+ } else if (p_path.find("Square150x150Logo") != -1) {
+ image = p_preset->get("images/square150x150_logo").is_zero() ? NULL : ((Object *)p_preset->get("images/square150x150_logo"))->cast_to<StreamTexture>();
+ } else if (p_path.find("Square310x310Logo") != -1) {
+ image = p_preset->get("images/square310x310_logo").is_zero() ? NULL : ((Object *)p_preset->get("images/square310x310_logo"))->cast_to<StreamTexture>();
+ } else if (p_path.find("Wide310x150Logo") != -1) {
+ image = p_preset->get("images/wide310x150_logo").is_zero() ? NULL : ((Object *)p_preset->get("images/wide310x150_logo"))->cast_to<StreamTexture>();
+ } else if (p_path.find("SplashScreen") != -1) {
+ image = p_preset->get("images/splash_screen").is_zero() ? NULL : ((Object *)p_preset->get("images/splash_screen"))->cast_to<StreamTexture>();
+ }
- Vector<String> parts = p_guid.split("-");
+ if (!image) return data;
- if (parts.size() != 5) return false;
- if (parts[0].length() != 8) return false;
- for (int i = 1; i < 4; i++)
- if (parts[i].length() != 4) return false;
- if (parts[4].length() != 12) return false;
+ String tmp_path = EditorSettings::get_singleton()->get_settings_path().plus_file("tmp/uwp_tmp_logo.png");
- return true;
-}
+ Error err = image->get_data()->save_png(tmp_path);
-bool EditorExportPlatformUWP::_valid_bgcolor(const String & p_color) const {
-
- if (p_color.empty()) return true;
- if (p_color.begins_with("#") && p_color.is_valid_html_color()) return true;
-
- // Colors from https://msdn.microsoft.com/en-us/library/windows/apps/dn934817.aspx
- static const char* valid_colors[] = {
- "aliceBlue","antiqueWhite","aqua","aquamarine","azure","beige",
- "bisque","black","blanchedAlmond","blue","blueViolet","brown",
- "burlyWood","cadetBlue","chartreuse","chocolate","coral","cornflowerBlue",
- "cornsilk","crimson","cyan","darkBlue","darkCyan","darkGoldenrod",
- "darkGray","darkGreen","darkKhaki","darkMagenta","darkOliveGreen","darkOrange",
- "darkOrchid","darkRed","darkSalmon","darkSeaGreen","darkSlateBlue","darkSlateGray",
- "darkTurquoise","darkViolet","deepPink","deepSkyBlue","dimGray","dodgerBlue",
- "firebrick","floralWhite","forestGreen","fuchsia","gainsboro","ghostWhite",
- "gold","goldenrod","gray","green","greenYellow","honeydew",
- "hotPink","indianRed","indigo","ivory","khaki","lavender",
- "lavenderBlush","lawnGreen","lemonChiffon","lightBlue","lightCoral","lightCyan",
- "lightGoldenrodYellow","lightGreen","lightGray","lightPink","lightSalmon","lightSeaGreen",
- "lightSkyBlue","lightSlateGray","lightSteelBlue","lightYellow","lime","limeGreen",
- "linen","magenta","maroon","mediumAquamarine","mediumBlue","mediumOrchid",
- "mediumPurple","mediumSeaGreen","mediumSlateBlue","mediumSpringGreen","mediumTurquoise","mediumVioletRed",
- "midnightBlue","mintCream","mistyRose","moccasin","navajoWhite","navy",
- "oldLace","olive","oliveDrab","orange","orangeRed","orchid",
- "paleGoldenrod","paleGreen","paleTurquoise","paleVioletRed","papayaWhip","peachPuff",
- "peru","pink","plum","powderBlue","purple","red",
- "rosyBrown","royalBlue","saddleBrown","salmon","sandyBrown","seaGreen",
- "seaShell","sienna","silver","skyBlue","slateBlue","slateGray",
- "snow","springGreen","steelBlue","tan","teal","thistle",
- "tomato","transparent","turquoise","violet","wheat","white",
- "whiteSmoke","yellow","yellowGreen",
- NULL
- };
+ if (err != OK) {
- const char** color = valid_colors;
+ String err_string = "Couldn't save temp logo file.";
- while(*color) {
- if (p_color == *color) return true;
- color++;
- }
+ EditorNode::add_io_error(err_string);
+ ERR_EXPLAIN(err_string);
+ ERR_FAIL_V(data);
+ }
- return false;
-}
+ FileAccess *f = FileAccess::open(tmp_path, FileAccess::READ, &err);
-bool EditorExportPlatformUWP::_valid_image(const Ref<ImageTexture> p_image, int p_width, int p_height) const {
+ if (err != OK) {
- if (!p_image.is_valid()) return false;
+ String err_string = "Couldn't open temp logo file.";
- // TODO: Add resource creation or image rescaling to enable other scales:
- // 1.25, 1.5, 2.0
- real_t scales[] = { 1.0 };
- bool valid_w = false;
- bool valid_h = false;
+ EditorNode::add_io_error(err_string);
+ ERR_EXPLAIN(err_string);
+ ERR_FAIL_V(data);
+ }
- for (int i = 0; i < 1; i++) {
+ data.resize(f->get_len());
+ f->get_buffer(data.ptr(), data.size());
- int w = ceil(p_width * scales[i]);
- int h = ceil(p_height * scales[i]);
+ f->close();
+ memdelete(f);
- if (w == p_image->get_width())
- valid_w = true;
- if (h == p_image->get_height())
- valid_h = true;
- }
+ // Delete temp file
+ DirAccess *dir = DirAccess::open(tmp_path.get_base_dir(), &err);
- return valid_w && valid_h;
-}
+ if (err != OK) {
-Vector<uint8_t> EditorExportPlatformUWP::_fix_manifest(const Vector<uint8_t> &p_template, bool p_give_internet) const {
+ String err_string = "Couldn't open temp path to remove temp logo file.";
- String result = String::utf8((const char*)p_template.ptr(), p_template.size());
+ EditorNode::add_io_error(err_string);
+ ERR_EXPLAIN(err_string);
+ ERR_FAIL_V(data);
+ }
- result = result.replace("$godot_version$", VERSION_FULL_NAME);
+ err = dir->remove(tmp_path);
- result = result.replace("$identity_name$", unique_name);
- result = result.replace("$publisher$", publisher);
+ memdelete(dir);
- result = result.replace("$product_guid$", product_guid);
- result = result.replace("$publisher_guid$", publisher_guid);
+ if (err != OK) {
- String version = itos(version_major) + "." + itos(version_minor) + "." + itos(version_build) + "." + itos(version_revision);
- result = result.replace("$version_string$", version);
+ String err_string = "Couldn't remove temp logo file.";
- String architecture = arch == ARM ? "ARM" : arch == X86 ? "x86" : "x64";
- result = result.replace("$architecture$", architecture);
+ EditorNode::add_io_error(err_string);
+ ERR_EXPLAIN(err_string);
+ ERR_FAIL_V(data);
+ }
- result = result.replace("$display_name$", display_name.empty() ? (String)GlobalConfig::get_singleton()->get("application/name") : display_name);
- result = result.replace("$publisher_display_name$", publisher_display_name);
- result = result.replace("$app_description$", description);
- result = result.replace("$bg_color$", background_color);
- result = result.replace("$short_name$", short_name);
+ return data;
+ }
+
+ static bool _should_compress_asset(const String &p_path, const Vector<uint8_t> &p_data) {
+
+ /* TODO: This was copied verbatim from Android export. It should be
+ * refactored to the parent class and also be used for .zip export.
+ */
+
+ /*
+ * By not compressing files with little or not benefit in doing so,
+ * a performance gain is expected at runtime. Moreover, if the APK is
+ * zip-aligned, assets stored as they are can be efficiently read by
+ * Android by memory-mapping them.
+ */
+
+ // -- Unconditional uncompress to mimic AAPT plus some other
+
+ static const char *unconditional_compress_ext[] = {
+ // From https://github.com/android/platform_frameworks_base/blob/master/tools/aapt/Package.cpp
+ // These formats are already compressed, or don't compress well:
+ ".jpg", ".jpeg", ".png", ".gif",
+ ".wav", ".mp2", ".mp3", ".ogg", ".aac",
+ ".mpg", ".mpeg", ".mid", ".midi", ".smf", ".jet",
+ ".rtttl", ".imy", ".xmf", ".mp4", ".m4a",
+ ".m4v", ".3gp", ".3gpp", ".3g2", ".3gpp2",
+ ".amr", ".awb", ".wma", ".wmv",
+ // Godot-specific:
+ ".webp", // Same reasoning as .png
+ ".cfb", // Don't let small config files slow-down startup
+ ".scn", // Binary scenes are usually already compressed
+ ".stex", // Streamable textures are usually already compressed
+ // Trailer for easier processing
+ NULL
+ };
+
+ for (const char **ext = unconditional_compress_ext; *ext; ++ext) {
+ if (p_path.to_lower().ends_with(String(*ext))) {
+ return false;
+ }
+ }
- String name_on_tiles = "";
- if (name_on_square150) {
- name_on_tiles += " <uap:ShowOn Tile=\"square150x150Logo\" />\n";
- }
- if (name_on_wide) {
- name_on_tiles += " <uap:ShowOn Tile=\"wide310x150Logo\" />\n";
- }
- if (name_on_square310) {
- name_on_tiles += " <uap:ShowOn Tile=\"square310x310Logo\" />\n";
- }
+ // -- Compressed resource?
- String show_name_on_tiles = "";
- if (!name_on_tiles.empty()) {
- show_name_on_tiles = "<uap:ShowNameOnTiles>\n" + name_on_tiles + " </uap:ShowNameOnTiles>";
- }
+ if (p_data.size() >= 4 && p_data[0] == 'R' && p_data[1] == 'S' && p_data[2] == 'C' && p_data[3] == 'C') {
+ // Already compressed
+ return false;
+ }
- result = result.replace("$name_on_tiles$", name_on_tiles);
+ // --- TODO: Decide on texture resources according to their image compression setting
- String rotations = "";
- if (orientation_landscape) {
- rotations += " <uap:Rotation Preference=\"landscape\" />\n";
- }
- if (orientation_portrait) {
- rotations += " <uap:Rotation Preference=\"portrait\" />\n";
- }
- if (orientation_landscape_flipped) {
- rotations += " <uap:Rotation Preference=\"landscapeFlipped\" />\n";
- }
- if (orientation_portrait_flipped) {
- rotations += " <uap:Rotation Preference=\"portraitFlipped\" />\n";
+ return true;
}
- String rotation_preference = "";
- if (!rotations.empty()) {
- rotation_preference = "<uap:InitialRotationPreference>\n" + rotations + " </uap:InitialRotationPreference>";
- }
+ static Error save_appx_file(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total) {
- result = result.replace("$rotation_preference$", rotation_preference);
+ AppxPackager *packager = (AppxPackager *)p_userdata;
+ String dst_path = p_path.replace_first("res://", "game/");
- String capabilities_elements = "";
- const char **basic = uwp_capabilities;
- while (*basic) {
- if (capabilities.has(*basic)) {
- capabilities_elements += " <Capability Name=\"" + String(*basic) + "\" />\n";
- }
- basic++;
- }
- const char **uap = uwp_uap_capabilities;
- while (*uap) {
- if (uap_capabilities.has(*uap)) {
- capabilities_elements += " <uap:Capability Name=\"" + String(*uap) + "\" />\n";
- }
- uap++;
- }
- const char **device = uwp_device_capabilites;
- while (*device) {
- if (uap_capabilities.has(*device)) {
- capabilities_elements += " <DeviceCapability Name=\"" + String(*device) + "\" />\n";
- }
- device++;
- }
+ packager->add_file(dst_path, p_data.ptr(), p_data.size(), p_file, p_total, _should_compress_asset(p_path, p_data));
- if (!capabilities.has("internetClient") && p_give_internet) {
- capabilities_elements += " <Capability Name=\"internetClient\" />\n";
+ return OK;
}
- String capabilities_string = "<Capabilities />";
- if (!capabilities_elements.empty()) {
- capabilities_string = "<Capabilities>\n" + capabilities_elements + " </Capabilities>";
+public:
+ virtual String get_name() const {
+ return "Windows Universal";
}
-
- result = result.replace("$capabilities_place$", capabilities_string);
-
- Vector<uint8_t> r_ret;
- r_ret.resize(result.length());
-
- for (int i = 0; i < result.length(); i++)
- r_ret[i] = result.utf8().get(i);
-
- return r_ret;
-}
-
-Vector<uint8_t> EditorExportPlatformUWP::_get_image_data(const String & p_path) {
-
- Vector<uint8_t> data;
- Ref<ImageTexture> ref;
-
- if (p_path.find("StoreLogo") != -1) {
- ref = store_logo;
- } else if (p_path.find("Square44x44Logo") != -1) {
- ref = square44;
- } else if (p_path.find("Square71x71Logo") != -1) {
- ref = square71;
- } else if (p_path.find("Square150x150Logo") != -1) {
- ref = square150;
- } else if (p_path.find("Square310x310Logo") != -1) {
- ref = square310;
- } else if (p_path.find("Wide310x150Logo") != -1) {
- ref = wide310;
- } else if (p_path.find("SplashScreen") != -1) {
- ref = splash;
+ virtual String get_os_name() const {
+ return "UWP";
}
- if (!ref.is_valid()) return data;
-
-
- String tmp_path = EditorSettings::get_singleton()->get_settings_path().plus_file("tmp/uwp_tmp_logo.png");
-
- Error err = ref->get_data().save_png(tmp_path);
-
- if (err != OK) {
-
- String err_string = "Couldn't save temp logo file.";
-
- EditorNode::add_io_error(err_string);
- ERR_EXPLAIN(err_string);
- ERR_FAIL_V(data);
+ virtual String get_binary_extension() const {
+ return "appx";
}
- FileAccess* f = FileAccess::open(tmp_path, FileAccess::READ, &err);
-
- if (err != OK) {
-
- String err_string = "Couldn't open temp logo file.";
-
- EditorNode::add_io_error(err_string);
- ERR_EXPLAIN(err_string);
- ERR_FAIL_V(data);
+ virtual Ref<Texture> get_logo() const {
+ return logo;
}
- data.resize(f->get_len());
- f->get_buffer(data.ptr(), data.size());
-
- f->close();
- memdelete(f);
-
- // Delete temp file
- DirAccess* dir = DirAccess::open(tmp_path.get_base_dir(), &err);
-
- if (err != OK) {
-
- String err_string = "Couldn't open temp path to remove temp logo file.";
-
- EditorNode::add_io_error(err_string);
- ERR_EXPLAIN(err_string);
- ERR_FAIL_V(data);
+ virtual void get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) {
+ r_features->push_back("s3tc");
+ r_features->push_back("etc");
}
- err = dir->remove(tmp_path);
-
- memdelete(dir);
-
- if (err != OK) {
+ virtual void get_export_options(List<ExportOption> *r_options) {
+ r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "architecture/target", PROPERTY_HINT_ENUM, "ARM,x86,x64"), 1));
- String err_string = "Couldn't remove temp logo file.";
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "command_line/extra_args"), ""));
- EditorNode::add_io_error(err_string);
- ERR_EXPLAIN(err_string);
- ERR_FAIL_V(data);
- }
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "package/display_name"), ""));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "package/short_name"), "Godot"));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "package/unique_name"), "Godot.Engine"));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "package/description"), "Godot Engine"));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "package/publisher"), "CN=GodotEngine"));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "package/publisher_display_name"), "Godot Engine"));
- return data;
-}
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "identity/product_guid"), "00000000-0000-0000-0000-000000000000"));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "identity/publisher_guid"), "00000000-0000-0000-0000-000000000000"));
-Error EditorExportPlatformUWP::save_appx_file(void * p_userdata, const String & p_path, const Vector<uint8_t>& p_data, int p_file, int p_total) {
+ r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "version/major"), 1));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "version/minor"), 0));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "version/build"), 0));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "version/revision"), 0));
- AppxPackager *packager = (AppxPackager*)p_userdata;
- String dst_path = p_path.replace_first("res://", "game/");
+ r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "orientation/landscape"), true));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "orientation/portrait"), true));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "orientation/landscape_flipped"), true));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "orientation/portrait_flipped"), true));
- packager->add_file(dst_path, p_data.ptr(), p_data.size(), p_file, p_total, _should_compress_asset(p_path, p_data));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "images/background_color"), "transparent"));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::OBJECT, "images/store_logo", PROPERTY_HINT_RESOURCE_TYPE, "StreamTexture"), Variant()));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::OBJECT, "images/square44x44_logo", PROPERTY_HINT_RESOURCE_TYPE, "StreamTexture"), Variant()));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::OBJECT, "images/square71x71_logo", PROPERTY_HINT_RESOURCE_TYPE, "StreamTexture"), Variant()));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::OBJECT, "images/square150x150_logo", PROPERTY_HINT_RESOURCE_TYPE, "StreamTexture"), Variant()));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::OBJECT, "images/square310x310_logo", PROPERTY_HINT_RESOURCE_TYPE, "StreamTexture"), Variant()));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::OBJECT, "images/wide310x150_logo", PROPERTY_HINT_RESOURCE_TYPE, "StreamTexture"), Variant()));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::OBJECT, "images/splash_screen", PROPERTY_HINT_RESOURCE_TYPE, "StreamTexture"), Variant()));
- return OK;
-}
+ r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "tiles/show_name_on_square150x150"), false));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "tiles/show_name_on_wide310x150"), false));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "tiles/show_name_on_square310x310"), false));
-bool EditorExportPlatformUWP::_should_compress_asset(const String & p_path, const Vector<uint8_t>& p_data) {
-
- /* TODO: This was copied verbatim from Android export. It should be
- * refactored to the parent class and also be used for .zip export.
- */
-
- /*
- * By not compressing files with little or not benefit in doing so,
- * a performance gain is expected at runtime. Moreover, if the APK is
- * zip-aligned, assets stored as they are can be efficiently read by
- * Android by memory-mapping them.
- */
-
- // -- Unconditional uncompress to mimic AAPT plus some other
-
- static const char* unconditional_compress_ext[] = {
- // From https://github.com/android/platform_frameworks_base/blob/master/tools/aapt/Package.cpp
- // These formats are already compressed, or don't compress well:
- ".jpg", ".jpeg", ".png", ".gif",
- ".wav", ".mp2", ".mp3", ".ogg", ".aac",
- ".mpg", ".mpeg", ".mid", ".midi", ".smf", ".jet",
- ".rtttl", ".imy", ".xmf", ".mp4", ".m4a",
- ".m4v", ".3gp", ".3gpp", ".3g2", ".3gpp2",
- ".amr", ".awb", ".wma", ".wmv",
- // Godot-specific:
- ".webp", // Same reasoning as .png
- ".cfb", // Don't let small config files slow-down startup
- // Trailer for easier processing
- NULL
- };
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_template/debug", PROPERTY_HINT_GLOBAL_FILE, "zip"), ""));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_template/release", PROPERTY_HINT_GLOBAL_FILE, "zip"), ""));
- for (const char** ext = unconditional_compress_ext; *ext; ++ext) {
- if (p_path.to_lower().ends_with(String(*ext))) {
- return false;
+ // Capabilites
+ const char **basic = uwp_capabilities;
+ while (*basic) {
+ r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "capabilities/" + String(*basic).camelcase_to_underscore(false)), false));
+ basic++;
}
- }
- // -- Compressed resource?
+ const char **uap = uwp_uap_capabilities;
+ while (*uap) {
+ r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "capabilities/" + String(*uap).camelcase_to_underscore(false)), false));
+ uap++;
+ }
- if (p_data.size() >= 4 && p_data[0] == 'R' && p_data[1] == 'S' && p_data[2] == 'C' && p_data[3] == 'C') {
- // Already compressed
- return false;
+ const char **device = uwp_device_capabilites;
+ while (*device) {
+ r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "capabilities/" + String(*device).camelcase_to_underscore(false)), false));
+ device++;
+ }
}
- // --- TODO: Decide on texture resources according to their image compression setting
-
- return true;
-}
-
-bool EditorExportPlatformUWP::_set(const StringName& p_name, const Variant& p_value) {
-
- String n = p_name;
-
- if (n == "architecture/target")
- arch = (Platform)((int)p_value);
- else if (n == "custom_package/debug")
- custom_debug_package = p_value;
- else if (n == "custom_package/release")
- custom_release_package = p_value;
- else if (n == "command_line/extra_args")
- cmdline = p_value;
- else if (n == "package/display_name")
- display_name = p_value;
- else if (n == "package/short_name")
- short_name = p_value;
- else if (n == "package/unique_name")
- unique_name = p_value;
- else if (n == "package/description")
- description = p_value;
- else if (n == "package/publisher")
- publisher = p_value;
- else if (n == "package/publisher_display_name")
- publisher_display_name = p_value;
- else if (n == "identity/product_guid")
- product_guid = p_value;
- else if (n == "identity/publisher_guid")
- publisher_guid = p_value;
- else if (n == "version/major")
- version_major = p_value;
- else if (n == "version/minor")
- version_minor = p_value;
- else if (n == "version/build")
- version_build = p_value;
- else if (n == "version/revision")
- version_revision = p_value;
- else if (n == "orientation/landscape")
- orientation_landscape = p_value;
- else if (n == "orientation/portrait")
- orientation_portrait = p_value;
- else if (n == "orientation/landscape_flipped")
- orientation_landscape_flipped = p_value;
- else if (n == "orientation/portrait_flipped")
- orientation_portrait_flipped = p_value;
- else if (n == "images/background_color")
- background_color = p_value;
- else if (n == "images/store_logo")
- store_logo = p_value;
- else if (n == "images/square44x44_logo")
- square44 = p_value;
- else if (n == "images/square71x71_logo")
- square71 = p_value;
- else if (n == "images/square150x150_logo")
- square150 = p_value;
- else if (n == "images/square310x310_logo")
- square310 = p_value;
- else if (n == "images/wide310x150_logo")
- wide310 = p_value;
- else if (n == "images/splash_screen")
- splash = p_value;
- else if (n == "tiles/show_name_on_square150x150")
- name_on_square150 = p_value;
- else if (n == "tiles/show_name_on_wide310x150")
- name_on_wide = p_value;
- else if (n == "tiles/show_name_on_square310x310")
- name_on_square310 = p_value;
-
-#if 0 // Signing disabled
- else if (n == "signing/sign")
- sign_package = p_value;
- else if (n == "signing/certificate_file")
- certificate_path = p_value;
- else if (n == "signing/certificate_password")
- certificate_pass = p_value;
-#endif
- else if (n.begins_with("capabilities/")) {
-
- String what = n.get_slice("/", 1).replace("_", "");
- bool enable = p_value;
-
- if (array_has(uwp_capabilities, what.utf8().get_data())) {
-
- if (enable)
- capabilities.insert(what);
- else
- capabilities.erase(what);
-
- } else if (array_has(uwp_uap_capabilities, what.utf8().get_data())) {
-
- if (enable)
- uap_capabilities.insert(what);
- else
- uap_capabilities.erase(what);
-
- } else if (array_has(uwp_device_capabilites, what.utf8().get_data())) {
-
- if (enable)
- device_capabilities.insert(what);
- else
- device_capabilities.erase(what);
+ virtual bool can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const {
+ String err;
+ bool valid = true;
+ Platform arch = (Platform)(int)(p_preset->get("architecture/target"));
+
+ String custom_debug_binary = p_preset->get("custom_template/debug");
+ String custom_release_binary = p_preset->get("custom_template/release");
+
+ String platform_infix;
+
+ switch (arch) {
+ case EditorExportUWP::ARM: {
+ platform_infix = "arm";
+ } break;
+ case EditorExportUWP::X86: {
+ platform_infix = "x86";
+ } break;
+ case EditorExportUWP::X64: {
+ platform_infix = "x64";
+ } break;
}
- } else return false;
- return true;
-}
-
-bool EditorExportPlatformUWP::_get(const StringName& p_name, Variant &r_ret) const {
-
- String n = p_name;
-
- if (n == "architecture/target")
- r_ret = (int)arch;
- else if (n == "custom_package/debug")
- r_ret = custom_debug_package;
- else if (n == "custom_package/release")
- r_ret = custom_release_package;
- else if (n == "command_line/extra_args")
- r_ret = cmdline;
- else if (n == "package/display_name")
- r_ret = display_name;
- else if (n == "package/short_name")
- r_ret = short_name;
- else if (n == "package/unique_name")
- r_ret = unique_name;
- else if (n == "package/description")
- r_ret = description;
- else if (n == "package/publisher")
- r_ret = publisher;
- else if (n == "package/publisher_display_name")
- r_ret = publisher_display_name;
- else if (n == "identity/product_guid")
- r_ret = product_guid;
- else if (n == "identity/publisher_guid")
- r_ret = publisher_guid;
- else if (n == "version/major")
- r_ret = version_major;
- else if (n == "version/minor")
- r_ret = version_minor;
- else if (n == "version/build")
- r_ret = version_build;
- else if (n == "version/revision")
- r_ret = version_revision;
- else if (n == "orientation/landscape")
- r_ret = orientation_landscape;
- else if (n == "orientation/portrait")
- r_ret = orientation_portrait;
- else if (n == "orientation/landscape_flipped")
- r_ret = orientation_landscape_flipped;
- else if (n == "orientation/portrait_flipped")
- r_ret = orientation_portrait_flipped;
- else if (n == "images/background_color")
- r_ret = background_color;
- else if (n == "images/store_logo")
- r_ret = store_logo;
- else if (n == "images/square44x44_logo")
- r_ret = square44;
- else if (n == "images/square71x71_logo")
- r_ret = square71;
- else if (n == "images/square150x150_logo")
- r_ret = square150;
- else if (n == "images/square310x310_logo")
- r_ret = square310;
- else if (n == "images/wide310x150_logo")
- r_ret = wide310;
- else if (n == "images/splash_screen")
- r_ret = splash;
- else if (n == "tiles/show_name_on_square150x150")
- r_ret = name_on_square150;
- else if (n == "tiles/show_name_on_wide310x150")
- r_ret = name_on_wide;
- else if (n == "tiles/show_name_on_square310x310")
- r_ret = name_on_square310;
-
-#if 0 // Signing disabled
- else if (n == "signing/sign")
- r_ret = sign_package;
- else if (n == "signing/certificate_file")
- r_ret = certificate_path;
- else if (n == "signing/certificate_password")
- r_ret = certificate_pass;
-#endif
- else if (n.begins_with("capabilities/")) {
-
- String what = n.get_slice("/", 1).replace("_", "");
-
- if (array_has(uwp_capabilities, what.utf8().get_data())) {
-
- r_ret = capabilities.has(what);
-
- } else if (array_has(uwp_uap_capabilities, what.utf8().get_data())) {
-
- r_ret = uap_capabilities.has(what);
-
- } else if (array_has(uwp_device_capabilites, what.utf8().get_data())) {
-
- r_ret = device_capabilities.has(what);
+ if (!exists_export_template("uwp_" + platform_infix + "_debug.zip", &err) || !exists_export_template("uwp_" + platform_infix + "_debug.zip", &err)) {
+ valid = false;
+ r_missing_templates = true;
}
- } else return false;
-
- return true;
-}
-
-void EditorExportPlatformUWP::_get_property_list(List<PropertyInfo>* p_list) const {
-
- p_list->push_back(PropertyInfo(Variant::STRING, "custom_package/debug", PROPERTY_HINT_GLOBAL_FILE, "appx"));
- p_list->push_back(PropertyInfo(Variant::STRING, "custom_package/release", PROPERTY_HINT_GLOBAL_FILE, "appx"));
-
- p_list->push_back(PropertyInfo(Variant::INT, "architecture/target", PROPERTY_HINT_ENUM, "ARM,x86,x64"));
-
- p_list->push_back(PropertyInfo(Variant::STRING, "command_line/extra_args"));
-
- p_list->push_back(PropertyInfo(Variant::STRING, "package/display_name"));
- p_list->push_back(PropertyInfo(Variant::STRING, "package/short_name"));
- p_list->push_back(PropertyInfo(Variant::STRING, "package/unique_name"));
- p_list->push_back(PropertyInfo(Variant::STRING, "package/description"));
- p_list->push_back(PropertyInfo(Variant::STRING, "package/publisher"));
- p_list->push_back(PropertyInfo(Variant::STRING, "package/publisher_display_name"));
-
- p_list->push_back(PropertyInfo(Variant::STRING, "identity/product_guid"));
- p_list->push_back(PropertyInfo(Variant::STRING, "identity/publisher_guid"));
-
- p_list->push_back(PropertyInfo(Variant::INT, "version/major"));
- p_list->push_back(PropertyInfo(Variant::INT, "version/minor"));
- p_list->push_back(PropertyInfo(Variant::INT, "version/build"));
- p_list->push_back(PropertyInfo(Variant::INT, "version/revision"));
-
- p_list->push_back(PropertyInfo(Variant::BOOL, "orientation/landscape"));
- p_list->push_back(PropertyInfo(Variant::BOOL, "orientation/portrait"));
- p_list->push_back(PropertyInfo(Variant::BOOL, "orientation/landscape_flipped"));
- p_list->push_back(PropertyInfo(Variant::BOOL, "orientation/portrait_flipped"));
-
- p_list->push_back(PropertyInfo(Variant::STRING, "images/background_color"));
- p_list->push_back(PropertyInfo(Variant::OBJECT, "images/store_logo", PROPERTY_HINT_RESOURCE_TYPE, "ImageTexture"));
- p_list->push_back(PropertyInfo(Variant::OBJECT, "images/square44x44_logo", PROPERTY_HINT_RESOURCE_TYPE, "ImageTexture"));
- p_list->push_back(PropertyInfo(Variant::OBJECT, "images/square71x71_logo", PROPERTY_HINT_RESOURCE_TYPE, "ImageTexture"));
- p_list->push_back(PropertyInfo(Variant::OBJECT, "images/square150x150_logo", PROPERTY_HINT_RESOURCE_TYPE, "ImageTexture"));
- p_list->push_back(PropertyInfo(Variant::OBJECT, "images/square310x310_logo", PROPERTY_HINT_RESOURCE_TYPE, "ImageTexture"));
- p_list->push_back(PropertyInfo(Variant::OBJECT, "images/wide310x150_logo", PROPERTY_HINT_RESOURCE_TYPE, "ImageTexture"));
- p_list->push_back(PropertyInfo(Variant::OBJECT, "images/splash_screen", PROPERTY_HINT_RESOURCE_TYPE, "ImageTexture"));
-
- p_list->push_back(PropertyInfo(Variant::BOOL, "tiles/show_name_on_square150x150"));
- p_list->push_back(PropertyInfo(Variant::BOOL, "tiles/show_name_on_wide310x150"));
- p_list->push_back(PropertyInfo(Variant::BOOL, "tiles/show_name_on_square310x310"));
-
-#if 0 // Signing does not work :( disabling for now
- p_list->push_back(PropertyInfo(Variant::BOOL, "signing/sign"));
- p_list->push_back(PropertyInfo(Variant::STRING, "signing/certificate_file", PROPERTY_HINT_GLOBAL_FILE, "pfx"));
- p_list->push_back(PropertyInfo(Variant::STRING, "signing/certificate_password"));
-#endif
-
- // Capabilites
- const char **basic = uwp_capabilities;
- while (*basic) {
- p_list->push_back(PropertyInfo(Variant::BOOL, "capabilities/" + String(*basic).camelcase_to_underscore(false)));
- basic++;
- }
- const char **uap = uwp_uap_capabilities;
- while (*uap) {
- p_list->push_back(PropertyInfo(Variant::BOOL, "capabilities/" + String(*uap).camelcase_to_underscore(false)));
- uap++;
- }
-
- const char **device = uwp_device_capabilites;
- while (*device) {
- p_list->push_back(PropertyInfo(Variant::BOOL, "capabilities/" + String(*device).camelcase_to_underscore(false)));
- device++;
- }
+ if (!valid && custom_debug_binary == "" && custom_release_binary == "") {
+ if (!err.empty()) {
+ r_error = err;
+ }
+ return valid;
+ }
-}
+ bool dvalid = true;
+ bool rvalid = true;
-bool EditorExportPlatformUWP::can_export(String * r_error) const {
+ if (!FileAccess::exists(custom_debug_binary)) {
+ dvalid = false;
+ err = "\nCustom debug binary not found.";
+ }
- String err;
- bool valid = true;
+ if (!FileAccess::exists(custom_release_binary)) {
+ rvalid = false;
+ err += "\nCustom release binary not found.";
+ }
- if (!exists_export_template("uwp_x86_debug.zip") || !exists_export_template("uwp_x86_release.zip")
- || !exists_export_template("uwp_arm_debug.zip") || !exists_export_template("uwp_arm_release.zip")
- || !exists_export_template("uwp_x64_debug.zip") || !exists_export_template("uwp_x64_release.zip")) {
- valid = false;
- err += TTR("No export templates found.\nDownload and install export templates.") + "\n";
- }
+ if (dvalid || rvalid)
+ valid = true;
- if (custom_debug_package != "" && !FileAccess::exists(custom_debug_package)) {
- valid = false;
- err += TTR("Custom debug package not found.") + "\n";
- }
+ if (!valid) {
+ r_error = err;
+ return valid;
+ }
- if (custom_release_package != "" && !FileAccess::exists(custom_release_package)) {
- valid = false;
- err += TTR("Custom release package not found.") + "\n";
- }
+ if (!_valid_resource_name(p_preset->get("package/unique_name"))) {
+ valid = false;
+ err += "\nInvalid unique name.";
+ }
- if (!_valid_resource_name(unique_name)) {
- valid = false;
- err += TTR("Invalid unique name.") + "\n";
- }
+ if (!_valid_guid(p_preset->get("identity/product_guid"))) {
+ valid = false;
+ err += "\nInvalid product GUID.";
+ }
- if (!_valid_guid(product_guid)) {
- valid = false;
- err += TTR("Invalid product GUID.") + "\n";
- }
+ if (!_valid_guid(p_preset->get("identity/publisher_guid"))) {
+ valid = false;
+ err += "\nInvalid publisher GUID.";
+ }
- if (!_valid_guid(publisher_guid)) {
- valid = false;
- err += TTR("Invalid publisher GUID.") + "\n";
- }
+ if (!_valid_bgcolor(p_preset->get("images/background_color"))) {
+ valid = false;
+ err += "\nInvalid background color.";
+ }
- if (!_valid_bgcolor(background_color)) {
- valid = false;
- err += TTR("Invalid background color.") + "\n";
- }
+ if (!p_preset->get("images/store_logo").is_zero() && !_valid_image(((Object *)p_preset->get("images/store_logo"))->cast_to<StreamTexture>(), 50, 50)) {
+ valid = false;
+ err += "\nInvalid Store Logo image dimensions (should be 50x50).";
+ }
- if (store_logo.is_valid() && !_valid_image(store_logo, 50, 50)) {
- valid = false;
- err += TTR("Invalid Store Logo image dimensions (should be 50x50).") + "\n";
- }
+ if (!p_preset->get("images/square44x44_logo").is_zero() && !_valid_image(((Object *)p_preset->get("images/square44x44_logo"))->cast_to<StreamTexture>(), 44, 44)) {
+ valid = false;
+ err += "\nInvalid square 44x44 logo image dimensions (should be 44x44).";
+ }
- if (square44.is_valid() && !_valid_image(square44, 44, 44)) {
- valid = false;
- err += TTR("Invalid square 44x44 logo image dimensions (should be 44x44).") + "\n";
- }
+ if (!p_preset->get("images/square71x71_logo").is_zero() && !_valid_image(((Object *)p_preset->get("images/square71x71_logo"))->cast_to<StreamTexture>(), 71, 71)) {
+ valid = false;
+ err += "\nInvalid square 71x71 logo image dimensions (should be 71x71).";
+ }
- if (square71.is_valid() && !_valid_image(square71, 71, 71)) {
- valid = false;
- err += TTR("Invalid square 71x71 logo image dimensions (should be 71x71).") + "\n";
- }
+ if (!p_preset->get("images/square150x150_logo").is_zero() && !_valid_image(((Object *)p_preset->get("images/square150x150_logo"))->cast_to<StreamTexture>(), 150, 0)) {
+ valid = false;
+ err += "\nInvalid square 150x150 logo image dimensions (should be 150x150).";
+ }
- if (square150.is_valid() && !_valid_image(square150, 150, 150)) {
- valid = false;
- err += TTR("Invalid square 150x150 logo image dimensions (should be 150x150).") + "\n";
- }
+ if (!p_preset->get("images/square310x310_logo").is_zero() && !_valid_image(((Object *)p_preset->get("images/square310x310_logo"))->cast_to<StreamTexture>(), 310, 310)) {
+ valid = false;
+ err += "\nInvalid square 310x310 logo image dimensions (should be 310x310).";
+ }
- if (square310.is_valid() && !_valid_image(square310, 310, 310)) {
- valid = false;
- err += TTR("Invalid square 310x310 logo image dimensions (should be 310x310).") + "\n";
- }
+ if (!p_preset->get("images/wide310x150_logo").is_zero() && !_valid_image(((Object *)p_preset->get("images/wide310x150_logo"))->cast_to<StreamTexture>(), 310, 150)) {
+ valid = false;
+ err += "\nInvalid wide 310x150 logo image dimensions (should be 310x150).";
+ }
- if (wide310.is_valid() && !_valid_image(wide310, 310, 150)) {
- valid = false;
- err += TTR("Invalid wide 310x150 logo image dimensions (should be 310x150).") + "\n";
- }
+ if (!p_preset->get("images/splash_screen").is_zero() && !_valid_image(((Object *)p_preset->get("images/splash_screen"))->cast_to<StreamTexture>(), 620, 300)) {
+ valid = false;
+ err += "\nInvalid splash screen image dimensions (should be 620x300).";
+ }
- if (splash.is_valid() && !_valid_image(splash, 620, 300)) {
- valid = false;
- err += TTR("Invalid splash screen image dimensions (should be 620x300).") + "\n";
+ r_error = err;
+ return valid;
}
- if (r_error)
- *r_error = err;
+ virtual Error export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0) {
- return valid;
-}
+ String src_appx;
-Error EditorExportPlatformUWP::export_project(const String & p_path, bool p_debug, int p_flags) {
+ EditorProgress ep("export", "Exporting for Windows Universal", 7);
- String src_appx;
+ if (p_debug)
+ src_appx = p_preset->get("custom_template/debug");
+ else
+ src_appx = p_preset->get("custom_template/release");
- EditorProgress ep("export", "Exporting for Windows Universal", 7);
+ src_appx = src_appx.strip_edges();
- if (is_debug)
- src_appx = custom_debug_package;
- else
- src_appx = custom_release_package;
+ Platform arch = (Platform)(int)p_preset->get("architecture/target");
- if (src_appx == "") {
- String err;
- if (p_debug) {
+ if (src_appx == "") {
+ String err, infix;
switch (arch) {
- case X86: {
- src_appx = find_export_template("uwp_x86_debug.zip", &err);
- break;
- }
- case X64: {
- src_appx = find_export_template("uwp_x64_debug.zip", &err);
- break;
- }
case ARM: {
- src_appx = find_export_template("uwp_arm_debug.zip", &err);
- break;
- }
- }
- } else {
- switch (arch) {
+ infix = "_arm_";
+ } break;
case X86: {
- src_appx = find_export_template("uwp_x86_release.zip", &err);
- break;
- }
+ infix = "_x86_";
+ } break;
case X64: {
- src_appx = find_export_template("uwp_x64_release.zip", &err);
- break;
- }
- case ARM: {
- src_appx = find_export_template("uwp_arm_release.zip", &err);
- break;
- }
+ infix = "_x64_";
+ } break;
+ }
+ if (p_debug) {
+ src_appx = find_export_template("uwp" + infix + "debug.zip", &err);
+ } else {
+ src_appx = find_export_template("uwp" + infix + "release.zip", &err);
+ }
+ if (src_appx == "") {
+ EditorNode::add_io_error(err);
+ return ERR_FILE_NOT_FOUND;
}
}
- if (src_appx == "") {
- EditorNode::add_io_error(err);
- return ERR_FILE_NOT_FOUND;
- }
- }
- Error err = OK;
+ Error err = OK;
- FileAccess *fa_pack = FileAccess::open(p_path, FileAccess::WRITE, &err);
- ERR_FAIL_COND_V(err != OK, ERR_CANT_CREATE);
+ FileAccess *fa_pack = FileAccess::open(p_path, FileAccess::WRITE, &err);
+ ERR_FAIL_COND_V(err != OK, ERR_CANT_CREATE);
- AppxPackager packager;
- packager.init(fa_pack, sign_package ? AppxPackager::SIGN : AppxPackager::DONT_SIGN, certificate_path, certificate_pass);
+ AppxPackager packager;
+ packager.init(fa_pack);
- FileAccess *src_f = NULL;
- zlib_filefunc_def io = zipio_create_io_from_file(&src_f);
+ FileAccess *src_f = NULL;
+ zlib_filefunc_def io = zipio_create_io_from_file(&src_f);
- ep.step("Creating package...", 0);
+ ep.step("Creating package...", 0);
- unzFile pkg = unzOpen2(src_appx.utf8().get_data(), &io);
+ unzFile pkg = unzOpen2(src_appx.utf8().get_data(), &io);
- if (!pkg) {
+ if (!pkg) {
- EditorNode::add_io_error("Could not find template appx to export:\n" + src_appx);
- return ERR_FILE_NOT_FOUND;
- }
-
- int ret = unzGoToFirstFile(pkg);
-
- ep.step("Copying template files...", 1);
-
- EditorNode::progress_add_task("template_files", "Template files", 100);
- packager.set_progress_task("template_files");
-
- int template_files_amount = 9;
- int template_file_no = 1;
-
- while (ret == UNZ_OK) {
-
- // get file name
- unz_file_info info;
- char fname[16834];
- ret = unzGetCurrentFileInfo(pkg, &info, fname, 16834, NULL, 0, NULL, 0);
-
- String path = fname;
-
- if (path.ends_with("/")) {
- // Ignore directories
- ret = unzGoToNextFile(pkg);
- continue;
+ EditorNode::add_io_error("Could not find template appx to export:\n" + src_appx);
+ return ERR_FILE_NOT_FOUND;
}
- Vector<uint8_t> data;
- bool do_read = true;
-
- if (path.begins_with("Assets/")) {
+ int ret = unzGoToFirstFile(pkg);
- path = path.replace(".scale-100", "");
+ ep.step("Copying template files...", 1);
- data = _get_image_data(path);
- if (data.size() > 0) do_read = false;
- }
+ EditorNode::progress_add_task("template_files", "Template files", 100);
+ packager.set_progress_task("template_files");
- //read
- if (do_read) {
- data.resize(info.uncompressed_size);
- unzOpenCurrentFile(pkg);
- unzReadCurrentFile(pkg, data.ptr(), data.size());
- unzCloseCurrentFile(pkg);
- }
+ int template_files_amount = 9;
+ int template_file_no = 1;
- if (path == "AppxManifest.xml") {
+ while (ret == UNZ_OK) {
- data = _fix_manifest(data, p_flags&(EXPORT_DUMB_CLIENT | EXPORT_REMOTE_DEBUG));
- }
+ // get file name
+ unz_file_info info;
+ char fname[16834];
+ ret = unzGetCurrentFileInfo(pkg, &info, fname, 16834, NULL, 0, NULL, 0);
- print_line("ADDING: " + path);
+ String path = fname;
- packager.add_file(path, data.ptr(), data.size(), template_file_no++, template_files_amount, _should_compress_asset(path, data));
+ if (path.ends_with("/")) {
+ // Ignore directories
+ ret = unzGoToNextFile(pkg);
+ continue;
+ }
- ret = unzGoToNextFile(pkg);
- }
+ Vector<uint8_t> data;
+ bool do_read = true;
- EditorNode::progress_end_task("template_files");
+ if (path.begins_with("Assets/")) {
- ep.step("Creating command line...", 2);
+ path = path.replace(".scale-100", "");
- Vector<String> cl = cmdline.strip_edges().split(" ");
- for (int i = 0;i<cl.size();i++) {
- if (cl[i].strip_edges().length() == 0) {
- cl.remove(i);
- i--;
- }
- }
-
- if (!(p_flags & EXPORT_DUMB_CLIENT)) {
- cl.push_back("-path");
- cl.push_back("game");
- }
+ data = _get_image_data(p_preset, path);
+ if (data.size() > 0) do_read = false;
+ }
- gen_export_flags(cl, p_flags);
+ //read
+ if (do_read) {
+ data.resize(info.uncompressed_size);
+ unzOpenCurrentFile(pkg);
+ unzReadCurrentFile(pkg, data.ptr(), data.size());
+ unzCloseCurrentFile(pkg);
+ }
- // Command line file
- Vector<uint8_t> clf;
+ if (path == "AppxManifest.xml") {
- // Argc
- clf.resize(4);
- encode_uint32(cl.size(), clf.ptr());
+ data = _fix_manifest(p_preset, data, p_flags & (DEBUG_FLAG_DUMB_CLIENT | DEBUG_FLAG_REMOTE_DEBUG));
+ }
- for (int i = 0; i < cl.size(); i++) {
+ print_line("ADDING: " + path);
- CharString txt = cl[i].utf8();
- int base = clf.size();
- clf.resize(base + 4 + txt.length());
- encode_uint32(txt.length(), &clf[base]);
- copymem(&clf[base + 4], txt.ptr(), txt.length());
- print_line(itos(i) + " param: " + cl[i]);
- }
+ packager.add_file(path, data.ptr(), data.size(), template_file_no++, template_files_amount, _should_compress_asset(path, data));
- packager.add_file("__cl__.cl", clf.ptr(), clf.size(), -1, -1, false);
+ ret = unzGoToNextFile(pkg);
+ }
- ep.step("Adding project files...", 3);
+ EditorNode::progress_end_task("template_files");
- EditorNode::progress_add_task("project_files", "Project Files", 100);
- packager.set_progress_task("project_files");
+ ep.step("Creating command line...", 2);
- err = export_project_files(save_appx_file, &packager, false);
+ Vector<String> cl = ((String)p_preset->get("command_line/extra_args")).strip_edges().split(" ");
+ for (int i = 0; i < cl.size(); i++) {
+ if (cl[i].strip_edges().length() == 0) {
+ cl.remove(i);
+ i--;
+ }
+ }
- EditorNode::progress_end_task("project_files");
+ if (!(p_flags & DEBUG_FLAG_DUMB_CLIENT)) {
+ cl.push_back("-path");
+ cl.push_back("game");
+ }
- ep.step("Closing package...", 7);
+ gen_export_flags(cl, p_flags);
- unzClose(pkg);
+ // Command line file
+ Vector<uint8_t> clf;
- packager.finish();
+ // Argc
+ clf.resize(4);
+ encode_uint32(cl.size(), clf.ptr());
- return OK;
-}
+ for (int i = 0; i < cl.size(); i++) {
-EditorExportPlatformUWP::EditorExportPlatformUWP() {
+ CharString txt = cl[i].utf8();
+ int base = clf.size();
+ clf.resize(base + 4 + txt.length());
+ encode_uint32(txt.length(), &clf[base]);
+ copymem(&clf[base + 4], txt.ptr(), txt.length());
+ print_line(itos(i) + " param: " + cl[i]);
+ }
- Image img(_uwp_logo);
- logo = Ref<ImageTexture>(memnew(ImageTexture));
- logo->create_from_image(img);
+ packager.add_file("__cl__.cl", clf.ptr(), clf.size(), -1, -1, false);
- is_debug = true;
+ ep.step("Adding project files...", 3);
- custom_release_package = "";
- custom_debug_package = "";
+ EditorNode::progress_add_task("project_files", "Project Files", 100);
+ packager.set_progress_task("project_files");
- arch = X86;
+ err = export_project_files(p_preset, save_appx_file, &packager);
- display_name = "";
- short_name = "Godot";
- unique_name = "Godot.Engine";
- description = "Godot Engine";
- publisher = "CN=GodotEngine";
- publisher_display_name = "Godot Engine";
+ EditorNode::progress_end_task("project_files");
- product_guid = "00000000-0000-0000-0000-000000000000";
- publisher_guid = "00000000-0000-0000-0000-000000000000";
+ ep.step("Closing package...", 7);
- version_major = 1;
- version_minor = 0;
- version_build = 0;
- version_revision = 0;
+ unzClose(pkg);
- orientation_landscape = true;
- orientation_portrait = true;
- orientation_landscape_flipped = true;
- orientation_portrait_flipped = true;
+ packager.finish();
- background_color = "transparent";
+ return OK;
+ }
- name_on_square150 = false;
- name_on_square310 = false;
- name_on_wide = false;
+ virtual void get_platform_features(List<String> *r_features) {
- sign_package = false;
- certificate_path = "";
- certificate_pass = "";
-}
+ r_features->push_back("pc");
+ r_features->push_back("UWP");
+ }
-EditorExportPlatformUWP::~EditorExportPlatformUWP() {}
+ EditorExportUWP() {
+ Ref<Image> img = memnew(Image(_uwp_logo));
+ logo.instance();
+ logo->create_from_image(img);
+ }
+};
-#endif
void register_uwp_exporter() {
-#if 0
- Ref<EditorExportPlatformUWP> exporter = Ref<EditorExportPlatformUWP>(memnew(EditorExportPlatformUWP));
- EditorImportExport::get_singleton()->add_export_platform(exporter);
-#endif
+ Ref<EditorExportUWP> exporter = Ref<EditorExportUWP>(memnew(EditorExportUWP));
+ EditorExport::get_singleton()->add_export_platform(exporter);
}
diff --git a/platform/uwp/os_uwp.cpp b/platform/uwp/os_uwp.cpp
index 28aaf9161b..fabb227bf5 100644
--- a/platform/uwp/os_uwp.cpp
+++ b/platform/uwp/os_uwp.cpp
@@ -35,12 +35,12 @@
#include "drivers/windows/mutex_windows.h"
#include "drivers/windows/rw_lock_windows.h"
#include "drivers/windows/semaphore_windows.h"
-#include "global_config.h"
#include "io/marshalls.h"
#include "main/main.h"
#include "platform/windows/packet_peer_udp_winsock.h"
#include "platform/windows/stream_peer_winsock.h"
#include "platform/windows/tcp_server_winsock.h"
+#include "project_settings.h"
#include "servers/audio_server.h"
#include "servers/visual/visual_server_raster.h"
#include "thread_uwp.h"
@@ -310,7 +310,7 @@ void OSUWP::initialize(const VideoMode &p_desired, int p_video_driver, int p_aud
if (is_keep_screen_on())
display_request->RequestActive();
- set_keep_screen_on(GLOBAL_DEF("display/keep_screen_on", true));
+ set_keep_screen_on(GLOBAL_DEF("display/window/keep_screen_on", true));
}
void OSUWP::set_clipboard(const String &p_text) {
@@ -851,9 +851,8 @@ String OSUWP::get_data_dir() const {
return String(data_folder->Path->Data()).replace("\\", "/");
}
-bool OSUWP::check_feature_support(const String &p_feature) {
-
- return VisualServer::get_singleton()->has_os_feature(p_feature);
+bool OSUWP::_check_internal_feature_support(const String &p_feature) {
+ return p_feature == "pc" || p_feature == "s3tc";
}
PowerState OSUWP::get_power_state() {
diff --git a/platform/uwp/os_uwp.h b/platform/uwp/os_uwp.h
index 45b8eefdee..dfa21a0934 100644
--- a/platform/uwp/os_uwp.h
+++ b/platform/uwp/os_uwp.h
@@ -236,7 +236,7 @@ public:
virtual void move_window_to_foreground();
virtual String get_data_dir() const;
- virtual bool check_feature_support(const String &p_feature);
+ virtual bool _check_internal_feature_support(const String &p_feature);
void set_gl_context(ContextEGL *p_context);
void screen_size_changed();
diff --git a/platform/windows/detect.py b/platform/windows/detect.py
index 5e56c1db49..4d93b3f244 100644
--- a/platform/windows/detect.py
+++ b/platform/windows/detect.py
@@ -1,104 +1,7 @@
-#
-# tested on | Windows native | Linux cross-compilation
-# ----------------------------+-------------------+---------------------------
-# Visual C++ Build Tools 2015 | WORKS | n/a
-# MSVS C++ 2010 Express | WORKS | n/a
-# Mingw-w64 | WORKS | WORKS
-# Mingw-w32 | WORKS | WORKS
-# MinGW | WORKS | untested
-#
-#####
-# Note about Visual C++ Build Tools :
-#
-# - Visual C++ Build Tools is the standalone MSVC compiler :
-# http://landinghub.visualstudio.com/visual-cpp-build-tools
-#
-#####
-# Notes about MSVS C++ :
-#
-# - MSVC2010-Express compiles to 32bits only.
-#
-#####
-# Notes about Mingw-w64 and Mingw-w32 under Windows :
-#
-# - both can be installed using the official installer :
-# http://mingw-w64.sourceforge.net/download.php#mingw-builds
-#
-# - if you want to compile both 32bits and 64bits, don't forget to
-# run the installer twice to install them both.
-#
-# - install them into a path that does not contain spaces
-# ( example : "C:/Mingw-w32", "C:/Mingw-w64" )
-#
-# - if you want to compile faster using the "-j" option, don't forget
-# to install the appropriate version of the Pywin32 python extension
-# available from : http://sourceforge.net/projects/pywin32/files/
-#
-# - before running scons, you must add into the environment path
-# the path to the "/bin" directory of the Mingw version you want
-# to use :
-#
-# set PATH=C:/Mingw-w32/bin;%PATH%
-#
-# - then, scons should be able to detect gcc.
-# - Mingw-w32 only compiles 32bits.
-# - Mingw-w64 only compiles 64bits.
-#
-# - it is possible to add them both at the same time into the PATH env,
-# if you also define the MINGW32_PREFIX and MINGW64_PREFIX environment
-# variables.
-# For instance, you could store that set of commands into a .bat script
-# that you would run just before scons :
-#
-# set PATH=C:\mingw-w32\bin;%PATH%
-# set PATH=C:\mingw-w64\bin;%PATH%
-# set MINGW32_PREFIX=C:\mingw-w32\bin\
-# set MINGW64_PREFIX=C:\mingw-w64\bin\
-#
-#####
-# Notes about Mingw, Mingw-w64 and Mingw-w32 under Linux :
-#
-# - default toolchain prefixes are :
-# "i586-mingw32msvc-" for MinGW
-# "i686-w64-mingw32-" for Mingw-w32
-# "x86_64-w64-mingw32-" for Mingw-w64
-#
-# - if both MinGW and Mingw-w32 are installed on your system
-# Mingw-w32 should take the priority over MinGW.
-#
-# - it is possible to manually override prefixes by defining
-# the MINGW32_PREFIX and MINGW64_PREFIX environment variables.
-#
-#####
-# Notes about Mingw under Windows :
-#
-# - this is the MinGW version from http://mingw.org/
-# - install it into a path that does not contain spaces
-# ( example : "C:/MinGW" )
-# - several DirectX headers might be missing. You can copy them into
-# the C:/MinGW/include" directory from this page :
-# https://code.google.com/p/mingw-lib/source/browse/trunk/working/avcodec_to_widget_5/directx_include/
-# - before running scons, add the path to the "/bin" directory :
-# set PATH=C:/MinGW/bin;%PATH%
-# - scons should be able to detect gcc.
-#
-
-#####
-# TODO :
-#
-# - finish to cleanup this script to remove all the remains of previous hacks and workarounds
-# - make it work with the Windows7 SDK that is supposed to enable 64bits compilation for MSVC2010-Express
-# - confirm it works well with other Visual Studio versions.
-# - update the wiki about the pywin32 extension required for the "-j" option under Windows.
-# - update the wiki to document MINGW32_PREFIX and MINGW64_PREFIX
-#
-
+import methods
import os
-
import sys
-import methods
-
def is_active():
return True
@@ -115,7 +18,7 @@ def can_build():
if (os.getenv("VCINSTALLDIR")):
return True
else:
- print("\nMSVC not detected, attempting Mingw.")
+ print("\nMSVC not detected, attempting MinGW.")
mingw32 = ""
mingw64 = ""
if (os.getenv("MINGW32_PREFIX")):
@@ -126,7 +29,7 @@ def can_build():
test = "gcc --version > NUL 2>&1"
if os.system(test) != 0 and os.system(mingw32 + test) != 0 and os.system(mingw64 + test) != 0:
print("- could not detect gcc.")
- print("Please, make sure a path to a Mingw /bin directory is accessible into the environment PATH.\n")
+ print("Please, make sure a path to a MinGW /bin directory is accessible into the environment PATH.\n")
return False
else:
print("- gcc detected.")
@@ -145,7 +48,7 @@ def can_build():
if (os.getenv("MINGW64_PREFIX")):
mingw64 = os.getenv("MINGW64_PREFIX")
- test = "gcc --version &>/dev/null"
+ test = "gcc --version > /dev/null 2>&1"
if (os.system(mingw + test) == 0 or os.system(mingw64 + test) == 0 or os.system(mingw32 + test) == 0):
return True
@@ -162,7 +65,7 @@ def get_opts():
mingw32 = "i686-w64-mingw32-"
mingw64 = "x86_64-w64-mingw32-"
- if os.system(mingw32 + "gcc --version &>/dev/null") != 0:
+ if os.system(mingw32 + "gcc --version > /dev/null 2>&1") != 0:
mingw32 = mingw
if (os.getenv("MINGW32_PREFIX")):
@@ -172,8 +75,8 @@ def get_opts():
mingw64 = os.getenv("MINGW64_PREFIX")
return [
- ('mingw_prefix', 'Mingw Prefix', mingw32),
- ('mingw_prefix_64', 'Mingw Prefix 64 bits', mingw64),
+ ('mingw_prefix', 'MinGW Prefix', mingw32),
+ ('mingw_prefix_64', 'MinGW Prefix 64 bits', mingw64),
]
@@ -211,55 +114,86 @@ def configure(env):
# Targeted Windows version: Vista (and later)
winver = "0x0600" # Windows Vista is the minimum target for windows builds
- env['is_mingw'] = False
- if (os.name == "nt" and os.getenv("VCINSTALLDIR")):
- # build using visual studio
+ if (os.name == "nt" and os.getenv("VCINSTALLDIR")): # MSVC
+
env['ENV']['TMP'] = os.environ['TMP']
- env.Append(CPPPATH=['#platform/windows/include'])
- env.Append(LIBPATH=['#platform/windows/lib'])
- env.Append(CCFLAGS=['/DWINVER=%s' % winver, '/D_WIN32_WINNT=%s' % winver])
- if (env["target"] == "release"):
+ ## Build type
+ if (env["target"] == "release"):
env.Append(CCFLAGS=['/O2'])
env.Append(LINKFLAGS=['/SUBSYSTEM:WINDOWS'])
env.Append(LINKFLAGS=['/ENTRY:mainCRTStartup'])
elif (env["target"] == "release_debug"):
-
env.Append(CCFLAGS=['/O2', '/DDEBUG_ENABLED'])
env.Append(LINKFLAGS=['/SUBSYSTEM:CONSOLE'])
- elif (env["target"] == "debug_release"):
+ elif (env["target"] == "debug_release"):
env.Append(CCFLAGS=['/Z7', '/Od'])
env.Append(LINKFLAGS=['/DEBUG'])
env.Append(LINKFLAGS=['/SUBSYSTEM:WINDOWS'])
env.Append(LINKFLAGS=['/ENTRY:mainCRTStartup'])
elif (env["target"] == "debug"):
-
env.Append(CCFLAGS=['/Z7', '/DDEBUG_ENABLED', '/DDEBUG_MEMORY_ENABLED', '/DD3D_DEBUG_INFO', '/Od'])
env.Append(LINKFLAGS=['/SUBSYSTEM:CONSOLE'])
env.Append(LINKFLAGS=['/DEBUG'])
- env.Append(CCFLAGS=['/MT', '/Gd', '/GR', '/nologo'])
+ ## Architecture
+
+ # Note: this detection/override code from here onward should be here instead of in SConstruct because it's platform and compiler specific (MSVC/Windows)
+ if (env["bits"] != "default"):
+ print("Error: bits argument is disabled for MSVC")
+ print("""
+ Bits argument is not supported for MSVC compilation. Architecture depends on the Native/Cross Compile Tools Prompt/Developer Console
+ (or Visual Studio settings) that is being used to run SCons. As a consequence, bits argument is disabled. Run scons again without bits
+ argument (example: scons p=windows) and SCons will attempt to detect what MSVC compiler will be executed and inform you.
+ """)
+ sys.exit()
+
+ # Forcing bits argument because MSVC does not have a flag to set this through SCons... it's different compilers (cl.exe's) called from the proper command prompt
+ # that decide the architecture that is build for. Scons can only detect the os.getenviron (because vsvarsall.bat sets a lot of stuff for cl.exe to work with)
+ env["bits"] = "32"
+ env["x86_libtheora_opt_vc"] = True
+
+ ## Compiler configuration
+
+ env['ENV'] = os.environ
+ # This detection function needs the tools env (that is env['ENV'], not SCons's env), and that is why it's this far bellow in the code
+ compiler_version_str = methods.detect_visual_c_compiler_version(env['ENV'])
+
+ print("Detected MSVC compiler: " + compiler_version_str)
+ # If building for 64bit architecture, disable assembly optimisations for 32 bit builds (theora as of writting)... vc compiler for 64bit can not compile _asm
+ if(compiler_version_str == "amd64" or compiler_version_str == "x86_amd64"):
+ env["bits"] = "64"
+ env["x86_libtheora_opt_vc"] = False
+ print("Compiled program architecture will be a 64 bit executable (forcing bits=64).")
+ elif (compiler_version_str == "x86" or compiler_version_str == "amd64_x86"):
+ print("Compiled program architecture will be a 32 bit executable. (forcing bits=32).")
+ else:
+ print("Failed to detect MSVC compiler architecture version... Defaulting to 32bit executable settings (forcing bits=32). Compilation attempt will continue, but SCons can not detect for what architecture this build is compiled for. You should check your settings/compilation setup.")
+
+ ## Compile flags
+
+ env.Append(CCFLAGS=['/MT', '/Gd', '/GR', '/nologo'])
env.Append(CXXFLAGS=['/TP'])
env.Append(CPPFLAGS=['/DMSVC', '/GR', ])
env.Append(CCFLAGS=['/I' + os.getenv("WindowsSdkDir") + "/Include"])
+
env.Append(CCFLAGS=['/DWINDOWS_ENABLED'])
+ env.Append(CCFLAGS=['/DOPENGL_ENABLED'])
env.Append(CCFLAGS=['/DRTAUDIO_ENABLED'])
- env.Append(CCFLAGS=['/DWIN32'])
env.Append(CCFLAGS=['/DTYPED_METHOD_BIND'])
+ env.Append(CCFLAGS=['/DWIN32'])
+ env.Append(CCFLAGS=['/DWINVER=%s' % winver, '/D_WIN32_WINNT=%s' % winver])
+ if env["bits"] == "64":
+ env.Append(CCFLAGS=['/D_WIN64'])
- env.Append(CCFLAGS=['/DOPENGL_ENABLED'])
LIBS = ['winmm', 'opengl32', 'dsound', 'kernel32', 'ole32', 'oleaut32', 'user32', 'gdi32', 'IPHLPAPI', 'Shlwapi', 'wsock32', 'Ws2_32', 'shell32', 'advapi32', 'dinput8', 'dxguid']
env.Append(LINKFLAGS=[p + env["LIBSUFFIX"] for p in LIBS])
env.Append(LIBPATH=[os.getenv("WindowsSdkDir") + "/Lib"])
- if (os.getenv("DXSDK_DIR")):
- DIRECTX_PATH = os.getenv("DXSDK_DIR")
- else:
- DIRECTX_PATH = "C:/Program Files/Microsoft DirectX SDK (March 2009)"
if (os.getenv("VCINSTALLDIR")):
VC_PATH = os.getenv("VCINSTALLDIR")
@@ -268,51 +202,37 @@ def configure(env):
env.Append(CCFLAGS=["/I" + p for p in os.getenv("INCLUDE").split(";")])
env.Append(LIBPATH=[p for p in os.getenv("LIB").split(";")])
- env.Append(CCFLAGS=["/I" + DIRECTX_PATH + "/Include"])
- env.Append(LIBPATH=[DIRECTX_PATH + "/Lib/x86"])
- env['ENV'] = os.environ
-
- # This detection function needs the tools env (that is env['ENV'], not SCons's env), and that is why it's this far bellow in the code
- compiler_version_str = methods.detect_visual_c_compiler_version(env['ENV'])
-
- # Note: this detection/override code from here onward should be here instead of in SConstruct because it's platform and compiler specific (MSVC/Windows)
- if(env["bits"] != "default"):
- print "Error: bits argument is disabled for MSVC"
- print ("Bits argument is not supported for MSVC compilation. Architecture depends on the Native/Cross Compile Tools Prompt/Developer Console (or Visual Studio settings)"
- + " that is being used to run SCons. As a consequence, bits argument is disabled. Run scons again without bits argument (example: scons p=windows) and SCons will attempt to detect what MSVC compiler"
- + " will be executed and inform you.")
- sys.exit()
-
- # Forcing bits argument because MSVC does not have a flag to set this through SCons... it's different compilers (cl.exe's) called from the proper command prompt
- # that decide the architecture that is build for. Scons can only detect the os.getenviron (because vsvarsall.bat sets a lot of stuff for cl.exe to work with)
- env["bits"] = "32"
- env["x86_libtheora_opt_vc"] = True
-
- print "Detected MSVC compiler: " + compiler_version_str
- # If building for 64bit architecture, disable assembly optimisations for 32 bit builds (theora as of writting)... vc compiler for 64bit can not compile _asm
- if(compiler_version_str == "amd64" or compiler_version_str == "x86_amd64"):
- env["bits"] = "64"
- env["x86_libtheora_opt_vc"] = False
- print "Compiled program architecture will be a 64 bit executable (forcing bits=64)."
- elif (compiler_version_str == "x86" or compiler_version_str == "amd64_x86"):
- print "Compiled program architecture will be a 32 bit executable. (forcing bits=32)."
- else:
- print "Failed to detect MSVC compiler architecture version... Defaulting to 32bit executable settings (forcing bits=32). Compilation attempt will continue, but SCons can not detect for what architecture this build is compiled for. You should check your settings/compilation setup."
- if env["bits"] == "64":
- env.Append(CCFLAGS=['/D_WIN64'])
# Incremental linking fix
env['BUILDERS']['ProgramOriginal'] = env['BUILDERS']['Program']
env['BUILDERS']['Program'] = methods.precious_program
- else:
+ else: # MinGW
# Workaround for MinGW. See:
# http://www.scons.org/wiki/LongCmdLinesOnWin32
env.use_windows_spawn_fix()
- # build using mingw
- env.Append(CCFLAGS=['-DWINVER=%s' % winver, '-D_WIN32_WINNT=%s' % winver])
+ ## Build type
+
+ if (env["target"] == "release"):
+ env.Append(CCFLAGS=['-msse2'])
+
+ if (env["bits"] == "64"):
+ env.Append(CCFLAGS=['-O3'])
+ else:
+ env.Append(CCFLAGS=['-O2'])
+
+ env.Append(LINKFLAGS=['-Wl,--subsystem,windows'])
+
+ elif (env["target"] == "release_debug"):
+ env.Append(CCFLAGS=['-O2', '-DDEBUG_ENABLED'])
+
+ elif (env["target"] == "debug"):
+ env.Append(CCFLAGS=['-g', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED'])
+
+ ## Compiler configuration
+
if (os.name == "nt"):
env['ENV']['TMP'] = os.environ['TMP'] # way to go scons, you can be so stupid sometimes
else:
@@ -332,37 +252,6 @@ def configure(env):
env.Append(LINKFLAGS=['-static'])
mingw_prefix = env["mingw_prefix_64"]
- nulstr = ""
-
- if (os.name == "posix"):
- nulstr = ">/dev/null"
- else:
- nulstr = ">nul"
-
- # if os.system(mingw_prefix+"gcc --version"+nulstr)!=0:
- # #not really super consistent but..
- # print("Can't find Windows compiler: "+mingw_prefix)
- # sys.exit(255)
-
- if (env["target"] == "release"):
-
- env.Append(CCFLAGS=['-msse2'])
-
- if (env["bits"] == "64"):
- env.Append(CCFLAGS=['-O3'])
- else:
- env.Append(CCFLAGS=['-O2'])
-
- env.Append(LINKFLAGS=['-Wl,--subsystem,windows'])
-
- elif (env["target"] == "release_debug"):
-
- env.Append(CCFLAGS=['-O2', '-DDEBUG_ENABLED'])
-
- elif (env["target"] == "debug"):
-
- env.Append(CCFLAGS=['-g', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED'])
-
env["CC"] = mingw_prefix + "gcc"
env['AS'] = mingw_prefix + "as"
env['CXX'] = mingw_prefix + "g++"
@@ -371,29 +260,15 @@ def configure(env):
env['LD'] = mingw_prefix + "g++"
env["x86_libtheora_opt_gcc"] = True
- #env['CC'] = "winegcc"
- #env['CXX'] = "wineg++"
+ ## Compile flags
env.Append(CCFLAGS=['-DWINDOWS_ENABLED', '-mwindows'])
- env.Append(CPPFLAGS=['-DRTAUDIO_ENABLED'])
env.Append(CCFLAGS=['-DOPENGL_ENABLED'])
+ env.Append(CCFLAGS=['-DRTAUDIO_ENABLED'])
+ env.Append(CCFLAGS=['-DWINVER=%s' % winver, '-D_WIN32_WINNT=%s' % winver])
env.Append(LIBS=['mingw32', 'opengl32', 'dsound', 'ole32', 'd3d9', 'winmm', 'gdi32', 'iphlpapi', 'shlwapi', 'wsock32', 'ws2_32', 'kernel32', 'oleaut32', 'dinput8', 'dxguid'])
- # if (env["bits"]=="32"):
- # env.Append(LIBS=['gcc_s'])
- # #--with-arch=i686
- # env.Append(CPPFLAGS=['-march=i686'])
- # env.Append(LINKFLAGS=['-march=i686'])
-
- #'d3dx9d'
env.Append(CPPFLAGS=['-DMINGW_ENABLED'])
- # env.Append(LINKFLAGS=['-g'])
# resrc
- env['is_mingw'] = True
env.Append(BUILDERS={'RES': env.Builder(action=build_res_file, suffix='.o', src_suffix='.rc')})
-
- env.Append(BUILDERS={'GLSL120': env.Builder(action=methods.build_legacygl_headers, suffix='glsl.h', src_suffix='.glsl')})
- env.Append(BUILDERS={'GLSL': env.Builder(action=methods.build_glsl_headers, suffix='glsl.h', src_suffix='.glsl')})
- env.Append(BUILDERS={'HLSL9': env.Builder(action=methods.build_hlsl_dx9_headers, suffix='hlsl.h', src_suffix='.hlsl')})
- env.Append(BUILDERS={'GLSL120GLES': env.Builder(action=methods.build_gles2_headers, suffix='glsl.h', src_suffix='.glsl')})
diff --git a/platform/windows/export/export.cpp b/platform/windows/export/export.cpp
index c9271f6266..6cb33e2ff0 100644
--- a/platform/windows/export/export.cpp
+++ b/platform/windows/export/export.cpp
@@ -46,6 +46,7 @@ void register_windows_exporter() {
platform->set_debug_32("windows_32_debug.exe");
platform->set_release_64("windows_64_release.exe");
platform->set_debug_64("windows_64_debug.exe");
+ platform->set_os_name("Windows");
EditorExport::get_singleton()->add_export_platform(platform);
}
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp
index e94529dd94..da14d5c284 100644
--- a/platform/windows/os_windows.cpp
+++ b/platform/windows/os_windows.cpp
@@ -37,12 +37,12 @@
#include "drivers/windows/rw_lock_windows.h"
#include "drivers/windows/semaphore_windows.h"
#include "drivers/windows/thread_windows.h"
-#include "global_config.h"
#include "io/marshalls.h"
#include "joypad.h"
#include "lang_table.h"
#include "main/main.h"
#include "packet_peer_udp_winsock.h"
+#include "project_settings.h"
#include "servers/audio_server.h"
#include "servers/visual/visual_server_raster.h"
#include "servers/visual/visual_server_wrap_mt.h"
@@ -805,7 +805,12 @@ void OS_Windows::process_key_events() {
k->set_pressed(ke.uMsg == WM_KEYDOWN);
- k->set_scancode(KeyMappingWindows::get_keysym(ke.wParam));
+ if ((ke.lParam & (1 << 24)) && (ke.wParam == VK_RETURN)) {
+ // Special case for Numpad Enter key
+ k->set_scancode(KEY_ENTER);
+ } else {
+ k->set_scancode(KeyMappingWindows::get_keysym(ke.wParam));
+ }
if (i + 1 < key_event_pos && key_event_buffer[i + 1].uMsg == WM_CHAR) {
k->set_unicode(key_event_buffer[i + 1].wParam);
@@ -1410,28 +1415,21 @@ void OS_Windows::set_window_size(const Size2 p_size) {
return;
}
- RECT crect;
- GetClientRect(hWnd, &crect);
+ int w = p_size.width;
+ int h = p_size.height;
RECT rect;
GetWindowRect(hWnd, &rect);
- int dx = (rect.right - rect.left) - (crect.right - crect.left);
- int dy = (rect.bottom - rect.top) - (crect.bottom - crect.top);
-
- rect.right = rect.left + p_size.width + dx;
- rect.bottom = rect.top + p_size.height + dy;
- //print_line("PRE: "+itos(rect.left)+","+itos(rect.top)+","+itos(rect.right-rect.left)+","+itos(rect.bottom-rect.top));
+ if (video_mode.borderless_window == false) {
+ RECT crect;
+ GetClientRect(hWnd, &crect);
- /*if (video_mode.resizable) {
- AdjustWindowRect(&rect, WS_OVERLAPPEDWINDOW, FALSE);
- } else {
- AdjustWindowRect(&rect, WS_CAPTION | WS_POPUPWINDOW, FALSE);
- }*/
-
- //print_line("POST: "+itos(rect.left)+","+itos(rect.top)+","+itos(rect.right-rect.left)+","+itos(rect.bottom-rect.top));
+ w += (rect.right - rect.left) - (crect.right - crect.left);
+ h += (rect.bottom - rect.top) - (crect.bottom - crect.top);
+ }
- MoveWindow(hWnd, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, TRUE);
+ MoveWindow(hWnd, rect.left, rect.top, w, h, TRUE);
}
void OS_Windows::set_window_fullscreen(bool p_enabled) {
@@ -1451,21 +1449,18 @@ void OS_Windows::set_window_fullscreen(bool p_enabled) {
Point2 pos = get_screen_position(cs);
Size2 size = get_screen_size(cs);
- /* r.left = pos.x;
- r.top = pos.y;
- r.bottom = pos.y+size.y;
- r.right = pos.x+size.x;
-*/
- SetWindowLongPtr(hWnd, GWL_STYLE,
- WS_SYSMENU | WS_POPUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_VISIBLE);
- MoveWindow(hWnd, pos.x, pos.y, size.width, size.height, TRUE);
-
video_mode.fullscreen = true;
+ _update_window_style(false);
+
+ MoveWindow(hWnd, pos.x, pos.y, size.width, size.height, TRUE);
+
} else {
RECT rect;
+ video_mode.fullscreen = false;
+
if (pre_fs_valid) {
rect = pre_fs_rect;
} else {
@@ -1475,35 +1470,12 @@ void OS_Windows::set_window_fullscreen(bool p_enabled) {
rect.bottom = video_mode.height;
}
- if (video_mode.resizable) {
-
- SetWindowLongPtr(hWnd, GWL_STYLE, WS_OVERLAPPEDWINDOW | WS_VISIBLE);
- //AdjustWindowRect(&rect, WS_OVERLAPPEDWINDOW, FALSE);
- MoveWindow(hWnd, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, TRUE);
- } else {
+ _update_window_style(false);
- SetWindowLongPtr(hWnd, GWL_STYLE, WS_CAPTION | WS_POPUPWINDOW | WS_VISIBLE);
- //AdjustWindowRect(&rect, WS_CAPTION | WS_POPUPWINDOW, FALSE);
- MoveWindow(hWnd, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, TRUE);
- }
+ MoveWindow(hWnd, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, TRUE);
- video_mode.fullscreen = false;
pre_fs_valid = true;
- /*
- DWORD dwExStyle=WS_EX_APPWINDOW | WS_EX_WINDOWEDGE;
- DWORD dwStyle=WS_OVERLAPPEDWINDOW;
- if (!video_mode.resizable) {
- dwStyle &= ~WS_THICKFRAME;
- dwStyle &= ~WS_MAXIMIZEBOX;
- }
- AdjustWindowRectEx(&pre_fs_rect, dwStyle, FALSE, dwExStyle);
- video_mode.fullscreen=false;
- video_mode.width=pre_fs_rect.right-pre_fs_rect.left;
- video_mode.height=pre_fs_rect.bottom-pre_fs_rect.top;
-*/
}
-
- //MoveWindow(hWnd,r.left,r.top,p_size.x,p_size.y,TRUE);
}
bool OS_Windows::is_window_fullscreen() const {
@@ -1513,30 +1485,10 @@ void OS_Windows::set_window_resizable(bool p_enabled) {
if (video_mode.resizable == p_enabled)
return;
- /*
- GetWindowRect(hWnd,&pre_fs_rect);
- DWORD dwExStyle=WS_EX_APPWINDOW | WS_EX_WINDOWEDGE;
- DWORD dwStyle=WS_OVERLAPPEDWINDOW;
- if (!p_enabled) {
- dwStyle &= ~WS_THICKFRAME;
- dwStyle &= ~WS_MAXIMIZEBOX;
- }
- AdjustWindowRectEx(&pre_fs_rect, dwStyle, FALSE, dwExStyle);
- */
-
- if (!video_mode.fullscreen) {
- if (p_enabled) {
- SetWindowLongPtr(hWnd, GWL_STYLE, WS_OVERLAPPEDWINDOW | WS_VISIBLE);
- } else {
- SetWindowLongPtr(hWnd, GWL_STYLE, WS_CAPTION | WS_MINIMIZEBOX | WS_POPUPWINDOW | WS_VISIBLE);
- }
-
- RECT rect;
- GetWindowRect(hWnd, &rect);
- MoveWindow(hWnd, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, TRUE);
- }
video_mode.resizable = p_enabled;
+
+ _update_window_style();
}
bool OS_Windows::is_window_resizable() const {
@@ -1576,13 +1528,36 @@ bool OS_Windows::is_window_maximized() const {
}
void OS_Windows::set_borderless_window(int p_borderless) {
+ if (video_mode.borderless_window == p_borderless)
+ return;
+
video_mode.borderless_window = p_borderless;
+
+ _update_window_style();
}
bool OS_Windows::get_borderless_window() {
return video_mode.borderless_window;
}
+void OS_Windows::_update_window_style(bool repaint) {
+ if (video_mode.fullscreen || video_mode.borderless_window) {
+ SetWindowLongPtr(hWnd, GWL_STYLE, WS_SYSMENU | WS_POPUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_VISIBLE);
+ } else {
+ if (video_mode.resizable) {
+ SetWindowLongPtr(hWnd, GWL_STYLE, WS_OVERLAPPEDWINDOW | WS_VISIBLE);
+ } else {
+ SetWindowLongPtr(hWnd, GWL_STYLE, WS_CAPTION | WS_MINIMIZEBOX | WS_POPUPWINDOW | WS_VISIBLE);
+ }
+ }
+
+ if (repaint) {
+ RECT rect;
+ GetWindowRect(hWnd, &rect);
+ MoveWindow(hWnd, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, TRUE);
+ }
+}
+
Error OS_Windows::open_dynamic_library(const String p_path, void *&p_library_handle) {
p_library_handle = (void *)LoadLibrary(p_path.utf8().get_data());
if (!p_library_handle) {
@@ -1599,12 +1574,16 @@ Error OS_Windows::close_dynamic_library(void *p_library_handle) {
return OK;
}
-Error OS_Windows::get_dynamic_library_symbol_handle(void *p_library_handle, const String p_name, void *&p_symbol_handle) {
+Error OS_Windows::get_dynamic_library_symbol_handle(void *p_library_handle, const String p_name, void *&p_symbol_handle, bool p_optional) {
char *error;
p_symbol_handle = (void *)GetProcAddress((HMODULE)p_library_handle, p_name.utf8().get_data());
if (!p_symbol_handle) {
- ERR_EXPLAIN("Can't resolve symbol " + p_name + ". Error: " + String::num(GetLastError()));
- ERR_FAIL_V(ERR_CANT_RESOLVE);
+ if (!p_optional) {
+ ERR_EXPLAIN("Can't resolve symbol " + p_name + ". Error: " + String::num(GetLastError()));
+ ERR_FAIL_V(ERR_CANT_RESOLVE);
+ } else {
+ return ERR_CANT_RESOLVE;
+ }
}
return OK;
}
@@ -2259,7 +2238,7 @@ String OS_Windows::get_data_dir() const {
if (has_environment("APPDATA")) {
- bool use_godot = GlobalConfig::get_singleton()->get("application/use_shared_user_dir");
+ bool use_godot = ProjectSettings::get_singleton()->get("application/config/use_shared_user_dir");
if (!use_godot)
return (OS::get_singleton()->get_environment("APPDATA") + "/" + an).replace("\\", "/");
else
@@ -2267,7 +2246,7 @@ String OS_Windows::get_data_dir() const {
}
}
- return GlobalConfig::get_singleton()->get_resource_path();
+ return ProjectSettings::get_singleton()->get_resource_path();
}
bool OS_Windows::is_joy_known(int p_device) {
@@ -2304,9 +2283,9 @@ int OS_Windows::get_power_percent_left() {
return power_manager->get_power_percent_left();
}
-bool OS_Windows::check_feature_support(const String &p_feature) {
+bool OS_Windows::_check_internal_feature_support(const String &p_feature) {
- return VisualServer::get_singleton()->has_os_feature(p_feature);
+ return p_feature == "pc" || p_feature == "s3tc";
}
OS_Windows::OS_Windows(HINSTANCE _hInstance) {
diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h
index 6cbdd58830..6856e7e9b8 100644
--- a/platform/windows/os_windows.h
+++ b/platform/windows/os_windows.h
@@ -133,6 +133,8 @@ class OS_Windows : public OS {
void _drag_event(int p_x, int p_y, int idx);
void _touch_event(bool p_pressed, int p_x, int p_y, int idx);
+ void _update_window_style(bool repaint = true);
+
// functions used by main to initialize/deintialize the OS
protected:
virtual int get_video_driver_count() const;
@@ -225,7 +227,7 @@ public:
virtual Error open_dynamic_library(const String p_path, void *&p_library_handle);
virtual Error close_dynamic_library(void *p_library_handle);
- virtual Error get_dynamic_library_symbol_handle(void *p_library_handle, const String p_name, void *&p_symbol_handle);
+ virtual Error get_dynamic_library_symbol_handle(void *p_library_handle, const String p_name, void *&p_symbol_handle, bool p_optional = false);
virtual MainLoop *get_main_loop() const;
@@ -286,7 +288,7 @@ public:
virtual int get_power_seconds_left();
virtual int get_power_percent_left();
- virtual bool check_feature_support(const String &p_feature);
+ virtual bool _check_internal_feature_support(const String &p_feature);
OS_Windows(HINSTANCE _hInstance);
~OS_Windows();
diff --git a/platform/x11/detect.py b/platform/x11/detect.py
index 0ba0f68393..79778136ad 100644
--- a/platform/x11/detect.py
+++ b/platform/x11/detect.py
@@ -1,7 +1,6 @@
-
import os
-import sys
import platform
+import sys
def is_active():
@@ -14,15 +13,12 @@ def get_name():
def can_build():
- if (os.name != "posix"):
+ if (os.name != "posix" or sys.platform == "darwin"):
return False
- if sys.platform == "darwin":
- return False # no x11 on mac for now
-
- errorval = os.system("pkg-config --version > /dev/null")
-
- if (errorval):
+ # Check the minimal dependencies
+ x11_error = os.system("pkg-config --version > /dev/null")
+ if (x11_error):
print("pkg-config not found.. x11 disabled.")
return False
@@ -31,11 +27,6 @@ def can_build():
print("X11 not found.. x11 disabled.")
return False
- ssl_error = os.system("pkg-config openssl --modversion > /dev/null ")
- if (ssl_error):
- print("OpenSSL not found.. x11 disabled.")
- return False
-
x11_error = os.system("pkg-config xcursor --modversion > /dev/null ")
if (x11_error):
print("xcursor not found.. x11 disabled.")
@@ -51,18 +42,18 @@ def can_build():
print("xrandr not found.. x11 disabled.")
return False
- return True # X11 enabled
+ return True
def get_opts():
return [
- ('use_llvm', 'Use llvm compiler', 'no'),
- ('use_static_cpp', 'link stdc++ statically', 'no'),
- ('use_sanitizer', 'Use llvm compiler sanitize address', 'no'),
- ('use_leak_sanitizer', 'Use llvm compiler sanitize memory leaks', 'no'),
+ ('use_llvm', 'Use the LLVM compiler', 'no'),
+ ('use_static_cpp', 'Link stdc++ statically', 'no'),
+ ('use_sanitizer', 'Use LLVM compiler address sanitizer', 'no'),
+ ('use_leak_sanitizer', 'Use LLVM compiler memory leaks sanitizer (implies use_sanitizer)', 'no'),
('use_lto', 'Use link time optimization', 'no'),
- ('pulseaudio', 'Detect & Use pulseaudio', 'yes'),
+ ('pulseaudio', 'Detect & use pulseaudio', 'yes'),
('udev', 'Use udev for gamepad connection callbacks', 'no'),
('debug_release', 'Add debug symbols to release version', 'no'),
]
@@ -80,66 +71,62 @@ def get_flags():
def configure(env):
- is64 = sys.maxsize > 2**32
+ ## Build type
+
+ if (env["target"] == "release"):
+ env.Prepend(CCFLAGS=['-Ofast'])
+ if (env["debug_release"] == "yes"):
+ env.Prepend(CCFLAGS=['-g2'])
+
+ elif (env["target"] == "release_debug"):
+ env.Prepend(CCFLAGS=['-O2', '-ffast-math', '-DDEBUG_ENABLED'])
+ if (env["debug_release"] == "yes"):
+ env.Prepend(CCFLAGS=['-g2'])
+
+ elif (env["target"] == "debug"):
+ env.Prepend(CCFLAGS=['-g2', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED'])
+
+ ## Architecture
+ is64 = sys.maxsize > 2**32
if (env["bits"] == "default"):
- if (is64):
- env["bits"] = "64"
- else:
- env["bits"] = "32"
+ env["bits"] = "64" if is64 else "32"
+
+ ## Compiler configuration
- env.Append(CPPPATH=['#platform/x11'])
if (env["use_llvm"] == "yes"):
- if 'clang++' not in env['CXX']:
+ if ('clang++' not in env['CXX']):
env["CC"] = "clang"
env["CXX"] = "clang++"
env["LD"] = "clang++"
env.Append(CPPFLAGS=['-DTYPED_METHOD_BIND'])
- env.extra_suffix = ".llvm"
-
- if (env["use_sanitizer"] == "yes"):
- env.Append(CCFLAGS=['-fsanitize=address', '-fno-omit-frame-pointer'])
- env.Append(LINKFLAGS=['-fsanitize=address'])
- env.extra_suffix += "s"
+ env.extra_suffix = ".llvm" + env.extra_suffix
- if (env["use_leak_sanitizer"] == "yes"):
+ # leak sanitizer requires (address) sanitizer
+ if (env["use_sanitizer"] == "yes" or env["use_leak_sanitizer"] == "yes"):
env.Append(CCFLAGS=['-fsanitize=address', '-fno-omit-frame-pointer'])
env.Append(LINKFLAGS=['-fsanitize=address'])
env.extra_suffix += "s"
-
- # if (env["tools"]=="no"):
- # #no tools suffix
- # env['OBJSUFFIX'] = ".nt"+env['OBJSUFFIX']
- # env['LIBSUFFIX'] = ".nt"+env['LIBSUFFIX']
+ if (env["use_leak_sanitizer"] == "yes"):
+ env.Append(CCFLAGS=['-fsanitize=leak'])
+ env.Append(LINKFLAGS=['-fsanitize=leak'])
if (env["use_lto"] == "yes"):
env.Append(CCFLAGS=['-flto'])
env.Append(LINKFLAGS=['-flto'])
-
env.Append(CCFLAGS=['-pipe'])
env.Append(LINKFLAGS=['-pipe'])
- if (env["target"] == "release"):
- env.Prepend(CCFLAGS=['-Ofast'])
- if (env["debug_release"] == "yes"):
- env.Prepend(CCFLAGS=['-g2'])
-
- elif (env["target"] == "release_debug"):
-
- env.Prepend(CCFLAGS=['-O2', '-ffast-math', '-DDEBUG_ENABLED'])
- if (env["debug_release"] == "yes"):
- env.Prepend(CCFLAGS=['-g2'])
-
- elif (env["target"] == "debug"):
-
- env.Prepend(CCFLAGS=['-g2', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED'])
+ ## Dependencies
env.ParseConfig('pkg-config x11 --cflags --libs')
- env.ParseConfig('pkg-config xinerama --cflags --libs')
env.ParseConfig('pkg-config xcursor --cflags --libs')
+ env.ParseConfig('pkg-config xinerama --cflags --libs')
env.ParseConfig('pkg-config xrandr --cflags --libs')
+ # FIXME: Check for existence of the libs before parsing their flags with pkg-config
+
if (env['builtin_openssl'] == 'no'):
# Currently not compatible with OpenSSL 1.1.0+
# https://github.com/godotengine/godot/issues/8624
@@ -196,47 +183,51 @@ def configure(env):
if (env['builtin_libogg'] == 'no'):
env.ParseConfig('pkg-config ogg --cflags --libs')
- env.Append(CPPFLAGS=['-DOPENGL_ENABLED'])
+ if (env['builtin_libtheora'] != 'no'):
+ list_of_x86 = ['x86_64', 'x86', 'i386', 'i586']
+ if any(platform.machine() in s for s in list_of_x86):
+ env["x86_libtheora_opt_gcc"] = True
+
+ ## Flags
- if os.system("pkg-config --exists alsa") == 0:
+ if (os.system("pkg-config --exists alsa") == 0): # 0 means found
print("Enabling ALSA")
env.Append(CPPFLAGS=["-DALSA_ENABLED"])
env.ParseConfig('pkg-config alsa --cflags --libs')
else:
print("ALSA libraries not found, disabling driver")
- if (platform.system() == "Linux"):
- env.Append(CPPFLAGS=["-DJOYDEV_ENABLED"])
- if (env["udev"] == "yes"):
- # pkg-config returns 0 when the lib exists...
- found_udev = not os.system("pkg-config --exists libudev")
-
- if (found_udev):
- print("Enabling udev support")
- env.Append(CPPFLAGS=["-DUDEV_ENABLED"])
- env.ParseConfig('pkg-config libudev --cflags --libs')
- else:
- print("libudev development libraries not found, disabling udev support")
-
if (env["pulseaudio"] == "yes"):
- if not os.system("pkg-config --exists libpulse-simple"):
+ if (os.system("pkg-config --exists libpulse-simple") == 0): # 0 means found
print("Enabling PulseAudio")
env.Append(CPPFLAGS=["-DPULSEAUDIO_ENABLED"])
env.ParseConfig('pkg-config --cflags --libs libpulse-simple')
else:
print("PulseAudio development libraries not found, disabling driver")
+ if (platform.system() == "Linux"):
+ env.Append(CPPFLAGS=["-DJOYDEV_ENABLED"])
+
+ if (env["udev"] == "yes"):
+ if (os.system("pkg-config --exists libudev") == 0): # 0 means found
+ print("Enabling udev support")
+ env.Append(CPPFLAGS=["-DUDEV_ENABLED"])
+ env.ParseConfig('pkg-config libudev --cflags --libs')
+ else:
+ print("libudev development libraries not found, disabling udev support")
+
+ # Linkflags below this line should typically stay the last ones
if (env['builtin_zlib'] == 'no'):
env.ParseConfig('pkg-config zlib --cflags --libs')
- env.Append(CPPFLAGS=['-DX11_ENABLED', '-DUNIX_ENABLED', '-DGLES2_ENABLED', '-DGLES_OVER_GL'])
+ env.Append(CPPPATH=['#platform/x11'])
+ env.Append(CPPFLAGS=['-DX11_ENABLED', '-DUNIX_ENABLED', '-DOPENGL_ENABLED', '-DGLES2_ENABLED', '-DGLES_OVER_GL'])
env.Append(LIBS=['GL', 'pthread'])
if (platform.system() == "Linux"):
env.Append(LIBS=['dl'])
- # env.Append(CPPFLAGS=['-DMPC_FIXED_POINT'])
- # host compiler is default..
+ ## Cross-compilation
if (is64 and env["bits"] == "32"):
env.Append(CPPFLAGS=['-m32'])
@@ -245,17 +236,5 @@ def configure(env):
env.Append(CPPFLAGS=['-m64'])
env.Append(LINKFLAGS=['-m64', '-L/usr/lib/i686-linux-gnu'])
- import methods
-
- # FIXME: Commented out when moving to gles3
- #env.Append(BUILDERS={'GLSL120': env.Builder(action=methods.build_legacygl_headers, suffix='glsl.h', src_suffix='.glsl')})
- #env.Append(BUILDERS={'GLSL': env.Builder(action=methods.build_glsl_headers, suffix='glsl.h', src_suffix='.glsl')})
- #env.Append(BUILDERS={'GLSL120GLES': env.Builder(action=methods.build_gles2_headers, suffix='glsl.h', src_suffix='.glsl')})
- #env.Append( BUILDERS = { 'HLSL9' : env.Builder(action = methods.build_hlsl_dx9_headers, suffix = 'hlsl.h',src_suffix = '.hlsl') } )
-
if (env["use_static_cpp"] == "yes"):
env.Append(LINKFLAGS=['-static-libstdc++'])
-
- list_of_x86 = ['x86_64', 'x86', 'i386', 'i586']
- if any(platform.machine() in s for s in list_of_x86):
- env["x86_libtheora_opt_gcc"] = True
diff --git a/platform/x11/export/export.cpp b/platform/x11/export/export.cpp
index 69784a473d..c8d6220aed 100644
--- a/platform/x11/export/export.cpp
+++ b/platform/x11/export/export.cpp
@@ -48,6 +48,7 @@ void register_x11_exporter() {
platform->set_debug_32("linux_x11_32_debug");
platform->set_release_64("linux_x11_64_release");
platform->set_debug_64("linux_x11_64_debug");
+ platform->set_os_name("X11");
EditorExport::get_singleton()->add_export_platform(platform);
diff --git a/platform/x11/godot_x11.cpp b/platform/x11/godot_x11.cpp
index b293b1bebb..6f418b213f 100644
--- a/platform/x11/godot_x11.cpp
+++ b/platform/x11/godot_x11.cpp
@@ -28,6 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include <limits.h>
+#include <locale.h>
#include <stdlib.h>
#include <unistd.h>
@@ -38,6 +39,8 @@ int main(int argc, char *argv[]) {
OS_X11 os;
+ setlocale(LC_CTYPE, "");
+
char *cwd = (char *)malloc(PATH_MAX);
getcwd(cwd, PATH_MAX);
diff --git a/platform/x11/key_mapping_x11.cpp b/platform/x11/key_mapping_x11.cpp
index 362fc3618a..1d7eb1692c 100644
--- a/platform/x11/key_mapping_x11.cpp
+++ b/platform/x11/key_mapping_x11.cpp
@@ -94,7 +94,6 @@ static _XTranslatePair _xkeysym_to_keycode[] = {
//{ XK_KP_Separator, KEY_COMMA },
{ XK_KP_Decimal, KEY_KP_PERIOD },
{ XK_KP_Delete, KEY_KP_PERIOD },
- { XK_KP_Enter, KEY_KP_ENTER },
{ XK_KP_Multiply, KEY_KP_MULTIPLY },
{ XK_KP_Divide, KEY_KP_DIVIDE },
{ XK_KP_Subtract, KEY_KP_SUBTRACT },
diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp
index 2eebc96d2c..1dde328eda 100644
--- a/platform/x11/os_x11.cpp
+++ b/platform/x11/os_x11.cpp
@@ -68,6 +68,8 @@
#undef CursorShape
+#include <X11/XKBlib.h>
+
int OS_X11::get_video_driver_count() const {
return 1;
}
@@ -93,6 +95,7 @@ const char *OS_X11::get_audio_driver_name(int p_driver) const {
void OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) {
+ long im_event_mask = 0;
last_button_state = 0;
xmbstring = NULL;
@@ -113,7 +116,32 @@ void OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_au
/** XLIB INITIALIZATION **/
x11_display = XOpenDisplay(NULL);
- char *modifiers = XSetLocaleModifiers("@im=none");
+ Bool xkb_dar = False;
+ if (x11_display) {
+ XAutoRepeatOn(x11_display);
+ xkb_dar = XkbSetDetectableAutoRepeat(x11_display, True, NULL);
+ }
+
+ char *modifiers = NULL;
+
+ // Try to support IME if detectable auto-repeat is supported
+
+ if (xkb_dar == True) {
+
+// Xutf8LookupString will be used later instead of XmbLookupString before
+// the multibyte sequences can be converted to unicode string.
+
+#ifdef X_HAVE_UTF8_STRING
+ modifiers = XSetLocaleModifiers("");
+#endif
+ }
+
+ if (modifiers == NULL) {
+ if (is_stdout_verbose()) {
+ WARN_PRINT("IME is disabled");
+ }
+ modifiers = XSetLocaleModifiers("@im=none");
+ }
if (modifiers == NULL) {
WARN_PRINT("Error setting locale modifiers");
}
@@ -153,6 +181,14 @@ void OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_au
WARN_PRINT("XOpenIM failed");
xim_style = 0L;
} else {
+ ::XIMCallback im_destroy_callback;
+ im_destroy_callback.client_data = (::XPointer)(this);
+ im_destroy_callback.callback = (::XIMProc)(xim_destroy_callback);
+ if (XSetIMValues(xim, XNDestroyCallback, &im_destroy_callback,
+ NULL) != NULL) {
+ WARN_PRINT("Error setting XIM destroy callback");
+ }
+
::XIMStyles *xim_styles = NULL;
xim_style = 0L;
char *imvalret = NULL;
@@ -242,6 +278,13 @@ void OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_au
xev.xclient.data.l[2] = 0;
XSendEvent(x11_display, DefaultRootWindow(x11_display), False, SubstructureNotifyMask, &xev);
+ } else if (current_videomode.borderless_window) {
+ Hints hints;
+ Atom property;
+ hints.flags = 2;
+ hints.decorations = 0;
+ property = XInternAtom(x11_display, "_MOTIF_WM_HINTS", True);
+ XChangeProperty(x11_display, x11_window, property, property, 32, PropModeReplace, (unsigned char *)&hints, 5);
}
// disable resizable window
@@ -303,7 +346,8 @@ void OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_au
StructureNotifyMask |
SubstructureNotifyMask | SubstructureRedirectMask |
FocusChangeMask | PropertyChangeMask |
- ColormapChangeMask | OwnerGrabButtonMask;
+ ColormapChangeMask | OwnerGrabButtonMask |
+ im_event_mask;
XChangeWindowAttributes(x11_display, x11_window, CWEventMask, &new_attr);
@@ -327,6 +371,16 @@ void OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_au
if (xim && xim_style) {
xic = XCreateIC(xim, XNInputStyle, xim_style, XNClientWindow, x11_window, XNFocusWindow, x11_window, (char *)NULL);
+ if (XGetICValues(xic, XNFilterEvents, &im_event_mask, NULL) != NULL) {
+ WARN_PRINT("XGetICValues couldn't obtain XNFilterEvents value");
+ XDestroyIC(xic);
+ xic = NULL;
+ }
+ if (xic) {
+ XSetICFocus(xic);
+ } else {
+ WARN_PRINT("XCreateIC couldn't create xic");
+ }
} else {
xic = NULL;
@@ -443,6 +497,30 @@ void OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_au
joypad = memnew(JoypadLinux(input));
#endif
_ensure_data_dir();
+
+ power_manager = memnew(PowerX11);
+}
+
+void OS_X11::xim_destroy_callback(::XIM im, ::XPointer client_data,
+ ::XPointer call_data) {
+
+ WARN_PRINT("Input method stopped");
+ OS_X11 *os = reinterpret_cast<OS_X11 *>(client_data);
+ os->xim = NULL;
+ os->xic = NULL;
+}
+
+void OS_X11::set_ime_position(const Point2 &p_pos) {
+
+ if (!xic)
+ return;
+
+ ::XPoint spot;
+ spot.x = short(p_pos.x);
+ spot.y = short(p_pos.y);
+ XVaNestedList preedit_attr = XVaCreateNestedList(0, XNSpotLocation, &spot, NULL);
+ XSetICValues(xic, XNPreeditAttributes, preedit_attr, NULL);
+ XFree(preedit_attr);
}
void OS_X11::finalize() {
@@ -492,8 +570,12 @@ void OS_X11::finalize() {
XcursorImageDestroy(img[i]);
};
- XDestroyIC(xic);
- XCloseIM(xim);
+ if (xic) {
+ XDestroyIC(xic);
+ }
+ if (xim) {
+ XCloseIM(xim);
+ }
XCloseDisplay(x11_display);
if (xmbstring)
@@ -606,6 +688,16 @@ void OS_X11::get_fullscreen_mode_list(List<VideoMode> *p_list, int p_screen) con
}
void OS_X11::set_wm_fullscreen(bool p_enabled) {
+ if (p_enabled && !is_window_resizable()) {
+ // Set the window as resizable to prevent window managers to ignore the fullscreen state flag.
+ XSizeHints *xsh;
+
+ xsh = XAllocSizeHints();
+ xsh->flags = 0L;
+ XSetWMNormalHints(x11_display, x11_window, xsh);
+ XFree(xsh);
+ }
+
// Using EWMH -- Extened Window Manager Hints
XEvent xev;
Atom wm_state = XInternAtom(x11_display, "_NET_WM_STATE", False);
@@ -621,6 +713,23 @@ void OS_X11::set_wm_fullscreen(bool p_enabled) {
xev.xclient.data.l[2] = 0;
XSendEvent(x11_display, DefaultRootWindow(x11_display), False, SubstructureRedirectMask | SubstructureNotifyMask, &xev);
+ XFlush(x11_display);
+
+ if (!p_enabled && !is_window_resizable()) {
+ // Reset the non-resizable flags if we un-set these before.
+ Size2 size = get_window_size();
+ XSizeHints *xsh;
+
+ xsh = XAllocSizeHints();
+ xsh->flags = PMinSize | PMaxSize;
+ xsh->min_width = size.x;
+ xsh->max_width = size.x;
+ xsh->min_height = size.y;
+ xsh->max_height = size.y;
+
+ XSetWMNormalHints(x11_display, x11_window, xsh);
+ XFree(xsh);
+ }
}
int OS_X11::get_screen_count() const {
@@ -940,6 +1049,25 @@ bool OS_X11::is_window_maximized() const {
return false;
}
+void OS_X11::set_borderless_window(int p_borderless) {
+
+ if (current_videomode.borderless_window == p_borderless)
+ return;
+
+ current_videomode.borderless_window = p_borderless;
+
+ Hints hints;
+ Atom property;
+ hints.flags = 2;
+ hints.decorations = current_videomode.borderless_window ? 0 : 1;
+ property = XInternAtom(x11_display, "_MOTIF_WM_HINTS", True);
+ XChangeProperty(x11_display, x11_window, property, property, 32, PropModeReplace, (unsigned char *)&hints, 5);
+}
+
+bool OS_X11::get_borderless_window() {
+ return current_videomode.borderless_window;
+}
+
void OS_X11::request_attention() {
// Using EWMH -- Extended Window Manager Hints
//
@@ -1041,9 +1169,61 @@ void OS_X11::handle_key_event(XKeyEvent *p_event, bool p_echo) {
xmblen = 8;
}
+ keysym_unicode = keysym_keycode;
+
if (xkeyevent->type == KeyPress && xic) {
Status status;
+#ifdef X_HAVE_UTF8_STRING
+ int utf8len = 8;
+ char *utf8string = (char *)memalloc(sizeof(char) * utf8len);
+ int utf8bytes = Xutf8LookupString(xic, xkeyevent, utf8string,
+ utf8len - 1, &keysym_unicode, &status);
+ if (status == XBufferOverflow) {
+ utf8len = utf8bytes + 1;
+ utf8string = (char *)memrealloc(utf8string, utf8len);
+ utf8bytes = Xutf8LookupString(xic, xkeyevent, utf8string,
+ utf8len - 1, &keysym_unicode, &status);
+ }
+ utf8string[utf8bytes] = '\0';
+
+ if (status == XLookupChars) {
+ bool keypress = xkeyevent->type == KeyPress;
+ unsigned int keycode = KeyMappingX11::get_keycode(keysym_keycode);
+ if (keycode >= 'a' && keycode <= 'z')
+ keycode -= 'a' - 'A';
+
+ String tmp;
+ tmp.parse_utf8(utf8string, utf8bytes);
+ for (int i = 0; i < tmp.length(); i++) {
+ Ref<InputEventKey> k;
+ k.instance();
+ if (keycode == 0 && tmp[i] == 0) {
+ continue;
+ }
+
+ get_key_modifier_state(xkeyevent->state, k);
+
+ k->set_unicode(tmp[i]);
+
+ k->set_pressed(keypress);
+
+ k->set_scancode(keycode);
+
+ k->set_echo(false);
+
+ if (k->get_scancode() == KEY_BACKTAB) {
+ //make it consistent across platforms.
+ k->set_scancode(KEY_TAB);
+ k->set_shift(true);
+ }
+
+ input->parse_input_event(k);
+ }
+ return;
+ }
+ memfree(utf8string);
+#else
do {
int mnbytes = XmbLookupString(xic, xkeyevent, xmbstring, xmblen - 1, &keysym_unicode, &status);
@@ -1054,6 +1234,7 @@ void OS_X11::handle_key_event(XKeyEvent *p_event, bool p_echo) {
xmbstring = (char *)memrealloc(xmbstring, xmblen);
}
} while (status == XBufferOverflow);
+#endif
}
/* Phase 2, obtain a pigui keycode from the keysym */
@@ -1082,11 +1263,6 @@ void OS_X11::handle_key_event(XKeyEvent *p_event, bool p_echo) {
bool keypress = xkeyevent->type == KeyPress;
- if (xkeyevent->type == KeyPress && xic) {
- if (XFilterEvent((XEvent *)xkeyevent, x11_window))
- return;
- }
-
if (keycode == 0 && unicode == 0)
return;
@@ -1108,17 +1284,19 @@ void OS_X11::handle_key_event(XKeyEvent *p_event, bool p_echo) {
// Echo characters in X11 are a keyrelease and a keypress
// one after the other with the (almot) same timestamp.
// To detect them, i use XPeekEvent and check that their
- // difference in time is below a treshold.
+ // difference in time is below a threshold.
if (xkeyevent->type != KeyPress) {
+ p_echo = false;
+
// make sure there are events pending,
// so this call won't block.
if (XPending(x11_display) > 0) {
XEvent peek_event;
XPeekEvent(x11_display, &peek_event);
- // I'm using a treshold of 5 msecs,
+ // I'm using a threshold of 5 msecs,
// since sometimes there seems to be a little
// jitter. I'm still not convinced that all this approach
// is correct, but the xorg developers are
@@ -1172,6 +1350,18 @@ void OS_X11::handle_key_event(XKeyEvent *p_event, bool p_echo) {
k->set_metakey(false);
}
+ bool last_is_pressed = Input::get_singleton()->is_key_pressed(k->get_scancode());
+ if (k->is_pressed()) {
+ if (last_is_pressed) {
+ k->set_echo(true);
+ }
+ } else {
+ //ignore
+ if (last_is_pressed == false) {
+ return;
+ }
+ }
+
//printf("key: %x\n",k->get_scancode());
input->parse_input_event(k);
}
@@ -1253,6 +1443,10 @@ void OS_X11::process_xevents() {
XEvent event;
XNextEvent(x11_display, &event);
+ if (XFilterEvent(&event, None)) {
+ continue;
+ }
+
switch (event.type) {
case Expose:
Main::force_redraw();
@@ -1295,6 +1489,9 @@ void OS_X11::process_xevents() {
ButtonPressMask | ButtonReleaseMask | PointerMotionMask,
GrabModeAsync, GrabModeAsync, x11_window, None, CurrentTime);
}
+ if (xic) {
+ XSetICFocus(xic);
+ }
break;
case FocusOut:
@@ -1308,9 +1505,16 @@ void OS_X11::process_xevents() {
}
XUngrabPointer(x11_display, CurrentTime);
}
+ if (xic) {
+ XUnsetICFocus(xic);
+ }
break;
case ConfigureNotify:
+ if (xic) {
+ // Not portable.
+ set_ime_position(Point2(0, 1));
+ }
/* call resizeGLScene only if our window-size changed */
if ((event.xconfigure.width == current_videomode.width) &&
@@ -1656,7 +1860,7 @@ void OS_X11::set_clipboard(const String &p_text) {
XSetSelectionOwner(x11_display, XInternAtom(x11_display, "CLIPBOARD", 0), x11_window, CurrentTime);
};
-static String _get_clipboard(Atom p_source, Window x11_window, ::Display *x11_display, String p_internal_clipboard) {
+static String _get_clipboard_impl(Atom p_source, Window x11_window, ::Display *x11_display, String p_internal_clipboard, Atom target) {
String ret;
@@ -1673,7 +1877,7 @@ static String _get_clipboard(Atom p_source, Window x11_window, ::Display *x11_di
};
if (Sown != None) {
- XConvertSelection(x11_display, p_source, XA_STRING, selection,
+ XConvertSelection(x11_display, p_source, target, selection,
x11_window, CurrentTime);
XFlush(x11_display);
while (true) {
@@ -1713,6 +1917,18 @@ static String _get_clipboard(Atom p_source, Window x11_window, ::Display *x11_di
return ret;
}
+static String _get_clipboard(Atom p_source, Window x11_window, ::Display *x11_display, String p_internal_clipboard) {
+ String ret;
+ Atom utf8_atom = XInternAtom(x11_display, "UTF8_STRING", True);
+ if (utf8_atom != None) {
+ ret = _get_clipboard_impl(p_source, x11_window, x11_display, p_internal_clipboard, utf8_atom);
+ }
+ if (ret == "") {
+ ret = _get_clipboard_impl(p_source, x11_window, x11_display, p_internal_clipboard, XA_STRING);
+ }
+ return ret;
+}
+
String OS_X11::get_clipboard() const {
String ret;
@@ -1745,6 +1961,11 @@ Error OS_X11::shell_open(String p_uri) {
return ok;
}
+bool OS_X11::_check_internal_feature_support(const String &p_feature) {
+
+ return p_feature == "pc" || p_feature == "s3tc";
+}
+
String OS_X11::get_system_dir(SystemDir p_dir) const {
String xdgparam;
diff --git a/platform/x11/os_x11.h b/platform/x11/os_x11.h
index d62186e5bd..db70f8f84a 100644
--- a/platform/x11/os_x11.h
+++ b/platform/x11/os_x11.h
@@ -113,6 +113,9 @@ class OS_X11 : public OS_Unix {
::XIC xic;
::XIM xim;
::XIMStyle xim_style;
+ static void xim_destroy_callback(::XIM im, ::XPointer client_data,
+ ::XPointer call_data);
+
Point2i last_mouse_pos;
bool last_mouse_pos_valid;
Point2i last_click_pos;
@@ -247,6 +250,10 @@ public:
virtual bool is_window_maximized() const;
virtual void request_attention();
+ virtual void set_borderless_window(int p_borderless);
+ virtual bool get_borderless_window();
+ virtual void set_ime_position(const Point2 &p_pos);
+
virtual void move_window_to_foreground();
virtual void alert(const String &p_alert, const String &p_title = "ALERT!");
@@ -262,6 +269,8 @@ public:
virtual int get_power_seconds_left();
virtual int get_power_percent_left();
+ virtual bool _check_internal_feature_support(const String &p_feature);
+
void run();
OS_X11();
diff --git a/platform/x11/power_x11.cpp b/platform/x11/power_x11.cpp
index 093d24f406..8e69a2223f 100644
--- a/platform/x11/power_x11.cpp
+++ b/platform/x11/power_x11.cpp
@@ -171,25 +171,18 @@ void PowerX11::check_proc_acpi_battery(const char *node, bool *have_battery, boo
charge = true;
}
} else if (String(key) == "remaining capacity") {
- char *endptr = NULL;
- //const int cvt = (int) strtol(val, &endptr, 10);
String sval = val;
const int cvt = sval.to_int();
- if (*endptr == ' ') {
- remaining = cvt;
- }
+ remaining = cvt;
}
}
ptr = &info[0];
while (make_proc_acpi_key_val(&ptr, &key, &val)) {
if (String(key) == "design capacity") {
- char *endptr = NULL;
String sval = val;
const int cvt = sval.to_int();
- if (*endptr == ' ') {
- maximum = cvt;
- }
+ maximum = cvt;
}
}
diff --git a/scene/2d/animated_sprite.cpp b/scene/2d/animated_sprite.cpp
index a1ab51b3c8..22649cedd7 100644
--- a/scene/2d/animated_sprite.cpp
+++ b/scene/2d/animated_sprite.cpp
@@ -223,10 +223,10 @@ void SpriteFrames::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_animation_loop", "anim", "loop"), &SpriteFrames::set_animation_loop);
ClassDB::bind_method(D_METHOD("get_animation_loop", "anim"), &SpriteFrames::get_animation_loop);
- ClassDB::bind_method(D_METHOD("add_frame", "anim", "frame", "atpos"), &SpriteFrames::add_frame, DEFVAL(-1));
+ ClassDB::bind_method(D_METHOD("add_frame", "anim", "frame:Texture", "atpos"), &SpriteFrames::add_frame, DEFVAL(-1));
ClassDB::bind_method(D_METHOD("get_frame_count", "anim"), &SpriteFrames::get_frame_count);
- ClassDB::bind_method(D_METHOD("get_frame", "anim", "idx"), &SpriteFrames::get_frame);
- ClassDB::bind_method(D_METHOD("set_frame", "anim", "idx", "txt"), &SpriteFrames::set_frame);
+ ClassDB::bind_method(D_METHOD("get_frame:Texture", "anim", "idx"), &SpriteFrames::get_frame);
+ ClassDB::bind_method(D_METHOD("set_frame", "anim", "idx", "txt:Texture"), &SpriteFrames::set_frame);
ClassDB::bind_method(D_METHOD("remove_frame", "anim", "idx"), &SpriteFrames::remove_frame);
ClassDB::bind_method(D_METHOD("clear", "anim"), &SpriteFrames::clear);
ClassDB::bind_method(D_METHOD("clear_all"), &SpriteFrames::clear_all);
diff --git a/scene/2d/area_2d.cpp b/scene/2d/area_2d.cpp
index db22a38cec..841e2ef7d3 100644
--- a/scene/2d/area_2d.cpp
+++ b/scene/2d/area_2d.cpp
@@ -331,7 +331,10 @@ void Area2D::_clear_monitoring() {
Object *obj = ObjectDB::get_instance(E->key());
Node *node = obj ? obj->cast_to<Node>() : NULL;
- ERR_CONTINUE(!node);
+
+ if (!node) //node may have been deleted in previous frame or at other legiminate point
+ continue;
+ //ERR_CONTINUE(!node);
node->disconnect(SceneStringNames::get_singleton()->tree_entered, this, SceneStringNames::get_singleton()->_body_enter_tree);
node->disconnect(SceneStringNames::get_singleton()->tree_exited, this, SceneStringNames::get_singleton()->_body_exit_tree);
@@ -359,7 +362,7 @@ void Area2D::_clear_monitoring() {
Object *obj = ObjectDB::get_instance(E->key());
Node *node = obj ? obj->cast_to<Node>() : NULL;
- if (!node) //node may have been deleted in previous frame, this should not be an error
+ if (!node) //node may have been deleted in previous frame or at other legiminate point
continue;
//ERR_CONTINUE(!node);
diff --git a/scene/2d/canvas_item.cpp b/scene/2d/canvas_item.cpp
index 4a80aba355..40c25c8bf6 100644
--- a/scene/2d/canvas_item.cpp
+++ b/scene/2d/canvas_item.cpp
@@ -609,6 +609,27 @@ void CanvasItem::draw_line(const Point2 &p_from, const Point2 &p_to, const Color
VisualServer::get_singleton()->canvas_item_add_line(canvas_item, p_from, p_to, p_color, p_width, p_antialiased);
}
+void CanvasItem::draw_polyline(const Vector<Point2> &p_points, const Color &p_color, float p_width, bool p_antialiased) {
+
+ if (!drawing) {
+ ERR_EXPLAIN("Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.");
+ ERR_FAIL();
+ }
+
+ Vector<Color> colors;
+ colors.push_back(p_color);
+ VisualServer::get_singleton()->canvas_item_add_polyline(canvas_item, p_points, colors, p_width, p_antialiased);
+}
+
+void CanvasItem::draw_polyline_colors(const Vector<Point2> &p_points, const Vector<Color> &p_colors, float p_width, bool p_antialiased) {
+
+ if (!drawing) {
+ ERR_EXPLAIN("Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.");
+ ERR_FAIL();
+ }
+
+ VisualServer::get_singleton()->canvas_item_add_polyline(canvas_item, p_points, p_colors, p_width, p_antialiased);
+}
void CanvasItem::draw_rect(const Rect2 &p_rect, const Color &p_color, bool p_filled) {
if (!drawing) {
@@ -928,7 +949,7 @@ void CanvasItem::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_canvas_item"), &CanvasItem::get_canvas_item);
- ClassDB::bind_method(D_METHOD("set_visible"), &CanvasItem::set_visible);
+ ClassDB::bind_method(D_METHOD("set_visible", "visible"), &CanvasItem::set_visible);
ClassDB::bind_method(D_METHOD("is_visible"), &CanvasItem::is_visible);
ClassDB::bind_method(D_METHOD("is_visible_in_tree"), &CanvasItem::is_visible_in_tree);
ClassDB::bind_method(D_METHOD("show"), &CanvasItem::show);
@@ -955,6 +976,8 @@ void CanvasItem::_bind_methods() {
//ClassDB::bind_method(D_METHOD("get_transform"),&CanvasItem::get_transform);
ClassDB::bind_method(D_METHOD("draw_line", "from", "to", "color", "width", "antialiased"), &CanvasItem::draw_line, DEFVAL(1.0), DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("draw_polyline", "points", "color", "width", "antialiased"), &CanvasItem::draw_polyline, DEFVAL(1.0), DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("draw_polyline_colors", "points", "colors", "width", "antialiased"), &CanvasItem::draw_polyline_colors, DEFVAL(1.0), DEFVAL(false));
ClassDB::bind_method(D_METHOD("draw_rect", "rect", "color", "filled"), &CanvasItem::draw_rect, DEFVAL(true));
ClassDB::bind_method(D_METHOD("draw_circle", "pos", "radius", "color"), &CanvasItem::draw_circle);
ClassDB::bind_method(D_METHOD("draw_texture", "texture:Texture", "pos", "modulate", "normal_map:Texture"), &CanvasItem::draw_texture, DEFVAL(Color(1, 1, 1, 1)), DEFVAL(Variant()));
@@ -978,7 +1001,7 @@ void CanvasItem::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_local_mouse_pos"), &CanvasItem::get_local_mouse_pos);
ClassDB::bind_method(D_METHOD("get_global_mouse_position"), &CanvasItem::get_global_mouse_position);
ClassDB::bind_method(D_METHOD("get_canvas"), &CanvasItem::get_canvas);
- ClassDB::bind_method(D_METHOD("get_world_2d"), &CanvasItem::get_world_2d);
+ ClassDB::bind_method(D_METHOD("get_world_2d:World2D"), &CanvasItem::get_world_2d);
//ClassDB::bind_method(D_METHOD("get_viewport"),&CanvasItem::get_viewport);
ClassDB::bind_method(D_METHOD("set_material", "material:Material"), &CanvasItem::set_material);
@@ -995,7 +1018,7 @@ void CanvasItem::_bind_methods() {
ClassDB::bind_method(D_METHOD("make_canvas_pos_local", "screen_point"),
&CanvasItem::make_canvas_pos_local);
- ClassDB::bind_method(D_METHOD("make_input_local", "event"), &CanvasItem::make_input_local);
+ ClassDB::bind_method(D_METHOD("make_input_local:InputEvent", "event:InputEvent"), &CanvasItem::make_input_local);
BIND_VMETHOD(MethodInfo("_draw"));
diff --git a/scene/2d/canvas_item.h b/scene/2d/canvas_item.h
index 06130e3252..27842727ac 100644
--- a/scene/2d/canvas_item.h
+++ b/scene/2d/canvas_item.h
@@ -242,6 +242,8 @@ public:
/* DRAWING API */
void draw_line(const Point2 &p_from, const Point2 &p_to, const Color &p_color, float p_width = 1.0, bool p_antialiased = false);
+ void draw_polyline(const Vector<Point2> &p_points, const Color &p_color, float p_width = 1.0, bool p_antialiased = false);
+ void draw_polyline_colors(const Vector<Point2> &p_points, const Vector<Color> &p_colors, float p_width = 1.0, bool p_antialiased = false);
void draw_rect(const Rect2 &p_rect, const Color &p_color, bool p_filled = true);
void draw_circle(const Point2 &p_pos, float p_radius, const Color &p_color);
void draw_texture(const Ref<Texture> &p_texture, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1, 1), const Ref<Texture> &p_normal_map = Ref<Texture>());
diff --git a/scene/2d/collision_object_2d.cpp b/scene/2d/collision_object_2d.cpp
index c5c274e225..eb47682884 100644
--- a/scene/2d/collision_object_2d.cpp
+++ b/scene/2d/collision_object_2d.cpp
@@ -152,6 +152,16 @@ void CollisionObject2D::get_shape_owners(List<uint32_t> *r_owners) {
}
}
+Array CollisionObject2D::_get_shape_owners() {
+
+ Array ret;
+ for (Map<uint32_t, ShapeData>::Element *E = shapes.front(); E; E = E->next()) {
+ ret.push_back(E->key());
+ }
+
+ return ret;
+}
+
void CollisionObject2D::shape_owner_set_transform(uint32_t p_owner, const Transform2D &p_transform) {
ERR_FAIL_COND(!shapes.has(p_owner));
@@ -204,10 +214,10 @@ int CollisionObject2D::shape_owner_get_shape_count(uint32_t p_owner) const {
return shapes[p_owner].shapes.size();
}
-Ref<Shape> CollisionObject2D::shape_owner_get_shape(uint32_t p_owner, int p_shape) const {
+Ref<Shape2D> CollisionObject2D::shape_owner_get_shape(uint32_t p_owner, int p_shape) const {
- ERR_FAIL_COND_V(!shapes.has(p_owner), Ref<Shape>());
- ERR_FAIL_INDEX_V(p_shape, shapes[p_owner].shapes.size(), Ref<Shape>());
+ ERR_FAIL_COND_V(!shapes.has(p_owner), Ref<Shape2D>());
+ ERR_FAIL_INDEX_V(p_shape, shapes[p_owner].shapes.size(), Ref<Shape2D>());
return shapes[p_owner].shapes[p_shape].shape;
}
@@ -323,6 +333,23 @@ void CollisionObject2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_pickable", "enabled"), &CollisionObject2D::set_pickable);
ClassDB::bind_method(D_METHOD("is_pickable"), &CollisionObject2D::is_pickable);
+ ClassDB::bind_method(D_METHOD("create_shape_owner", "owner:Object"), &CollisionObject2D::create_shape_owner);
+ ClassDB::bind_method(D_METHOD("remove_shape_owner", "owner_id"), &CollisionObject2D::remove_shape_owner);
+ ClassDB::bind_method(D_METHOD("get_shape_owners"), &CollisionObject2D::_get_shape_owners);
+ ClassDB::bind_method(D_METHOD("shape_owner_set_transform", "owner_id", "transform:Transform2D"), &CollisionObject2D::shape_owner_set_transform);
+ ClassDB::bind_method(D_METHOD("shape_owner_get_transform", "owner_id"), &CollisionObject2D::shape_owner_get_transform);
+ ClassDB::bind_method(D_METHOD("shape_owner_get_owner", "owner_id"), &CollisionObject2D::shape_owner_get_owner);
+ ClassDB::bind_method(D_METHOD("shape_owner_set_disabled", "owner_id", "disabled"), &CollisionObject2D::shape_owner_set_disabled);
+ ClassDB::bind_method(D_METHOD("is_shape_owner_disabled", "owner_id"), &CollisionObject2D::is_shape_owner_disabled);
+ ClassDB::bind_method(D_METHOD("shape_owner_set_one_way_collision", "owner_id", "enable"), &CollisionObject2D::shape_owner_set_one_way_collision);
+ ClassDB::bind_method(D_METHOD("is_shape_owner_one_way_collision_enabled", "owner_id"), &CollisionObject2D::is_shape_owner_one_way_collision_enabled);
+ ClassDB::bind_method(D_METHOD("shape_owner_add_shape", "owner_id", "shape:Shape2D"), &CollisionObject2D::shape_owner_add_shape);
+ ClassDB::bind_method(D_METHOD("shape_owner_get_shape_count", "owner_id"), &CollisionObject2D::shape_owner_get_shape_count);
+ ClassDB::bind_method(D_METHOD("shape_owner_get_shape", "owner_id", "shape_id"), &CollisionObject2D::shape_owner_get_shape);
+ ClassDB::bind_method(D_METHOD("shape_owner_get_shape_index", "owner_id", "shape_id"), &CollisionObject2D::shape_owner_get_shape_index);
+ ClassDB::bind_method(D_METHOD("shape_owner_remove_shape", "owner_id", "shape_id"), &CollisionObject2D::shape_owner_remove_shape);
+ ClassDB::bind_method(D_METHOD("shape_owner_clear_shapes", "owner_id"), &CollisionObject2D::shape_owner_clear_shapes);
+ ClassDB::bind_method(D_METHOD("shape_find_owner", "shape_index"), &CollisionObject2D::shape_find_owner);
BIND_VMETHOD(MethodInfo("_input_event", PropertyInfo(Variant::OBJECT, "viewport"), PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent"), PropertyInfo(Variant::INT, "shape_idx")));
diff --git a/scene/2d/collision_object_2d.h b/scene/2d/collision_object_2d.h
index deffe8a002..36bf39ff4e 100644
--- a/scene/2d/collision_object_2d.h
+++ b/scene/2d/collision_object_2d.h
@@ -81,6 +81,7 @@ public:
uint32_t create_shape_owner(Object *p_owner);
void remove_shape_owner(uint32_t owner);
void get_shape_owners(List<uint32_t> *r_owners);
+ Array _get_shape_owners();
void shape_owner_set_transform(uint32_t p_owner, const Transform2D &p_transform);
Transform2D shape_owner_get_transform(uint32_t p_owner) const;
@@ -94,7 +95,7 @@ public:
void shape_owner_add_shape(uint32_t p_owner, const Ref<Shape2D> &p_shape);
int shape_owner_get_shape_count(uint32_t p_owner) const;
- Ref<Shape> shape_owner_get_shape(uint32_t p_owner, int p_shape) const;
+ Ref<Shape2D> shape_owner_get_shape(uint32_t p_owner, int p_shape) const;
int shape_owner_get_shape_index(uint32_t p_owner, int p_shape) const;
void shape_owner_remove_shape(uint32_t p_owner, int p_shape);
diff --git a/scene/2d/collision_shape_2d.cpp b/scene/2d/collision_shape_2d.cpp
index ff4aa245ec..890ac0c1f3 100644
--- a/scene/2d/collision_shape_2d.cpp
+++ b/scene/2d/collision_shape_2d.cpp
@@ -201,8 +201,8 @@ bool CollisionShape2D::is_one_way_collision_enabled() const {
void CollisionShape2D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_shape", "shape"), &CollisionShape2D::set_shape);
- ClassDB::bind_method(D_METHOD("get_shape"), &CollisionShape2D::get_shape);
+ ClassDB::bind_method(D_METHOD("set_shape", "shape:Shape2D"), &CollisionShape2D::set_shape);
+ ClassDB::bind_method(D_METHOD("get_shape:Shape2D"), &CollisionShape2D::get_shape);
ClassDB::bind_method(D_METHOD("set_disabled", "disabled"), &CollisionShape2D::set_disabled);
ClassDB::bind_method(D_METHOD("is_disabled"), &CollisionShape2D::is_disabled);
ClassDB::bind_method(D_METHOD("set_one_way_collision", "enabled"), &CollisionShape2D::set_one_way_collision);
diff --git a/scene/2d/light_2d.cpp b/scene/2d/light_2d.cpp
index e8c2122bd1..044cb06c02 100644
--- a/scene/2d/light_2d.cpp
+++ b/scene/2d/light_2d.cpp
@@ -355,8 +355,8 @@ void Light2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_editor_only", "editor_only"), &Light2D::set_editor_only);
ClassDB::bind_method(D_METHOD("is_editor_only"), &Light2D::is_editor_only);
- ClassDB::bind_method(D_METHOD("set_texture", "texture"), &Light2D::set_texture);
- ClassDB::bind_method(D_METHOD("get_texture"), &Light2D::get_texture);
+ ClassDB::bind_method(D_METHOD("set_texture", "texture:Texture"), &Light2D::set_texture);
+ ClassDB::bind_method(D_METHOD("get_texture:Texture"), &Light2D::get_texture);
ClassDB::bind_method(D_METHOD("set_texture_offset", "texture_offset"), &Light2D::set_texture_offset);
ClassDB::bind_method(D_METHOD("get_texture_offset"), &Light2D::get_texture_offset);
diff --git a/scene/2d/line_2d.cpp b/scene/2d/line_2d.cpp
index 5438557d0b..22e54cfb54 100644
--- a/scene/2d/line_2d.cpp
+++ b/scene/2d/line_2d.cpp
@@ -283,11 +283,11 @@ void Line2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_default_color", "color"), &Line2D::set_default_color);
ClassDB::bind_method(D_METHOD("get_default_color"), &Line2D::get_default_color);
- ClassDB::bind_method(D_METHOD("set_gradient", "color"), &Line2D::set_gradient);
- ClassDB::bind_method(D_METHOD("get_gradient"), &Line2D::get_gradient);
+ ClassDB::bind_method(D_METHOD("set_gradient", "color:Gradient"), &Line2D::set_gradient);
+ ClassDB::bind_method(D_METHOD("get_gradient:Gradient"), &Line2D::get_gradient);
- ClassDB::bind_method(D_METHOD("set_texture", "texture"), &Line2D::set_texture);
- ClassDB::bind_method(D_METHOD("get_texture"), &Line2D::get_texture);
+ ClassDB::bind_method(D_METHOD("set_texture", "texture:Texture"), &Line2D::set_texture);
+ ClassDB::bind_method(D_METHOD("get_texture:Texture"), &Line2D::get_texture);
ClassDB::bind_method(D_METHOD("set_texture_mode", "mode"), &Line2D::set_texture_mode);
ClassDB::bind_method(D_METHOD("get_texture_mode"), &Line2D::get_texture_mode);
diff --git a/scene/2d/node_2d.cpp b/scene/2d/node_2d.cpp
index 6fe1dd73fe..0acc85681d 100644
--- a/scene/2d/node_2d.cpp
+++ b/scene/2d/node_2d.cpp
@@ -319,7 +319,7 @@ void Node2D::set_global_scale(const Size2 &p_scale) {
CanvasItem *pi = get_parent_item();
if (pi) {
const Size2 parent_global_scale = pi->get_global_transform().get_scale();
- set_scale(p_scale - parent_global_scale);
+ set_scale(p_scale / parent_global_scale);
} else {
set_scale(p_scale);
}
@@ -398,6 +398,16 @@ float Node2D::get_angle_to(const Vector2 &p_pos) const {
return (get_global_transform().affine_inverse().xform(p_pos)).angle();
}
+Point2 Node2D::to_local(Point2 p_global) const {
+
+ return get_global_transform().affine_inverse().xform(p_global);
+}
+
+Point2 Node2D::to_global(Point2 p_local) const {
+
+ return get_global_transform().xform(p_local);
+}
+
void Node2D::_bind_methods() {
// TODO: Obsolete those two methods (old name) properly (GH-4397)
@@ -436,6 +446,9 @@ void Node2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("look_at", "point"), &Node2D::look_at);
ClassDB::bind_method(D_METHOD("get_angle_to", "point"), &Node2D::get_angle_to);
+ ClassDB::bind_method(D_METHOD("to_local", "global_point"), &Node2D::to_local);
+ ClassDB::bind_method(D_METHOD("to_global", "local_point"), &Node2D::to_global);
+
ClassDB::bind_method(D_METHOD("set_z", "z"), &Node2D::set_z);
ClassDB::bind_method(D_METHOD("get_z"), &Node2D::get_z);
@@ -444,7 +457,7 @@ void Node2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("edit_set_pivot", "pivot"), &Node2D::edit_set_pivot);
- ClassDB::bind_method(D_METHOD("get_relative_transform_to_parent", "parent"), &Node2D::get_relative_transform_to_parent);
+ ClassDB::bind_method(D_METHOD("get_relative_transform_to_parent", "parent:Node"), &Node2D::get_relative_transform_to_parent);
ADD_GROUP("Transform", "");
ADD_PROPERTYNZ(PropertyInfo(Variant::VECTOR2, "position"), "set_position", "get_position");
diff --git a/scene/2d/node_2d.h b/scene/2d/node_2d.h
index 65331a4d58..5b3a28d5c3 100644
--- a/scene/2d/node_2d.h
+++ b/scene/2d/node_2d.h
@@ -104,6 +104,9 @@ public:
void look_at(const Vector2 &p_pos);
float get_angle_to(const Vector2 &p_pos) const;
+ Point2 to_local(Point2 p_global) const;
+ Point2 to_global(Point2 p_local) const;
+
void set_z_as_relative(bool p_enabled);
bool is_z_relative() const;
diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp
index fd261117e1..8b2653f639 100644
--- a/scene/2d/physics_body_2d.cpp
+++ b/scene/2d/physics_body_2d.cpp
@@ -554,11 +554,12 @@ real_t RigidBody2D::get_inertia() const {
void RigidBody2D::set_weight(real_t p_weight) {
- set_mass(p_weight / 9.8);
+ set_mass(p_weight / real_t(GLOBAL_DEF("physics/2d/default_gravity", 98)) / 10);
}
+
real_t RigidBody2D::get_weight() const {
- return mass * 9.8;
+ return mass * real_t(GLOBAL_DEF("physics/2d/default_gravity", 98)) / 10;
}
void RigidBody2D::set_friction(real_t p_friction) {
diff --git a/scene/2d/polygon_2d.cpp b/scene/2d/polygon_2d.cpp
index 5c1c953a37..4a68df5706 100644
--- a/scene/2d/polygon_2d.cpp
+++ b/scene/2d/polygon_2d.cpp
@@ -330,8 +330,8 @@ void Polygon2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_vertex_colors", "vertex_colors"), &Polygon2D::set_vertex_colors);
ClassDB::bind_method(D_METHOD("get_vertex_colors"), &Polygon2D::get_vertex_colors);
- ClassDB::bind_method(D_METHOD("set_texture", "texture"), &Polygon2D::set_texture);
- ClassDB::bind_method(D_METHOD("get_texture"), &Polygon2D::get_texture);
+ ClassDB::bind_method(D_METHOD("set_texture", "texture:Texture"), &Polygon2D::set_texture);
+ ClassDB::bind_method(D_METHOD("get_texture:Texture"), &Polygon2D::get_texture);
ClassDB::bind_method(D_METHOD("set_texture_offset", "texture_offset"), &Polygon2D::set_texture_offset);
ClassDB::bind_method(D_METHOD("get_texture_offset"), &Polygon2D::get_texture_offset);
diff --git a/scene/2d/remote_transform_2d.cpp b/scene/2d/remote_transform_2d.cpp
index 3cb9ebb5b5..4298377499 100644
--- a/scene/2d/remote_transform_2d.cpp
+++ b/scene/2d/remote_transform_2d.cpp
@@ -63,7 +63,50 @@ void RemoteTransform2D::_update_remote() {
return;
//todo make faster
- n->set_global_transform(get_global_transform());
+ if (use_global_coordinates) {
+
+ if (update_remote_position && update_remote_rotation && update_remote_scale) {
+ n->set_global_transform(get_global_transform());
+ } else {
+ Transform2D n_trans = n->get_global_transform();
+ Transform2D our_trans = get_global_transform();
+ Vector2 n_scale = n->get_global_scale();
+
+ if (!update_remote_position)
+ our_trans.set_origin(n_trans.get_origin());
+ if (!update_remote_rotation)
+ our_trans.set_rotation(n_trans.get_rotation());
+
+ n->set_global_transform(our_trans);
+
+ if (update_remote_scale)
+ n->set_scale(get_global_scale());
+ else
+ n->set_scale(n_scale);
+ }
+
+ } else {
+
+ if (update_remote_position && update_remote_rotation && update_remote_scale) {
+ n->set_transform(get_transform());
+ } else {
+ Transform2D n_trans = n->get_transform();
+ Transform2D our_trans = get_transform();
+ Vector2 n_scale = n->get_scale();
+
+ if (!update_remote_position)
+ our_trans.set_origin(n_trans.get_origin());
+ if (!update_remote_rotation)
+ our_trans.set_rotation(n_trans.get_rotation());
+
+ n->set_transform(our_trans);
+
+ if (update_remote_scale)
+ n->set_scale(get_scale());
+ else
+ n->set_scale(n_scale);
+ }
+ }
}
void RemoteTransform2D::_notification(int p_what) {
@@ -102,6 +145,41 @@ NodePath RemoteTransform2D::get_remote_node() const {
return remote_node;
}
+void RemoteTransform2D::set_use_global_coordinates(const bool p_enable) {
+ use_global_coordinates = p_enable;
+}
+
+bool RemoteTransform2D::get_use_global_coordinates() const {
+ return use_global_coordinates;
+}
+
+void RemoteTransform2D::set_update_position(const bool p_update) {
+ update_remote_position = p_update;
+ _update_remote();
+}
+
+bool RemoteTransform2D::get_update_position() const {
+ return update_remote_position;
+}
+
+void RemoteTransform2D::set_update_rotation(const bool p_update) {
+ update_remote_rotation = p_update;
+ _update_remote();
+}
+
+bool RemoteTransform2D::get_update_rotation() const {
+ return update_remote_rotation;
+}
+
+void RemoteTransform2D::set_update_scale(const bool p_update) {
+ update_remote_scale = p_update;
+ _update_remote();
+}
+
+bool RemoteTransform2D::get_update_scale() const {
+ return update_remote_scale;
+}
+
String RemoteTransform2D::get_configuration_warning() const {
if (!has_node(remote_node) || !get_node(remote_node) || !get_node(remote_node)->cast_to<Node2D>()) {
@@ -116,11 +194,32 @@ void RemoteTransform2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_remote_node", "path"), &RemoteTransform2D::set_remote_node);
ClassDB::bind_method(D_METHOD("get_remote_node"), &RemoteTransform2D::get_remote_node);
+ ClassDB::bind_method(D_METHOD("set_use_global_coordinates", "use_global_coordinates"), &RemoteTransform2D::set_use_global_coordinates);
+ ClassDB::bind_method(D_METHOD("get_use_global_coordinates"), &RemoteTransform2D::get_use_global_coordinates);
+
+ ClassDB::bind_method(D_METHOD("set_update_position", "update_remote_position"), &RemoteTransform2D::set_update_position);
+ ClassDB::bind_method(D_METHOD("get_update_position"), &RemoteTransform2D::get_update_position);
+ ClassDB::bind_method(D_METHOD("set_update_rotation", "update_remote_rotation"), &RemoteTransform2D::set_update_rotation);
+ ClassDB::bind_method(D_METHOD("get_update_rotation"), &RemoteTransform2D::get_update_rotation);
+ ClassDB::bind_method(D_METHOD("set_update_scale", "update_remote_scale"), &RemoteTransform2D::set_update_scale);
+ ClassDB::bind_method(D_METHOD("get_update_scale"), &RemoteTransform2D::get_update_scale);
+
ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "remote_path"), "set_remote_node", "get_remote_node");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_global_coordinates"), "set_use_global_coordinates", "get_use_global_coordinates");
+
+ ADD_GROUP("Update", "update_");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "update_position"), "set_update_position", "get_update_position");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "update_rotation"), "set_update_rotation", "get_update_rotation");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "update_scale"), "set_update_scale", "get_update_scale");
}
RemoteTransform2D::RemoteTransform2D() {
+ use_global_coordinates = true;
+ update_remote_position = true;
+ update_remote_rotation = true;
+ update_remote_scale = true;
+
cache = 0;
set_notify_transform(true);
}
diff --git a/scene/2d/remote_transform_2d.h b/scene/2d/remote_transform_2d.h
index 375efabf2f..d58ec14a95 100644
--- a/scene/2d/remote_transform_2d.h
+++ b/scene/2d/remote_transform_2d.h
@@ -37,6 +37,11 @@ class RemoteTransform2D : public Node2D {
ObjectID cache;
+ bool use_global_coordinates;
+ bool update_remote_position;
+ bool update_remote_rotation;
+ bool update_remote_scale;
+
void _update_remote();
void _update_cache();
//void _node_exited_scene();
@@ -48,6 +53,18 @@ public:
void set_remote_node(const NodePath &p_remote_node);
NodePath get_remote_node() const;
+ void set_use_global_coordinates(const bool p_enable);
+ bool get_use_global_coordinates() const;
+
+ void set_update_position(const bool p_update);
+ bool get_update_position() const;
+
+ void set_update_rotation(const bool p_update);
+ bool get_update_rotation() const;
+
+ void set_update_scale(const bool p_update);
+ bool get_update_scale() const;
+
virtual String get_configuration_warning() const;
RemoteTransform2D();
diff --git a/scene/2d/screen_button.cpp b/scene/2d/screen_button.cpp
index 37139b2b93..24c9137807 100644
--- a/scene/2d/screen_button.cpp
+++ b/scene/2d/screen_button.cpp
@@ -356,17 +356,17 @@ bool TouchScreenButton::is_passby_press_enabled() const {
void TouchScreenButton::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_texture", "texture"), &TouchScreenButton::set_texture);
- ClassDB::bind_method(D_METHOD("get_texture"), &TouchScreenButton::get_texture);
+ ClassDB::bind_method(D_METHOD("set_texture", "texture:Texture"), &TouchScreenButton::set_texture);
+ ClassDB::bind_method(D_METHOD("get_texture:Texture"), &TouchScreenButton::get_texture);
- ClassDB::bind_method(D_METHOD("set_texture_pressed", "texture_pressed"), &TouchScreenButton::set_texture_pressed);
- ClassDB::bind_method(D_METHOD("get_texture_pressed"), &TouchScreenButton::get_texture_pressed);
+ ClassDB::bind_method(D_METHOD("set_texture_pressed", "texture_pressed:Texture"), &TouchScreenButton::set_texture_pressed);
+ ClassDB::bind_method(D_METHOD("get_texture_pressed:Texture"), &TouchScreenButton::get_texture_pressed);
- ClassDB::bind_method(D_METHOD("set_bitmask", "bitmask"), &TouchScreenButton::set_bitmask);
- ClassDB::bind_method(D_METHOD("get_bitmask"), &TouchScreenButton::get_bitmask);
+ ClassDB::bind_method(D_METHOD("set_bitmask", "bitmask:BitMap"), &TouchScreenButton::set_bitmask);
+ ClassDB::bind_method(D_METHOD("get_bitmask:BitMap"), &TouchScreenButton::get_bitmask);
- ClassDB::bind_method(D_METHOD("set_shape", "shape"), &TouchScreenButton::set_shape);
- ClassDB::bind_method(D_METHOD("get_shape"), &TouchScreenButton::get_shape);
+ ClassDB::bind_method(D_METHOD("set_shape", "shape:Shape2D"), &TouchScreenButton::set_shape);
+ ClassDB::bind_method(D_METHOD("get_shape:Shape2D"), &TouchScreenButton::get_shape);
ClassDB::bind_method(D_METHOD("set_shape_centered", "bool"), &TouchScreenButton::set_shape_centered);
ClassDB::bind_method(D_METHOD("is_shape_centered"), &TouchScreenButton::is_shape_centered);
diff --git a/scene/2d/sprite.cpp b/scene/2d/sprite.cpp
index c4590c100d..ad34dfd63a 100644
--- a/scene/2d/sprite.cpp
+++ b/scene/2d/sprite.cpp
@@ -105,20 +105,7 @@ void Sprite::set_texture(const Ref<Texture> &p_texture) {
if (p_texture == texture)
return;
-#ifdef DEBUG_ENABLED
- if (texture.is_valid()) {
- texture->disconnect(CoreStringNames::get_singleton()->changed, this, SceneStringNames::get_singleton()->update);
- }
-#endif
texture = p_texture;
- /* this should no longer be needed in 3.0
-#ifdef DEBUG_ENABLED
- if (texture.is_valid()) {
- texture->set_flags(texture->get_flags()); //remove repeat from texture, it looks bad in sprites
- texture->connect(CoreStringNames::get_singleton()->changed, this, SceneStringNames::get_singleton()->update);
- }
-#endif
-*/
update();
emit_signal("texture_changed");
item_rect_changed();
diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp
index 57e25ec609..9d70b75027 100644
--- a/scene/2d/tile_map.cpp
+++ b/scene/2d/tile_map.cpp
@@ -461,16 +461,18 @@ void TileMap::_update_dirty_quadrants() {
Transform2D xform;
xform.set_origin(offset.floor());
- _fix_cell_transform(xform, c, shapes[i].shape_offset + center_ofs, s);
+ _fix_cell_transform(xform, c, center_ofs, s);
+
+ xform *= shapes[i].shape_transform;
if (debug_canvas_item.is_valid()) {
vs->canvas_item_add_set_transform(debug_canvas_item, xform);
shape->draw(debug_canvas_item, debug_collision_color);
}
ps->body_add_shape(q.body, shape->get_rid(), xform);
- shape_idx++;
- ps->body_set_shape_as_one_way_collision(q.body, shape_idx, shapes[i].one_way_collision);
ps->body_set_shape_metadata(q.body, shape_idx, Vector2(E->key().x, E->key().y));
+ ps->body_set_shape_as_one_way_collision(q.body, shape_idx, shapes[i].one_way_collision);
+ shape_idx++;
}
}
diff --git a/scene/3d/area.cpp b/scene/3d/area.cpp
index 39a4e926b2..59227070b3 100644
--- a/scene/3d/area.cpp
+++ b/scene/3d/area.cpp
@@ -29,7 +29,9 @@
/*************************************************************************/
#include "area.h"
#include "scene/scene_string_names.h"
+#include "servers/audio_server.h"
#include "servers/physics_server.h"
+
void Area::set_space_override_mode(SpaceOverride p_mode) {
space_override = p_mode;
@@ -227,7 +229,11 @@ void Area::_clear_monitoring() {
Object *obj = ObjectDB::get_instance(E->key());
Node *node = obj ? obj->cast_to<Node>() : NULL;
- ERR_CONTINUE(!node);
+
+ if (!node) //node may have been deleted in previous frame or at other legiminate point
+ continue;
+ //ERR_CONTINUE(!node);
+
if (!E->get().in_tree)
continue;
@@ -253,7 +259,11 @@ void Area::_clear_monitoring() {
Object *obj = ObjectDB::get_instance(E->key());
Node *node = obj ? obj->cast_to<Node>() : NULL;
- ERR_CONTINUE(!node);
+
+ if (!node) //node may have been deleted in previous frame or at other legiminate point
+ continue;
+ //ERR_CONTINUE(!node);
+
if (!E->get().in_tree)
continue;
@@ -530,6 +540,87 @@ bool Area::get_collision_layer_bit(int p_bit) const {
return get_collision_layer() & (1 << p_bit);
}
+void Area::set_audio_bus_override(bool p_override) {
+
+ audio_bus_override = p_override;
+}
+
+bool Area::is_overriding_audio_bus() const {
+
+ return audio_bus_override;
+}
+
+void Area::set_audio_bus(const StringName &p_audio_bus) {
+
+ audio_bus = p_audio_bus;
+}
+StringName Area::get_audio_bus() const {
+
+ for (int i = 0; i < AudioServer::get_singleton()->get_bus_count(); i++) {
+ if (AudioServer::get_singleton()->get_bus_name(i) == audio_bus) {
+ return audio_bus;
+ }
+ }
+ return "Master";
+}
+
+void Area::set_use_reverb_bus(bool p_enable) {
+
+ use_reverb_bus = p_enable;
+}
+bool Area::is_using_reverb_bus() const {
+
+ return use_reverb_bus;
+}
+
+void Area::set_reverb_bus(const StringName &p_audio_bus) {
+
+ reverb_bus = p_audio_bus;
+}
+StringName Area::get_reverb_bus() const {
+
+ for (int i = 0; i < AudioServer::get_singleton()->get_bus_count(); i++) {
+ if (AudioServer::get_singleton()->get_bus_name(i) == reverb_bus) {
+ return reverb_bus;
+ }
+ }
+ return "Master";
+}
+
+void Area::set_reverb_amount(float p_amount) {
+
+ reverb_amount = p_amount;
+}
+float Area::get_reverb_amount() const {
+
+ return reverb_amount;
+}
+
+void Area::set_reverb_uniformity(float p_uniformity) {
+
+ reverb_uniformity = p_uniformity;
+}
+float Area::get_reverb_uniformity() const {
+
+ return reverb_uniformity;
+}
+
+void Area::_validate_property(PropertyInfo &property) const {
+
+ if (property.name == "audio_bus_name" || property.name == "reverb_bus_name") {
+
+ String options;
+ for (int i = 0; i < AudioServer::get_singleton()->get_bus_count(); i++) {
+ if (i > 0)
+ options += ",";
+ String name = AudioServer::get_singleton()->get_bus_name(i);
+ options += name;
+ }
+
+ property.hint_string = options;
+ }
+}
+
void Area::_bind_methods() {
ClassDB::bind_method(D_METHOD("_body_enter_tree", "id"), &Area::_body_enter_tree);
@@ -589,6 +680,24 @@ void Area::_bind_methods() {
ClassDB::bind_method(D_METHOD("_body_inout"), &Area::_body_inout);
ClassDB::bind_method(D_METHOD("_area_inout"), &Area::_area_inout);
+ ClassDB::bind_method(D_METHOD("set_audio_bus_override", "enable"), &Area::set_audio_bus_override);
+ ClassDB::bind_method(D_METHOD("is_overriding_audio_bus"), &Area::is_overriding_audio_bus);
+
+ ClassDB::bind_method(D_METHOD("set_audio_bus", "name"), &Area::set_audio_bus);
+ ClassDB::bind_method(D_METHOD("get_audio_bus"), &Area::get_audio_bus);
+
+ ClassDB::bind_method(D_METHOD("set_use_reverb_bus", "enable"), &Area::set_use_reverb_bus);
+ ClassDB::bind_method(D_METHOD("is_using_reverb_bus"), &Area::is_using_reverb_bus);
+
+ ClassDB::bind_method(D_METHOD("set_reverb_bus", "name"), &Area::set_reverb_bus);
+ ClassDB::bind_method(D_METHOD("get_reverb_bus"), &Area::get_reverb_bus);
+
+ ClassDB::bind_method(D_METHOD("set_reverb_amount", "amount"), &Area::set_reverb_amount);
+ ClassDB::bind_method(D_METHOD("get_reverb_amount"), &Area::get_reverb_amount);
+
+ ClassDB::bind_method(D_METHOD("set_reverb_uniformity", "amount"), &Area::set_reverb_uniformity);
+ ClassDB::bind_method(D_METHOD("get_reverb_uniformity"), &Area::get_reverb_uniformity);
+
ADD_SIGNAL(MethodInfo("body_shape_entered", PropertyInfo(Variant::INT, "body_id"), PropertyInfo(Variant::OBJECT, "body"), PropertyInfo(Variant::INT, "body_shape"), PropertyInfo(Variant::INT, "area_shape")));
ADD_SIGNAL(MethodInfo("body_shape_exited", PropertyInfo(Variant::INT, "body_id"), PropertyInfo(Variant::OBJECT, "body"), PropertyInfo(Variant::INT, "body_shape"), PropertyInfo(Variant::INT, "area_shape")));
ADD_SIGNAL(MethodInfo("body_entered", PropertyInfo(Variant::OBJECT, "body")));
@@ -612,6 +721,14 @@ void Area::_bind_methods() {
ADD_GROUP("Collision", "collision_");
ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_layer", PROPERTY_HINT_LAYERS_3D_PHYSICS), "set_collision_layer", "get_collision_layer");
ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_mask", PROPERTY_HINT_LAYERS_3D_PHYSICS), "set_collision_mask", "get_collision_mask");
+ ADD_GROUP("Audio Bus", "audio_bus_");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "audio_bus_override"), "set_audio_bus_override", "is_overriding_audio_bus");
+ ADD_PROPERTY(PropertyInfo(Variant::STRING, "audio_bus_name", PROPERTY_HINT_ENUM, ""), "set_audio_bus", "get_audio_bus");
+ ADD_GROUP("Reverb Bus", "reverb_bus_");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "reverb_bus_enable"), "set_use_reverb_bus", "is_using_reverb_bus");
+ ADD_PROPERTY(PropertyInfo(Variant::STRING, "reverb_bus_name", PROPERTY_HINT_ENUM, ""), "set_reverb_bus", "get_reverb_bus");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "reverb_bus_amount", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_reverb_amount", "get_reverb_amount");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "reverb_bus_uniformity", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_reverb_uniformity", "get_reverb_uniformity");
}
Area::Area()
@@ -632,6 +749,14 @@ Area::Area()
set_ray_pickable(false);
set_monitoring(true);
set_monitorable(true);
+
+ audio_bus_override = false;
+ audio_bus = "Master";
+
+ use_reverb_bus = false;
+ reverb_bus = "Master";
+ reverb_amount = 0.0;
+ reverb_uniformity = 0.0;
}
Area::~Area() {
diff --git a/scene/3d/area.h b/scene/3d/area.h
index 279a52ee69..5df308fc47 100644
--- a/scene/3d/area.h
+++ b/scene/3d/area.h
@@ -126,6 +126,16 @@ private:
Map<ObjectID, AreaState> area_map;
void _clear_monitoring();
+ bool audio_bus_override;
+ StringName audio_bus;
+
+ bool use_reverb_bus;
+ StringName reverb_bus;
+ float reverb_amount;
+ float reverb_uniformity;
+
+ void _validate_property(PropertyInfo &property) const;
+
protected:
void _notification(int p_what);
static void _bind_methods();
@@ -179,6 +189,24 @@ public:
bool overlaps_area(Node *p_area) const;
bool overlaps_body(Node *p_body) const;
+ void set_audio_bus_override(bool p_override);
+ bool is_overriding_audio_bus() const;
+
+ void set_audio_bus(const StringName &p_audio_bus);
+ StringName get_audio_bus() const;
+
+ void set_use_reverb_bus(bool p_enable);
+ bool is_using_reverb_bus() const;
+
+ void set_reverb_bus(const StringName &p_audio_bus);
+ StringName get_reverb_bus() const;
+
+ void set_reverb_amount(float p_amount);
+ float get_reverb_amount() const;
+
+ void set_reverb_uniformity(float p_uniformity);
+ float get_reverb_uniformity() const;
+
Area();
~Area();
};
diff --git a/scene/3d/arvr_nodes.cpp b/scene/3d/arvr_nodes.cpp
new file mode 100644
index 0000000000..5f2a720748
--- /dev/null
+++ b/scene/3d/arvr_nodes.cpp
@@ -0,0 +1,313 @@
+/*************************************************************************/
+/* arvr_nodes.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#include "arvr_nodes.h"
+#include "core/os/input.h"
+#include "servers/arvr/arvr_interface.h"
+#include "servers/arvr/arvr_positional_tracker.h"
+#include "servers/arvr_server.h"
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void ARVRCamera::_notification(int p_what) {
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE: {
+ // need to find our ARVROrigin parent and let it know we're it's camera!
+ ARVROrigin *origin = get_parent()->cast_to<ARVROrigin>();
+ if (origin != NULL) {
+ origin->set_tracked_camera(this);
+ }
+ }; break;
+ case NOTIFICATION_EXIT_TREE: {
+ // need to find our ARVROrigin parent and let it know we're no longer it's camera!
+ ARVROrigin *origin = get_parent()->cast_to<ARVROrigin>();
+ if (origin != NULL) {
+ origin->clear_tracked_camera_if(this);
+ }
+ }; break;
+ };
+};
+
+String ARVRCamera::get_configuration_warning() const {
+ if (!is_visible() || !is_inside_tree())
+ return String();
+
+ // must be child node of ARVROrigin!
+ ARVROrigin *origin = get_parent()->cast_to<ARVROrigin>();
+ if (origin == NULL) {
+ return TTR("ARVRCamera must have an ARVROrigin node as its parent");
+ };
+
+ return String();
+};
+
+ARVRCamera::ARVRCamera(){
+ // nothing to do here yet for now..
+};
+
+ARVRCamera::~ARVRCamera(){
+ // nothing to do here yet for now..
+};
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void ARVRController::_notification(int p_what) {
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE: {
+ set_process_internal(true);
+ }; break;
+ case NOTIFICATION_EXIT_TREE: {
+ set_process_internal(false);
+ }; break;
+ case NOTIFICATION_INTERNAL_PROCESS: {
+ // get our ARVRServer
+ ARVRServer *arvr_server = ARVRServer::get_singleton();
+ ERR_FAIL_NULL(arvr_server);
+
+ // find the tracker for our controller
+ ARVRPositionalTracker *tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_CONTROLLER, controller_id);
+ if (tracker == NULL) {
+ // this controller is currently turned off
+ is_active = false;
+ button_states = 0;
+ } else {
+ set_transform(tracker->get_transform(true));
+
+ int joy_id = tracker->get_joy_id();
+ if (joy_id >= 0) {
+ int mask = 1;
+ // check button states
+ for (int i = 0; i < 16; i++) {
+ 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) {
+ emit_signal("button_pressed", i);
+ button_states += mask;
+ } else if (was_pressed && !is_pressed) {
+ emit_signal("button_release", i);
+ button_states -= mask;
+ };
+
+ mask = mask << 1;
+ };
+
+ } else {
+ button_states = 0;
+ };
+ };
+ }; break;
+ default:
+ break;
+ };
+};
+
+void ARVRController::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("set_controller_id", "controller_id"), &ARVRController::set_controller_id);
+ ClassDB::bind_method(D_METHOD("get_controller_id"), &ARVRController::get_controller_id);
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "controller_id"), "set_controller_id", "get_controller_id");
+ ClassDB::bind_method(D_METHOD("get_controller_name"), &ARVRController::get_controller_name);
+
+ // passthroughs to information about our related joystick
+ ClassDB::bind_method(D_METHOD("get_joystick_id"), &ARVRController::get_joystick_id);
+ ClassDB::bind_method(D_METHOD("is_button_pressed", "button"), &ARVRController::is_button_pressed);
+ ClassDB::bind_method(D_METHOD("get_joystick_axis", "axis"), &ARVRController::get_joystick_axis);
+
+ ClassDB::bind_method(D_METHOD("get_is_active"), &ARVRController::get_is_active);
+
+ ADD_SIGNAL(MethodInfo("button_pressed", PropertyInfo(Variant::INT, "button")));
+ ADD_SIGNAL(MethodInfo("button_release", PropertyInfo(Variant::INT, "button")));
+};
+
+void ARVRController::set_controller_id(int p_controller_id) {
+ // we don't check any bounds here, this controller may not yet be active and just be a place holder until it is.
+ controller_id = p_controller_id;
+};
+
+int ARVRController::get_controller_id(void) const {
+ return controller_id;
+};
+
+String ARVRController::get_controller_name(void) const {
+ // get our ARVRServer
+ ARVRServer *arvr_server = ARVRServer::get_singleton();
+ ERR_FAIL_NULL_V(arvr_server, String());
+
+ ARVRPositionalTracker *tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_CONTROLLER, controller_id);
+ if (tracker == NULL) {
+ return String("Not connected");
+ };
+
+ return tracker->get_name();
+};
+
+int ARVRController::get_joystick_id() const {
+ // get our ARVRServer
+ ARVRServer *arvr_server = ARVRServer::get_singleton();
+ ERR_FAIL_NULL_V(arvr_server, 0);
+
+ ARVRPositionalTracker *tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_CONTROLLER, controller_id);
+ if (tracker == NULL) {
+ return 0;
+ };
+
+ return tracker->get_joy_id();
+};
+
+int ARVRController::is_button_pressed(int p_button) const {
+ int joy_id = get_joystick_id();
+ if (joy_id == 0) {
+ return false;
+ };
+
+ return Input::get_singleton()->is_joy_button_pressed(joy_id, p_button);
+};
+
+float ARVRController::get_joystick_axis(int p_axis) const {
+ int joy_id = get_joystick_id();
+ if (joy_id == 0) {
+ return 0.0;
+ };
+
+ return Input::get_singleton()->get_joy_axis(joy_id, p_axis);
+};
+
+bool ARVRController::get_is_active() const {
+ return is_active;
+};
+
+String ARVRController::get_configuration_warning() const {
+ if (!is_visible() || !is_inside_tree())
+ return String();
+
+ // must be child node of ARVROrigin!
+ ARVROrigin *origin = get_parent()->cast_to<ARVROrigin>();
+ if (origin == NULL) {
+ return TTR("ARVRController must have an ARVROrigin node as its parent");
+ };
+
+ if (controller_id == 0) {
+ return TTR("The controller id must not be 0 or this controller will not be bound to an actual controller");
+ };
+
+ return String();
+};
+
+ARVRController::ARVRController() {
+ controller_id = 0;
+ is_active = true;
+};
+
+ARVRController::~ARVRController(){
+ // nothing to do here yet for now..
+};
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+String ARVROrigin::get_configuration_warning() const {
+ if (!is_visible() || !is_inside_tree())
+ return String();
+
+ if (tracked_camera == NULL)
+ return TTR("ARVROrigin requires an ARVRCamera child node");
+
+ return String();
+};
+
+void ARVROrigin::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("set_world_scale", "world_scale"), &ARVROrigin::set_world_scale);
+ ClassDB::bind_method(D_METHOD("get_world_scale"), &ARVROrigin::get_world_scale);
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "world_scale"), "set_world_scale", "get_world_scale");
+};
+
+void ARVROrigin::set_tracked_camera(ARVRCamera *p_tracked_camera) {
+ tracked_camera = p_tracked_camera;
+};
+
+void ARVROrigin::clear_tracked_camera_if(ARVRCamera *p_tracked_camera) {
+ if (tracked_camera == p_tracked_camera) {
+ tracked_camera = NULL;
+ };
+};
+
+float ARVROrigin::get_world_scale() const {
+ // get our ARVRServer
+ ARVRServer *arvr_server = ARVRServer::get_singleton();
+ ERR_FAIL_NULL_V(arvr_server, 1.0);
+
+ return arvr_server->get_world_scale();
+};
+
+void ARVROrigin::set_world_scale(float p_world_scale) {
+ // get our ARVRServer
+ ARVRServer *arvr_server = ARVRServer::get_singleton();
+ ERR_FAIL_NULL(arvr_server);
+
+ arvr_server->set_world_scale(p_world_scale);
+};
+
+void ARVROrigin::_notification(int p_what) {
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE: {
+ set_process_internal(true);
+ }; break;
+ case NOTIFICATION_EXIT_TREE: {
+ set_process_internal(false);
+ }; break;
+ case NOTIFICATION_INTERNAL_PROCESS: {
+ // get our ARVRServer
+ ARVRServer *arvr_server = ARVRServer::get_singleton();
+ ERR_FAIL_NULL(arvr_server);
+
+ // set our world origin to our node transform
+ arvr_server->set_world_origin(get_global_transform());
+
+ // check if we have a primary interface
+ Ref<ARVRInterface> arvr_interface = arvr_server->get_primary_interface();
+ if (arvr_interface.is_valid() && tracked_camera != NULL) {
+ // get our positioning transform for our headset
+ Transform t = arvr_interface->get_transform_for_eye(ARVRInterface::EYE_MONO, Transform());
+
+ // now apply this to our camera
+ tracked_camera->set_transform(t);
+ };
+ }; break;
+ default:
+ break;
+ };
+};
+
+ARVROrigin::ARVROrigin() {
+ tracked_camera = NULL;
+};
+
+ARVROrigin::~ARVROrigin(){
+ // nothing to do here yet for now..
+};
diff --git a/scene/3d/arvr_nodes.h b/scene/3d/arvr_nodes.h
new file mode 100644
index 0000000000..3dab263317
--- /dev/null
+++ b/scene/3d/arvr_nodes.h
@@ -0,0 +1,126 @@
+/*************************************************************************/
+/* arvr_nodes.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#ifndef ARVR_NODES_H
+#define ARVR_NODES_H
+
+#include "scene/3d/camera.h"
+#include "scene/3d/spatial.h"
+
+/**
+ @author Bastiaan Olij <mux213@gmail.com>
+**/
+
+/*
+ ARVRCamera is a subclass of camera which will register itself with its parent ARVROrigin and as a result is automatically positioned
+*/
+class ARVRCamera : public Camera {
+
+ GDCLASS(ARVRCamera, Camera);
+
+protected:
+ void _notification(int p_what);
+
+public:
+ String get_configuration_warning() const;
+
+ ARVRCamera();
+ ~ARVRCamera();
+};
+
+/*
+ ARVRController is a helper node that automatically updates it's position based on tracker data.
+
+ It must be a child node of our ARVROrigin node
+*/
+
+class ARVRController : public Spatial {
+
+ GDCLASS(ARVRController, Spatial);
+
+private:
+ int controller_id;
+ bool is_active;
+ int button_states;
+
+protected:
+ void _notification(int p_what);
+ static void _bind_methods();
+
+public:
+ void set_controller_id(int p_controller_id);
+ int get_controller_id(void) const;
+ String get_controller_name(void) const;
+
+ int get_joystick_id() const;
+ int is_button_pressed(int p_button) const;
+ float get_joystick_axis(int p_axis) const;
+
+ bool get_is_active() const;
+
+ String get_configuration_warning() const;
+
+ ARVRController();
+ ~ARVRController();
+};
+
+/*
+ ARVROrigin is special spatial node that acts as our origin point mapping our real world center of our tracking volume into our virtual world.
+
+ It is this point that you will move around the world as the player 'moves while standing still', i.e. the player moves through teleporting or controller inputs as opposed to physically moving.
+
+ Our camera and controllers will always be child nodes and thus place relative to this origin point.
+ This node will automatically locate any camera child nodes and update its position while our ARVRController node will handle tracked controllers.
+*/
+class ARVROrigin : public Spatial {
+
+ GDCLASS(ARVROrigin, Spatial);
+
+private:
+ ARVRCamera *tracked_camera;
+
+protected:
+ void _notification(int p_what);
+ static void _bind_methods();
+
+public:
+ String get_configuration_warning() const;
+
+ void set_tracked_camera(ARVRCamera *p_tracked_camera);
+ void clear_tracked_camera_if(ARVRCamera *p_tracked_camera);
+
+ float get_world_scale() const;
+ void set_world_scale(float p_world_scale);
+
+ ARVROrigin();
+ ~ARVROrigin();
+};
+
+#endif /* ARVR_NODES_H */
diff --git a/scene/3d/audio_stream_player_3d.cpp b/scene/3d/audio_stream_player_3d.cpp
new file mode 100644
index 0000000000..87ea018425
--- /dev/null
+++ b/scene/3d/audio_stream_player_3d.cpp
@@ -0,0 +1,930 @@
+#include "audio_stream_player_3d.h"
+#include "engine.h"
+#include "scene/3d/area.h"
+#include "scene/3d/camera.h"
+#include "scene/main/viewport.h"
+void AudioStreamPlayer3D::_mix_audio() {
+
+ if (!stream_playback.is_valid()) {
+ return;
+ }
+
+ if (!active) {
+ return;
+ }
+
+ bool started = false;
+ if (setseek >= 0.0) {
+ stream_playback->start(setseek);
+ setseek = -1.0; //reset seek
+ started = true;
+ }
+
+ //get data
+ AudioFrame *buffer = mix_buffer.ptr();
+ int buffer_size = mix_buffer.size();
+
+ //mix
+ if (output_count > 0 || out_of_range_mode == OUT_OF_RANGE_MIX) {
+
+ float pitch_scale = 0.0;
+ if (output_count) {
+ //used for doppler, not realistic but good enough
+ for (int i = 0; i < output_count; i++) {
+ pitch_scale += outputs[i].pitch_scale;
+ }
+ pitch_scale /= float(output_count);
+ } else {
+ pitch_scale = 1.0;
+ }
+
+ stream_playback->mix(buffer, pitch_scale, buffer_size);
+ }
+
+ //write all outputs
+ for (int i = 0; i < output_count; i++) {
+
+ Output current = outputs[i];
+
+ //see if current output exists, to keep volume ramp
+ bool found = false;
+ for (int j = i; j < prev_output_count; j++) {
+ if (prev_outputs[j].viewport == current.viewport) {
+ if (j != i) {
+ SWAP(prev_outputs[j], prev_outputs[i]);
+ }
+ found = true;
+ break;
+ }
+ }
+
+ bool interpolate_filter = !started;
+ ;
+ if (!found) {
+ //create new if was not used before
+ if (prev_output_count < MAX_OUTPUTS) {
+ prev_outputs[prev_output_count] = prev_outputs[i]; //may be owned by another viewport
+ prev_output_count++;
+ }
+ prev_outputs[i] = current;
+ interpolate_filter = false;
+ }
+
+ //mix!
+
+ int buffers = 0;
+ int first = 0;
+
+ switch (AudioServer::get_singleton()->get_speaker_mode()) {
+
+ case AudioServer::SPEAKER_MODE_STEREO: {
+ buffers = 1;
+ first = 0;
+
+ } break;
+ case AudioServer::SPEAKER_SURROUND_51: {
+ buffers = 2;
+ first = 1;
+
+ } break;
+ case AudioServer::SPEAKER_SURROUND_71: {
+
+ buffers = 3;
+ first = 1;
+
+ } break;
+ }
+
+ for (int k = 0; k < buffers; k++) {
+ AudioFrame vol_inc = (current.vol[k] - prev_outputs[i].vol[k]) / float(buffer_size);
+ AudioFrame vol = current.vol[k];
+
+ AudioFrame *target = AudioServer::get_singleton()->thread_get_channel_mix_buffer(current.bus_index, first + k);
+
+ current.filter.set_mode(AudioFilterSW::HIGHSHELF);
+ current.filter.set_sampling_rate(AudioServer::get_singleton()->get_mix_rate());
+ current.filter.set_cutoff(attenuation_filter_cutoff_hz);
+ current.filter.set_resonance(1);
+ current.filter.set_stages(1);
+ current.filter.set_gain(current.filter_gain);
+
+ if (interpolate_filter) {
+
+ current.filter_process[k * 2 + 0] = prev_outputs[i].filter_process[k * 2 + 0];
+ current.filter_process[k * 2 + 1] = prev_outputs[i].filter_process[k * 2 + 1];
+
+ current.filter_process[k * 2 + 0].set_filter(&current.filter, false);
+ current.filter_process[k * 2 + 1].set_filter(&current.filter, false);
+
+ current.filter_process[k * 2 + 0].update_coeffs(buffer_size);
+ current.filter_process[k * 2 + 1].update_coeffs(buffer_size);
+ for (int j = 0; j < buffer_size; j++) {
+
+ AudioFrame f = buffer[j] * vol;
+ current.filter_process[k * 2 + 0].process_one_interp(f.l);
+ current.filter_process[k * 2 + 1].process_one_interp(f.r);
+
+ target[j] += f;
+ vol += vol_inc;
+ }
+ } else {
+ current.filter_process[k * 2 + 0].set_filter(&current.filter);
+ current.filter_process[k * 2 + 1].set_filter(&current.filter);
+
+ current.filter_process[k * 2 + 0].update_coeffs();
+ current.filter_process[k * 2 + 1].update_coeffs();
+ for (int j = 0; j < buffer_size; j++) {
+
+ AudioFrame f = buffer[j] * vol;
+ current.filter_process[k * 2 + 0].process_one(f.l);
+ current.filter_process[k * 2 + 1].process_one(f.r);
+
+ target[j] += f;
+ vol += vol_inc;
+ }
+ }
+
+ if (current.reverb_bus_index >= 0) {
+
+ AudioFrame *rtarget = AudioServer::get_singleton()->thread_get_channel_mix_buffer(current.reverb_bus_index, first + k);
+
+ if (current.reverb_bus_index == prev_outputs[i].reverb_bus_index) {
+ AudioFrame rvol_inc = (current.reverb_vol[k] - prev_outputs[i].reverb_vol[k]) / float(buffer_size);
+ AudioFrame rvol = prev_outputs[i].reverb_vol[k];
+
+ for (int j = 0; j < buffer_size; j++) {
+
+ rtarget[j] += buffer[j] * rvol;
+ rvol += rvol_inc;
+ }
+ } else {
+
+ AudioFrame rvol = current.reverb_vol[k];
+ for (int j = 0; j < buffer_size; j++) {
+
+ rtarget[j] += buffer[j] * rvol;
+ }
+ }
+ }
+ }
+
+ prev_outputs[i] = current;
+ }
+
+ prev_output_count = output_count;
+
+ //stream is no longer active, disable this.
+ if (!stream_playback->is_playing()) {
+ active = false;
+ }
+
+ output_ready = false;
+}
+
+float AudioStreamPlayer3D::_get_attenuation_db(float p_distance) const {
+
+ float att;
+ switch (attenuation_model) {
+ case ATTENUATION_INVERSE_DISTANCE: {
+ att = Math::linear2db(1.0 / ((p_distance / unit_size) + 000001));
+ } break;
+ case ATTENUATION_INVERSE_SQUARE_DISTANCE: {
+ float d = (p_distance / unit_size);
+ d *= d;
+ att = Math::linear2db(1.0 / (d + 0.00001));
+ } break;
+ case ATTENUATION_LOGARITHMIC: {
+ att = -20 * Math::log(p_distance / unit_size + 000001);
+ } break;
+ }
+
+ att += unit_db;
+ if (att > max_db) {
+ att = max_db;
+ }
+
+ return att;
+}
+
+void _update_sound() {
+}
+
+void AudioStreamPlayer3D::_notification(int p_what) {
+
+ if (p_what == NOTIFICATION_ENTER_TREE) {
+
+ velocity_tracker->reset(get_global_transform().origin);
+ AudioServer::get_singleton()->add_callback(_mix_audios, this);
+ if (autoplay && !get_tree()->is_editor_hint()) {
+ play();
+ }
+ }
+
+ if (p_what == NOTIFICATION_EXIT_TREE) {
+
+ AudioServer::get_singleton()->remove_callback(_mix_audios, this);
+ }
+ if (p_what == NOTIFICATION_TRANSFORM_CHANGED) {
+
+ if (doppler_tracking != DOPPLER_TRACKING_DISABLED) {
+ velocity_tracker->update_position(get_global_transform().origin);
+ }
+ }
+
+ if (p_what == NOTIFICATION_INTERNAL_FIXED_PROCESS) {
+
+ //update anything related to position first, if possible of course
+
+ if (!output_ready) {
+
+ Vector3 linear_velocity;
+
+ //compute linear velocity for doppler
+ if (doppler_tracking != DOPPLER_TRACKING_DISABLED) {
+ linear_velocity = velocity_tracker->get_tracked_linear_velocity();
+ }
+
+ Ref<World> world = get_world();
+ ERR_FAIL_COND(world.is_null());
+
+ int new_output_count = 0;
+
+ Vector3 global_pos = get_global_transform().origin;
+
+ int bus_index = AudioServer::get_singleton()->thread_find_bus_index(bus);
+
+ //check if any area is diverting sound into a bus
+
+ PhysicsDirectSpaceState *space_state = PhysicsServer::get_singleton()->space_get_direct_state(world->get_space());
+
+ PhysicsDirectSpaceState::ShapeResult sr[MAX_INTERSECT_AREAS];
+
+ int areas = space_state->intersect_point(global_pos, sr, MAX_INTERSECT_AREAS, Set<RID>(), area_mask, PhysicsDirectSpaceState::TYPE_MASK_AREA);
+ Area *area = NULL;
+
+ for (int i = 0; i < areas; i++) {
+ if (!sr[i].collider)
+ continue;
+
+ Area *tarea = sr[i].collider->cast_to<Area>();
+ if (!tarea)
+ continue;
+
+ if (!tarea->is_overriding_audio_bus() && !tarea->is_using_reverb_bus())
+ continue;
+
+ area = tarea;
+ break;
+ }
+
+ List<Camera *> cameras;
+ world->get_camera_list(&cameras);
+
+ for (List<Camera *>::Element *E = cameras.front(); E; E = E->next()) {
+
+ Camera *camera = E->get();
+ Viewport *vp = camera->get_viewport();
+ if (!vp->is_audio_listener())
+ continue;
+
+ Vector3 local_pos = camera->get_global_transform().orthonormalized().affine_inverse().xform(global_pos);
+
+ float dist = local_pos.length();
+
+ Vector3 area_sound_pos;
+ Vector3 cam_area_pos;
+
+ if (area && area->is_using_reverb_bus() && area->get_reverb_uniformity() > 0) {
+ area_sound_pos = space_state->get_closest_point_to_object_volume(area->get_rid(), camera->get_global_transform().origin);
+ cam_area_pos = camera->get_global_transform().affine_inverse().xform(area_sound_pos);
+ }
+
+ if (max_distance > 0) {
+
+ float total_max = max_distance;
+
+ if (area && area->is_using_reverb_bus() && area->get_reverb_uniformity() > 0) {
+ total_max = MAX(total_max, cam_area_pos.length());
+ }
+ if (total_max > max_distance) {
+ continue; //cant hear this sound in this camera
+ }
+ }
+
+ float multiplier = Math::db2linear(_get_attenuation_db(dist));
+ if (max_distance > 0) {
+ multiplier *= MAX(0, 1.0 - (dist / max_distance));
+ }
+
+ Output output;
+ output.bus_index = bus_index;
+ output.reverb_bus_index = -1; //no reverb by default
+ output.viewport = vp;
+
+ float db_att = (1.0 - MIN(1.0, multiplier)) * attenuation_filter_db;
+
+ if (emission_angle_enabled) {
+ Vector3 camtopos = global_pos - camera->get_global_transform().origin;
+ float c = camtopos.normalized().dot(get_global_transform().basis.get_axis(2).normalized()); //it's z negative
+ float angle = Math::rad2deg(Math::acos(c));
+ if (angle > emission_angle)
+ db_att -= -emission_angle_filter_attenuation_db;
+ }
+
+ output.filter_gain = Math::db2linear(db_att);
+
+ Vector3 flat_pos = local_pos;
+ flat_pos.y = 0;
+ flat_pos.normalize();
+
+ switch (AudioServer::get_singleton()->get_speaker_mode()) {
+
+ case AudioServer::SPEAKER_MODE_STEREO: {
+
+ float c = flat_pos.x * 0.5 + 0.5;
+ output.vol[0].l = 1.0 - c;
+ output.vol[0].r = c;
+
+ output.vol[0] *= multiplier;
+
+ } break;
+ case AudioServer::SPEAKER_SURROUND_51: {
+
+ float xl = Vector3(-1, 0, -1).normalized().dot(flat_pos) * 0.5 + 0.5;
+ float xr = Vector3(1, 0, -1).normalized().dot(flat_pos) * 0.5 + 0.5;
+
+ output.vol[0].l = xl;
+ output.vol[1].r = 1.0 - xl;
+ output.vol[0].r = xr;
+ output.vol[1].l = 1.0 - xr;
+
+ output.vol[0] *= multiplier;
+ output.vol[1] *= multiplier;
+ } break;
+ case AudioServer::SPEAKER_SURROUND_71: {
+
+ float xl = Vector3(-1, 0, -1).normalized().dot(flat_pos) * 0.5 + 0.5;
+ float xr = Vector3(1, 0, -1).normalized().dot(flat_pos) * 0.5 + 0.5;
+
+ output.vol[0].l = xl;
+ output.vol[1].r = 1.0 - xl;
+ output.vol[0].r = xr;
+ output.vol[1].l = 1.0 - xr;
+
+ float c = flat_pos.x * 0.5 + 0.5;
+ output.vol[2].l = 1.0 - c;
+ output.vol[2].r = c;
+
+ output.vol[0] *= multiplier;
+ output.vol[1] *= multiplier;
+ output.vol[2] *= multiplier;
+
+ } break;
+ }
+
+ bool filled_reverb = false;
+ int vol_index_max = AudioServer::get_singleton()->get_speaker_mode() + 1;
+
+ if (area) {
+
+ if (area->is_overriding_audio_bus()) {
+ //override audio bus
+ StringName bus_name = area->get_audio_bus();
+ output.bus_index = AudioServer::get_singleton()->thread_find_bus_index(bus_name);
+ }
+
+ if (area->is_using_reverb_bus()) {
+
+ filled_reverb = true;
+ StringName bus_name = area->get_reverb_bus();
+ output.reverb_bus_index = AudioServer::get_singleton()->thread_find_bus_index(bus_name);
+
+ float uniformity = area->get_reverb_uniformity();
+ float area_send = area->get_reverb_amount();
+
+ if (uniformity > 0.0) {
+
+ float distance = cam_area_pos.length();
+ float attenuation = Math::db2linear(_get_attenuation_db(distance));
+
+ //float dist_att_db = -20 * Math::log(dist + 0.00001); //logarithmic attenuation, like in real life
+
+ float center_val[3] = { 0.5, 0.25, 0.16666 };
+ AudioFrame center_frame(center_val[vol_index_max - 1], center_val[vol_index_max - 1]);
+
+ if (attenuation < 1.0) {
+ //pan the uniform sound
+ Vector3 rev_pos = cam_area_pos;
+ rev_pos.y = 0;
+ rev_pos.normalize();
+
+ switch (AudioServer::get_singleton()->get_speaker_mode()) {
+
+ case AudioServer::SPEAKER_MODE_STEREO: {
+
+ float c = rev_pos.x * 0.5 + 0.5;
+ output.reverb_vol[0].l = 1.0 - c;
+ output.reverb_vol[0].r = c;
+
+ } break;
+ case AudioServer::SPEAKER_SURROUND_51: {
+
+ float xl = Vector3(-1, 0, -1).normalized().dot(rev_pos) * 0.5 + 0.5;
+ float xr = Vector3(1, 0, -1).normalized().dot(rev_pos) * 0.5 + 0.5;
+
+ output.reverb_vol[0].l = xl;
+ output.reverb_vol[1].r = 1.0 - xl;
+ output.reverb_vol[0].r = xr;
+ output.reverb_vol[1].l = 1.0 - xr;
+
+ } break;
+ case AudioServer::SPEAKER_SURROUND_71: {
+
+ float xl = Vector3(-1, 0, -1).normalized().dot(rev_pos) * 0.5 + 0.5;
+ float xr = Vector3(1, 0, -1).normalized().dot(rev_pos) * 0.5 + 0.5;
+
+ output.reverb_vol[0].l = xl;
+ output.reverb_vol[1].r = 1.0 - xl;
+ output.reverb_vol[0].r = xr;
+ output.reverb_vol[1].l = 1.0 - xr;
+
+ float c = rev_pos.x * 0.5 + 0.5;
+ output.reverb_vol[2].l = 1.0 - c;
+ output.reverb_vol[2].r = c;
+
+ } break;
+ }
+
+ for (int i = 0; i < vol_index_max; i++) {
+
+ output.reverb_vol[i] = output.reverb_vol[i].linear_interpolate(center_frame, attenuation);
+ }
+ } else {
+ for (int i = 0; i < vol_index_max; i++) {
+
+ output.reverb_vol[i] = center_frame;
+ }
+ }
+
+ for (int i = 0; i < vol_index_max; i++) {
+
+ output.reverb_vol[i] = output.vol[i].linear_interpolate(output.reverb_vol[i] * attenuation, uniformity);
+ output.reverb_vol[i] *= area_send;
+ }
+
+ } else {
+
+ for (int i = 0; i < vol_index_max; i++) {
+
+ output.reverb_vol[i] = output.vol[i] * area_send;
+ }
+ }
+ }
+ }
+
+ if (doppler_tracking != DOPPLER_TRACKING_DISABLED) {
+
+ Vector3 camera_velocity = camera->get_doppler_tracked_velocity();
+
+ Vector3 local_velocity = camera->get_global_transform().orthonormalized().basis.xform_inv(linear_velocity - camera_velocity);
+
+ if (local_velocity == Vector3()) {
+ output.pitch_scale = 1.0;
+ } else {
+ float approaching = local_pos.normalized().dot(local_velocity.normalized());
+ float velocity = local_velocity.length();
+ float speed_of_sound = 343.0;
+
+ output.pitch_scale = speed_of_sound / (speed_of_sound + velocity * approaching);
+ output.pitch_scale = CLAMP(output.pitch_scale, (1 / 8.0), 8.0); //avoid crazy stuff
+ }
+
+ } else {
+ output.pitch_scale = 1.0;
+ }
+
+ if (!filled_reverb) {
+
+ for (int i = 0; i < vol_index_max; i++) {
+
+ output.reverb_vol[i] = AudioFrame(0, 0);
+ }
+ }
+
+ outputs[new_output_count] = output;
+ new_output_count++;
+ if (new_output_count == MAX_OUTPUTS)
+ break;
+ }
+
+ output_count = new_output_count;
+ output_ready = true;
+ }
+
+ //start playing if requested
+ if (setplay >= 0.0) {
+ setseek = setplay;
+ active = true;
+ setplay = -1;
+ _change_notify("playing"); //update property in editor
+ }
+
+ //stop playing if no longer active
+ if (!active) {
+ set_fixed_process_internal(false);
+ _change_notify("playing"); //update property in editor
+ }
+ }
+}
+
+void AudioStreamPlayer3D::set_stream(Ref<AudioStream> p_stream) {
+
+ ERR_FAIL_COND(!p_stream.is_valid());
+ AudioServer::get_singleton()->lock();
+
+ mix_buffer.resize(AudioServer::get_singleton()->thread_get_mix_buffer_size());
+
+ if (stream_playback.is_valid()) {
+ stream_playback.unref();
+ stream.unref();
+ active = false;
+ setseek = -1;
+ }
+
+ stream = p_stream;
+ stream_playback = p_stream->instance_playback();
+
+ if (stream_playback.is_null()) {
+ stream.unref();
+ ERR_FAIL_COND(stream_playback.is_null());
+ }
+
+ AudioServer::get_singleton()->unlock();
+}
+
+Ref<AudioStream> AudioStreamPlayer3D::get_stream() const {
+
+ return stream;
+}
+
+void AudioStreamPlayer3D::set_unit_db(float p_volume) {
+
+ unit_db = p_volume;
+}
+float AudioStreamPlayer3D::get_unit_db() const {
+
+ return unit_db;
+}
+
+void AudioStreamPlayer3D::set_unit_size(float p_volume) {
+
+ unit_size = p_volume;
+}
+float AudioStreamPlayer3D::get_unit_size() const {
+
+ return unit_size;
+}
+
+void AudioStreamPlayer3D::set_max_db(float p_boost) {
+
+ max_db = p_boost;
+}
+float AudioStreamPlayer3D::get_max_db() const {
+
+ return max_db;
+}
+
+void AudioStreamPlayer3D::play(float p_from_pos) {
+
+ if (stream_playback.is_valid()) {
+ setplay = p_from_pos;
+ output_ready = false;
+ set_fixed_process_internal(true);
+ }
+}
+
+void AudioStreamPlayer3D::seek(float p_seconds) {
+
+ if (stream_playback.is_valid()) {
+ setseek = p_seconds;
+ }
+}
+
+void AudioStreamPlayer3D::stop() {
+
+ if (stream_playback.is_valid()) {
+ active = false;
+ set_fixed_process_internal(false);
+ setplay = -1;
+ }
+}
+
+bool AudioStreamPlayer3D::is_playing() const {
+
+ if (stream_playback.is_valid()) {
+ return active; // && stream_playback->is_playing();
+ }
+
+ return false;
+}
+
+float AudioStreamPlayer3D::get_pos() {
+
+ if (stream_playback.is_valid()) {
+ return stream_playback->get_pos();
+ }
+
+ return 0;
+}
+
+void AudioStreamPlayer3D::set_bus(const StringName &p_bus) {
+
+ //if audio is active, must lock this
+ AudioServer::get_singleton()->lock();
+ bus = p_bus;
+ AudioServer::get_singleton()->unlock();
+}
+StringName AudioStreamPlayer3D::get_bus() const {
+
+ for (int i = 0; i < AudioServer::get_singleton()->get_bus_count(); i++) {
+ if (AudioServer::get_singleton()->get_bus_name(i) == bus) {
+ return bus;
+ }
+ }
+ return "Master";
+}
+
+void AudioStreamPlayer3D::set_autoplay(bool p_enable) {
+
+ autoplay = p_enable;
+}
+bool AudioStreamPlayer3D::is_autoplay_enabled() {
+
+ return autoplay;
+}
+
+void AudioStreamPlayer3D::_set_playing(bool p_enable) {
+
+ if (p_enable)
+ play();
+ else
+ stop();
+}
+bool AudioStreamPlayer3D::_is_active() const {
+
+ return active;
+}
+
+void AudioStreamPlayer3D::_validate_property(PropertyInfo &property) const {
+
+ if (property.name == "bus") {
+
+ String options;
+ for (int i = 0; i < AudioServer::get_singleton()->get_bus_count(); i++) {
+ if (i > 0)
+ options += ",";
+ String name = AudioServer::get_singleton()->get_bus_name(i);
+ options += name;
+ }
+
+ property.hint_string = options;
+ }
+}
+
+void AudioStreamPlayer3D::_bus_layout_changed() {
+
+ _change_notify();
+}
+
+void AudioStreamPlayer3D::set_max_distance(float p_metres) {
+
+ ERR_FAIL_COND(p_metres < 0.0);
+ max_distance = p_metres;
+}
+
+float AudioStreamPlayer3D::get_max_distance() const {
+
+ return max_distance;
+}
+
+void AudioStreamPlayer3D::set_area_mask(uint32_t p_mask) {
+
+ area_mask = p_mask;
+}
+
+uint32_t AudioStreamPlayer3D::get_area_mask() const {
+
+ return area_mask;
+}
+
+void AudioStreamPlayer3D::set_emission_angle_enabled(bool p_enable) {
+ emission_angle_enabled = p_enable;
+ update_gizmo();
+}
+
+bool AudioStreamPlayer3D::is_emission_angle_enabled() const {
+ return emission_angle_enabled;
+}
+
+void AudioStreamPlayer3D::set_emission_angle(float p_angle) {
+ ERR_FAIL_COND(p_angle < 0 || p_angle > 90);
+ emission_angle = p_angle;
+ update_gizmo();
+}
+
+float AudioStreamPlayer3D::get_emission_angle() const {
+ return emission_angle;
+}
+
+void AudioStreamPlayer3D::set_emission_angle_filter_attenuation_db(float p_angle_attenuation_db) {
+
+ emission_angle_filter_attenuation_db = p_angle_attenuation_db;
+}
+
+float AudioStreamPlayer3D::get_emission_angle_filter_attenuation_db() const {
+
+ return emission_angle_filter_attenuation_db;
+}
+
+void AudioStreamPlayer3D::set_attenuation_filter_cutoff_hz(float p_hz) {
+
+ attenuation_filter_cutoff_hz = p_hz;
+}
+float AudioStreamPlayer3D::get_attenuation_filter_cutoff_hz() const {
+
+ return attenuation_filter_cutoff_hz;
+}
+
+void AudioStreamPlayer3D::set_attenuation_filter_db(float p_db) {
+
+ attenuation_filter_db = p_db;
+}
+float AudioStreamPlayer3D::get_attenuation_filter_db() const {
+
+ return attenuation_filter_db;
+}
+
+void AudioStreamPlayer3D::set_attenuation_model(AttenuationModel p_model) {
+ ERR_FAIL_INDEX(p_model, 3);
+ attenuation_model = p_model;
+}
+
+AudioStreamPlayer3D::AttenuationModel AudioStreamPlayer3D::get_attenuation_model() const {
+ return attenuation_model;
+}
+
+void AudioStreamPlayer3D::set_out_of_range_mode(OutOfRangeMode p_mode) {
+
+ ERR_FAIL_INDEX(p_mode, 2);
+ out_of_range_mode = p_mode;
+}
+
+AudioStreamPlayer3D::OutOfRangeMode AudioStreamPlayer3D::get_out_of_range_mode() const {
+
+ return out_of_range_mode;
+}
+
+void AudioStreamPlayer3D::set_doppler_tracking(DopplerTracking p_tracking) {
+
+ if (doppler_tracking == p_tracking)
+ return;
+
+ doppler_tracking = p_tracking;
+
+ if (doppler_tracking != DOPPLER_TRACKING_DISABLED) {
+ set_notify_transform(true);
+ velocity_tracker->set_track_fixed_step(doppler_tracking == DOPPLER_TRACKING_FIXED_STEP);
+ velocity_tracker->reset(get_global_transform().origin);
+ } else {
+ set_notify_transform(false);
+ }
+}
+
+AudioStreamPlayer3D::DopplerTracking AudioStreamPlayer3D::get_doppler_tracking() const {
+
+ return doppler_tracking;
+}
+
+void AudioStreamPlayer3D::_bind_methods() {
+
+ ClassDB::bind_method(D_METHOD("set_stream", "stream:AudioStream"), &AudioStreamPlayer3D::set_stream);
+ ClassDB::bind_method(D_METHOD("get_stream"), &AudioStreamPlayer3D::get_stream);
+
+ ClassDB::bind_method(D_METHOD("set_unit_db", "unit_db"), &AudioStreamPlayer3D::set_unit_db);
+ ClassDB::bind_method(D_METHOD("get_unit_db"), &AudioStreamPlayer3D::get_unit_db);
+
+ ClassDB::bind_method(D_METHOD("set_unit_size", "unit_size"), &AudioStreamPlayer3D::set_unit_size);
+ ClassDB::bind_method(D_METHOD("get_unit_size"), &AudioStreamPlayer3D::get_unit_size);
+
+ ClassDB::bind_method(D_METHOD("set_max_db", "max_db"), &AudioStreamPlayer3D::set_max_db);
+ ClassDB::bind_method(D_METHOD("get_max_db"), &AudioStreamPlayer3D::get_max_db);
+
+ ClassDB::bind_method(D_METHOD("play", "from_pos"), &AudioStreamPlayer3D::play, DEFVAL(0.0));
+ ClassDB::bind_method(D_METHOD("seek", "to_pos"), &AudioStreamPlayer3D::seek);
+ ClassDB::bind_method(D_METHOD("stop"), &AudioStreamPlayer3D::stop);
+
+ ClassDB::bind_method(D_METHOD("is_playing"), &AudioStreamPlayer3D::is_playing);
+ ClassDB::bind_method(D_METHOD("get_pos"), &AudioStreamPlayer3D::get_pos);
+
+ ClassDB::bind_method(D_METHOD("set_bus", "bus"), &AudioStreamPlayer3D::set_bus);
+ ClassDB::bind_method(D_METHOD("get_bus"), &AudioStreamPlayer3D::get_bus);
+
+ ClassDB::bind_method(D_METHOD("set_autoplay", "enable"), &AudioStreamPlayer3D::set_autoplay);
+ ClassDB::bind_method(D_METHOD("is_autoplay_enabled"), &AudioStreamPlayer3D::is_autoplay_enabled);
+
+ ClassDB::bind_method(D_METHOD("_set_playing", "enable"), &AudioStreamPlayer3D::_set_playing);
+ ClassDB::bind_method(D_METHOD("_is_active"), &AudioStreamPlayer3D::_is_active);
+
+ ClassDB::bind_method(D_METHOD("set_max_distance", "metres"), &AudioStreamPlayer3D::set_max_distance);
+ ClassDB::bind_method(D_METHOD("get_max_distance"), &AudioStreamPlayer3D::get_max_distance);
+
+ ClassDB::bind_method(D_METHOD("set_area_mask", "mask"), &AudioStreamPlayer3D::set_area_mask);
+ ClassDB::bind_method(D_METHOD("get_area_mask"), &AudioStreamPlayer3D::get_area_mask);
+
+ ClassDB::bind_method(D_METHOD("set_emission_angle", "degrees"), &AudioStreamPlayer3D::set_emission_angle);
+ ClassDB::bind_method(D_METHOD("get_emission_angle"), &AudioStreamPlayer3D::get_emission_angle);
+
+ ClassDB::bind_method(D_METHOD("set_emission_angle_enabled", "enabled"), &AudioStreamPlayer3D::set_emission_angle_enabled);
+ ClassDB::bind_method(D_METHOD("is_emission_angle_enabled"), &AudioStreamPlayer3D::is_emission_angle_enabled);
+
+ ClassDB::bind_method(D_METHOD("set_emission_angle_filter_attenuation_db", "db"), &AudioStreamPlayer3D::set_emission_angle_filter_attenuation_db);
+ ClassDB::bind_method(D_METHOD("get_emission_angle_filter_attenuation_db"), &AudioStreamPlayer3D::get_emission_angle_filter_attenuation_db);
+
+ ClassDB::bind_method(D_METHOD("set_attenuation_filter_cutoff_hz", "degrees"), &AudioStreamPlayer3D::set_attenuation_filter_cutoff_hz);
+ ClassDB::bind_method(D_METHOD("get_attenuation_filter_cutoff_hz"), &AudioStreamPlayer3D::get_attenuation_filter_cutoff_hz);
+
+ ClassDB::bind_method(D_METHOD("set_attenuation_filter_db", "db"), &AudioStreamPlayer3D::set_attenuation_filter_db);
+ ClassDB::bind_method(D_METHOD("get_attenuation_filter_db"), &AudioStreamPlayer3D::get_attenuation_filter_db);
+
+ ClassDB::bind_method(D_METHOD("set_attenuation_model", "model"), &AudioStreamPlayer3D::set_attenuation_model);
+ ClassDB::bind_method(D_METHOD("get_attenuation_model"), &AudioStreamPlayer3D::get_attenuation_model);
+
+ ClassDB::bind_method(D_METHOD("set_out_of_range_mode", "mode"), &AudioStreamPlayer3D::set_out_of_range_mode);
+ ClassDB::bind_method(D_METHOD("get_out_of_range_mode"), &AudioStreamPlayer3D::get_out_of_range_mode);
+
+ ClassDB::bind_method(D_METHOD("set_doppler_tracking", "mode"), &AudioStreamPlayer3D::set_doppler_tracking);
+ ClassDB::bind_method(D_METHOD("get_doppler_tracking"), &AudioStreamPlayer3D::get_doppler_tracking);
+
+ ClassDB::bind_method(D_METHOD("_bus_layout_changed"), &AudioStreamPlayer3D::_bus_layout_changed);
+
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "stream", PROPERTY_HINT_RESOURCE_TYPE, "AudioStream"), "set_stream", "get_stream");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "attenuation_model", PROPERTY_HINT_ENUM, "Inverse,InverseSquare,Log"), "set_attenuation_model", "get_attenuation_model");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "unit_db", PROPERTY_HINT_RANGE, "-80,80"), "set_unit_db", "get_unit_db");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "unit_size", PROPERTY_HINT_RANGE, "0.1,100,0.1"), "set_unit_size", "get_unit_size");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "max_db", PROPERTY_HINT_RANGE, "-24,6"), "set_max_db", "get_max_db");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "playing", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "_set_playing", "_is_active");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "autoplay"), "set_autoplay", "is_autoplay_enabled");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "max_distance", PROPERTY_HINT_RANGE, "0,65536,1"), "set_max_distance", "get_max_distance");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "out_of_range_mode", PROPERTY_HINT_ENUM, "Mix,Pause"), "set_out_of_range_mode", "get_out_of_range_mode");
+ ADD_PROPERTY(PropertyInfo(Variant::STRING, "bus", PROPERTY_HINT_ENUM, ""), "set_bus", "get_bus");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "area_mask", PROPERTY_HINT_LAYERS_2D_PHYSICS), "set_area_mask", "get_area_mask");
+ ADD_GROUP("Emission Angle", "emission_angle");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "emission_angle_enabled"), "set_emission_angle_enabled", "is_emission_angle_enabled");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "emission_angle_degrees", PROPERTY_HINT_RANGE, "0.1,90,0.1"), "set_emission_angle", "get_emission_angle");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "emission_angle_filter_attenuation_db", PROPERTY_HINT_RANGE, "-80,0,0.1"), "set_emission_angle_filter_attenuation_db", "get_emission_angle_filter_attenuation_db");
+ ADD_GROUP("Attenuation Filter", "attenuation_filter_");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "attenuation_filter_cutoff_hz", PROPERTY_HINT_RANGE, "50,50000,1"), "set_attenuation_filter_cutoff_hz", "get_attenuation_filter_cutoff_hz");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "attenuation_filter_db", PROPERTY_HINT_RANGE, "-80,0,0.1"), "set_attenuation_filter_db", "get_attenuation_filter_db");
+ ADD_GROUP("Doppler", "doppler_");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "doppler_tracking", PROPERTY_HINT_ENUM, "Disabled,Idle,Fixed"), "set_doppler_tracking", "get_doppler_tracking");
+
+ BIND_CONSTANT(ATTENUATION_INVERSE_DISTANCE);
+ BIND_CONSTANT(ATTENUATION_INVERSE_SQUARE_DISTANCE);
+ BIND_CONSTANT(ATTENUATION_LOGARITHMIC);
+
+ BIND_CONSTANT(OUT_OF_RANGE_MIX);
+ BIND_CONSTANT(OUT_OF_RANGE_PAUSE);
+
+ BIND_CONSTANT(DOPPLER_TRACKING_DISABLED);
+ BIND_CONSTANT(DOPPLER_TRACKING_IDLE_STEP);
+ BIND_CONSTANT(DOPPLER_TRACKING_FIXED_STEP);
+}
+
+AudioStreamPlayer3D::AudioStreamPlayer3D() {
+
+ unit_db = 0;
+ unit_size = 1;
+ attenuation_model = ATTENUATION_INVERSE_DISTANCE;
+ max_db = 3;
+ autoplay = false;
+ setseek = -1;
+ active = false;
+ output_count = 0;
+ prev_output_count = 0;
+ max_distance = 0;
+ setplay = -1;
+ output_ready = false;
+ area_mask = 1;
+ emission_angle = 45;
+ emission_angle_enabled = false;
+ emission_angle_filter_attenuation_db = -12;
+ attenuation_filter_cutoff_hz = 5000;
+ attenuation_filter_db = -24;
+ out_of_range_mode = OUT_OF_RANGE_MIX;
+ doppler_tracking = DOPPLER_TRACKING_DISABLED;
+
+ velocity_tracker.instance();
+ AudioServer::get_singleton()->connect("bus_layout_changed", this, "_bus_layout_changed");
+}
+AudioStreamPlayer3D::~AudioStreamPlayer3D() {
+}
diff --git a/scene/3d/audio_stream_player_3d.h b/scene/3d/audio_stream_player_3d.h
new file mode 100644
index 0000000000..8603cab5a4
--- /dev/null
+++ b/scene/3d/audio_stream_player_3d.h
@@ -0,0 +1,175 @@
+#ifndef AUDIO_STREAM_PLAYER_3D_H
+#define AUDIO_STREAM_PLAYER_3D_H
+
+#include "scene/3d/spatial.h"
+#include "scene/3d/spatial_velocity_tracker.h"
+#include "servers/audio/audio_filter_sw.h"
+#include "servers/audio/audio_stream.h"
+#include "servers/audio_server.h"
+
+class Camera;
+class AudioStreamPlayer3D : public Spatial {
+
+ GDCLASS(AudioStreamPlayer3D, Spatial)
+public:
+ enum AttenuationModel {
+ ATTENUATION_INVERSE_DISTANCE,
+ ATTENUATION_INVERSE_SQUARE_DISTANCE,
+ ATTENUATION_LOGARITHMIC,
+ };
+
+ enum OutOfRangeMode {
+ OUT_OF_RANGE_MIX,
+ OUT_OF_RANGE_PAUSE,
+ };
+
+ enum DopplerTracking {
+ DOPPLER_TRACKING_DISABLED,
+ DOPPLER_TRACKING_IDLE_STEP,
+ DOPPLER_TRACKING_FIXED_STEP
+ };
+
+private:
+ enum {
+ MAX_OUTPUTS = 8,
+ MAX_INTERSECT_AREAS = 32
+
+ };
+
+ struct Output {
+
+ AudioFilterSW filter;
+ AudioFilterSW::Processor filter_process[6];
+ AudioFrame vol[3];
+ float filter_gain;
+ float pitch_scale;
+ int bus_index;
+ int reverb_bus_index;
+ AudioFrame reverb_vol[3];
+ Viewport *viewport; //pointer only used for reference to previous mix
+
+ Output() {
+ filter_gain = 0;
+ viewport = NULL;
+ reverb_bus_index = -1;
+ bus_index = -1;
+ }
+ };
+
+ Output outputs[MAX_OUTPUTS];
+ volatile int output_count;
+ volatile bool output_ready;
+
+ //these are used by audio thread to have a reference of previous volumes (for ramping volume and avoiding clicks)
+ Output prev_outputs[MAX_OUTPUTS];
+ int prev_output_count;
+
+ Ref<AudioStreamPlayback> stream_playback;
+ Ref<AudioStream> stream;
+ Vector<AudioFrame> mix_buffer;
+
+ volatile float setseek;
+ volatile bool active;
+ volatile float setplay;
+
+ AttenuationModel attenuation_model;
+ float unit_db;
+ float unit_size;
+ float max_db;
+ bool autoplay;
+ StringName bus;
+
+ void _mix_audio();
+ static void _mix_audios(void *self) { reinterpret_cast<AudioStreamPlayer3D *>(self)->_mix_audio(); }
+
+ void _set_playing(bool p_enable);
+ bool _is_active() const;
+
+ void _bus_layout_changed();
+
+ uint32_t area_mask;
+
+ bool emission_angle_enabled;
+ float emission_angle;
+ float emission_angle_filter_attenuation_db;
+ float attenuation_filter_cutoff_hz;
+ float attenuation_filter_db;
+
+ float max_distance;
+
+ Ref<SpatialVelocityTracker> velocity_tracker;
+
+ DopplerTracking doppler_tracking;
+
+ OutOfRangeMode out_of_range_mode;
+
+ float _get_attenuation_db(float p_distance) const;
+
+protected:
+ void _validate_property(PropertyInfo &property) const;
+ void _notification(int p_what);
+ static void _bind_methods();
+
+public:
+ void set_stream(Ref<AudioStream> p_stream);
+ Ref<AudioStream> get_stream() const;
+
+ void set_unit_db(float p_volume);
+ float get_unit_db() const;
+
+ void set_unit_size(float p_volume);
+ float get_unit_size() const;
+
+ void set_max_db(float p_boost);
+ float get_max_db() const;
+
+ void play(float p_from_pos = 0.0);
+ void seek(float p_seconds);
+ void stop();
+ bool is_playing() const;
+ float get_pos();
+
+ void set_bus(const StringName &p_bus);
+ StringName get_bus() const;
+
+ void set_autoplay(bool p_enable);
+ bool is_autoplay_enabled();
+
+ void set_max_distance(float p_metres);
+ float get_max_distance() const;
+
+ void set_area_mask(uint32_t p_mask);
+ uint32_t get_area_mask() const;
+
+ void set_emission_angle_enabled(bool p_enable);
+ bool is_emission_angle_enabled() const;
+
+ void set_emission_angle(float p_angle);
+ float get_emission_angle() const;
+
+ void set_emission_angle_filter_attenuation_db(float p_angle_attenuation_db);
+ float get_emission_angle_filter_attenuation_db() const;
+
+ void set_attenuation_filter_cutoff_hz(float p_hz);
+ float get_attenuation_filter_cutoff_hz() const;
+
+ void set_attenuation_filter_db(float p_db);
+ float get_attenuation_filter_db() const;
+
+ void set_attenuation_model(AttenuationModel p_model);
+ AttenuationModel get_attenuation_model() const;
+
+ void set_out_of_range_mode(OutOfRangeMode p_mode);
+ OutOfRangeMode get_out_of_range_mode() const;
+
+ void set_doppler_tracking(DopplerTracking p_tracking);
+ DopplerTracking get_doppler_tracking() const;
+
+ AudioStreamPlayer3D();
+ ~AudioStreamPlayer3D();
+};
+
+VARIANT_ENUM_CAST(AudioStreamPlayer3D::AttenuationModel)
+VARIANT_ENUM_CAST(AudioStreamPlayer3D::OutOfRangeMode)
+VARIANT_ENUM_CAST(AudioStreamPlayer3D::DopplerTracking)
+#endif // AUDIO_STREAM_PLAYER_3D_H
diff --git a/scene/3d/body_shape.cpp b/scene/3d/body_shape.cpp
deleted file mode 100644
index 68f166c5b9..0000000000
--- a/scene/3d/body_shape.cpp
+++ /dev/null
@@ -1,920 +0,0 @@
-/*************************************************************************/
-/* body_shape.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-#include "body_shape.h"
-#include "scene/resources/box_shape.h"
-#include "scene/resources/capsule_shape.h"
-#include "scene/resources/concave_polygon_shape.h"
-#include "scene/resources/convex_polygon_shape.h"
-#include "scene/resources/plane_shape.h"
-#include "scene/resources/ray_shape.h"
-#include "scene/resources/sphere_shape.h"
-#include "servers/visual_server.h"
-//TODO: Implement CylinderShape and HeightMapShape?
-#include "mesh_instance.h"
-#include "physics_body.h"
-#include "quick_hull.h"
-
-void CollisionShape::_update_body() {
-
- if (!is_inside_tree() || !can_update_body)
- return;
- if (!get_tree()->is_editor_hint())
- return;
- if (get_parent() && get_parent()->cast_to<CollisionObject>())
- get_parent()->cast_to<CollisionObject>()->_update_shapes_from_children();
-}
-
-void CollisionShape::make_convex_from_brothers() {
-
- Node *p = get_parent();
- if (!p)
- return;
-
- for (int i = 0; i < p->get_child_count(); i++) {
-
- Node *n = p->get_child(i);
- if (n->cast_to<MeshInstance>()) {
-
- MeshInstance *mi = n->cast_to<MeshInstance>();
- Ref<Mesh> m = mi->get_mesh();
- if (m.is_valid()) {
-
- Ref<Shape> s = m->create_convex_shape();
- set_shape(s);
- }
- }
- }
-}
-/*
-
-void CollisionShape::_update_indicator() {
-
- while (VisualServer::get_singleton()->mesh_get_surface_count(indicator))
- VisualServer::get_singleton()->mesh_remove_surface(indicator,0);
-
- if (shape.is_null())
- return;
-
- PoolVector<Vector3> points;
- PoolVector<Vector3> normals;
-
- VS::PrimitiveType pt = VS::PRIMITIVE_TRIANGLES;
-
- if (shape->cast_to<RayShape>()) {
-
- RayShape *rs = shape->cast_to<RayShape>();
- points.push_back(Vector3());
- points.push_back(Vector3(0,0,rs->get_length()));
- pt = VS::PRIMITIVE_LINES;
- } else if (shape->cast_to<SphereShape>()) {
-
- //VisualServer *vs=VisualServer::get_singleton();
- SphereShape *shapeptr=shape->cast_to<SphereShape>();
-
-
- Color col(0.4,1.0,1.0,0.5);
-
- int lats=6;
- int lons=12;
- float size=shapeptr->get_radius();
-
-
- for(int i = 1; i <= lats; i++) {
- double lat0 = Math_PI * (-0.5 + (double) (i - 1) / lats);
- double z0 = Math::sin(lat0);
- double zr0 = Math::cos(lat0);
-
- double lat1 = Math_PI * (-0.5 + (double) i / lats);
- double z1 = Math::sin(lat1);
- double zr1 = Math::cos(lat1);
-
- for(int j = lons; j >= 1; j--) {
-
- double lng0 = 2 * Math_PI * (double) (j - 1) / lons;
- double x0 = Math::cos(lng0);
- double y0 = Math::sin(lng0);
-
- double lng1 = 2 * Math_PI * (double) (j) / lons;
- double x1 = Math::cos(lng1);
- double y1 = Math::sin(lng1);
-
- Vector3 v4=Vector3(x0 * zr0, z0, y0 *zr0)*size;
- Vector3 v3=Vector3(x0 * zr1, z1, y0 *zr1)*size;
- Vector3 v2=Vector3(x1 * zr1, z1, y1 *zr1)*size;
- Vector3 v1=Vector3(x1 * zr0, z0, y1 *zr0)*size;
-
- Vector<Vector3> line;
- line.push_back(v1);
- line.push_back(v2);
- line.push_back(v3);
- line.push_back(v4);
-
-
- points.push_back(v1);
- points.push_back(v2);
- points.push_back(v3);
-
- points.push_back(v1);
- points.push_back(v3);
- points.push_back(v4);
-
- normals.push_back(v1.normalized());
- normals.push_back(v2.normalized());
- normals.push_back(v3.normalized());
-
- normals.push_back(v1.normalized());
- normals.push_back(v3.normalized());
- normals.push_back(v4.normalized());
-
- }
- }
- } else if (shape->cast_to<BoxShape>()) {
-
- BoxShape *shapeptr=shape->cast_to<BoxShape>();
-
- for (int i=0;i<6;i++) {
-
-
- Vector3 face_points[4];
-
-
- for (int j=0;j<4;j++) {
-
- float v[3];
- v[0]=1.0;
- v[1]=1-2*((j>>1)&1);
- v[2]=v[1]*(1-2*(j&1));
-
- for (int k=0;k<3;k++) {
-
- if (i<3)
- face_points[j][(i+k)%3]=v[k]*(i>=3?-1:1);
- else
- face_points[3-j][(i+k)%3]=v[k]*(i>=3?-1:1);
- }
- }
- Vector3 normal;
- normal[i%3]=(i>=3?-1:1);
-
- for(int j=0;j<4;j++)
- face_points[j]*=shapeptr->get_extents();
-
- points.push_back(face_points[0]);
- points.push_back(face_points[1]);
- points.push_back(face_points[2]);
-
- points.push_back(face_points[0]);
- points.push_back(face_points[2]);
- points.push_back(face_points[3]);
-
- for(int n=0;n<6;n++)
- normals.push_back(normal);
-
- }
-
- } else if (shape->cast_to<ConvexPolygonShape>()) {
-
- ConvexPolygonShape *shapeptr=shape->cast_to<ConvexPolygonShape>();
-
- Geometry::MeshData md;
- QuickHull::build(Variant(shapeptr->get_points()),md);
-
- for(int i=0;i<md.faces.size();i++) {
-
- for(int j=2;j<md.faces[i].indices.size();j++) {
- points.push_back(md.vertices[md.faces[i].indices[0]]);
- points.push_back(md.vertices[md.faces[i].indices[j-1]]);
- points.push_back(md.vertices[md.faces[i].indices[j]]);
- normals.push_back(md.faces[i].plane.normal);
- normals.push_back(md.faces[i].plane.normal);
- normals.push_back(md.faces[i].plane.normal);
- }
- }
- } else if (shape->cast_to<ConcavePolygonShape>()) {
-
- ConcavePolygonShape *shapeptr=shape->cast_to<ConcavePolygonShape>();
-
- points = shapeptr->get_faces();
- for(int i=0;i<points.size()/3;i++) {
-
- Vector3 n = Plane( points[i*3+0],points[i*3+1],points[i*3+2] ).normal;
- normals.push_back(n);
- normals.push_back(n);
- normals.push_back(n);
- }
-
- } else if (shape->cast_to<CapsuleShape>()) {
-
- CapsuleShape *shapeptr=shape->cast_to<CapsuleShape>();
-
- PoolVector<Plane> planes = Geometry::build_capsule_planes(shapeptr->get_radius(), shapeptr->get_height()/2.0, 12, Vector3::AXIS_Z);
- Geometry::MeshData md = Geometry::build_convex_mesh(planes);
-
- for(int i=0;i<md.faces.size();i++) {
-
- for(int j=2;j<md.faces[i].indices.size();j++) {
- points.push_back(md.vertices[md.faces[i].indices[0]]);
- points.push_back(md.vertices[md.faces[i].indices[j-1]]);
- points.push_back(md.vertices[md.faces[i].indices[j]]);
- normals.push_back(md.faces[i].plane.normal);
- normals.push_back(md.faces[i].plane.normal);
- normals.push_back(md.faces[i].plane.normal);
-
- }
- }
-
- } else if (shape->cast_to<PlaneShape>()) {
-
- PlaneShape *shapeptr=shape->cast_to<PlaneShape>();
-
- Plane p = shapeptr->get_plane();
- Vector3 n1 = p.get_any_perpendicular_normal();
- Vector3 n2 = p.normal.cross(n1).normalized();
-
- Vector3 pface[4]={
- p.normal*p.d+n1*100.0+n2*100.0,
- p.normal*p.d+n1*100.0+n2*-100.0,
- p.normal*p.d+n1*-100.0+n2*-100.0,
- p.normal*p.d+n1*-100.0+n2*100.0,
- };
-
- points.push_back(pface[0]);
- points.push_back(pface[1]);
- points.push_back(pface[2]);
-
- points.push_back(pface[0]);
- points.push_back(pface[2]);
- points.push_back(pface[3]);
-
- normals.push_back(p.normal);
- normals.push_back(p.normal);
- normals.push_back(p.normal);
- normals.push_back(p.normal);
- normals.push_back(p.normal);
- normals.push_back(p.normal);
-
- }
-
- if (!points.size())
- return;
- RID material = VisualServer::get_singleton()->fixed_material_create();
- VisualServer::get_singleton()->fixed_material_set_param(material,VS::FIXED_MATERIAL_PARAM_DIFFUSE,Color(0,0.6,0.7,0.3));
- VisualServer::get_singleton()->fixed_material_set_param(material,VS::FIXED_MATERIAL_PARAM_EMISSION,0.7);
- if (normals.size()==0)
- VisualServer::get_singleton()->material_set_flag(material,VS::MATERIAL_FLAG_UNSHADED,true);
- VisualServer::get_singleton()->material_set_flag(material,VS::MATERIAL_FLAG_DOUBLE_SIDED,true);
- Array d;
- d.resize(VS::ARRAY_MAX);
- d[VS::ARRAY_VERTEX]=points;
- if (normals.size())
- d[VS::ARRAY_NORMAL]=normals;
- VisualServer::get_singleton()->mesh_add_surface(indicator,pt,d);
- VisualServer::get_singleton()->mesh_surface_set_material(indicator,0,material,true);
-
-}
-
-*/
-void CollisionShape::_add_to_collision_object(Object *p_cshape) {
-
- if (unparenting)
- return;
-
- CollisionObject *co = p_cshape->cast_to<CollisionObject>();
- ERR_FAIL_COND(!co);
-
- if (shape.is_valid()) {
-
- update_shape_index = co->get_shape_count();
- co->add_shape(shape, get_transform());
- if (trigger)
- co->set_shape_as_trigger(co->get_shape_count() - 1, true);
- } else {
- update_shape_index = -1;
- }
-}
-
-void CollisionShape::_notification(int p_what) {
-
- switch (p_what) {
-
- case NOTIFICATION_ENTER_TREE: {
- unparenting = false;
- can_update_body = get_tree()->is_editor_hint();
- set_notify_local_transform(!can_update_body);
-
- if (get_tree()->is_debugging_collisions_hint()) {
- _create_debug_shape();
- }
-
- //indicator_instance = VisualServer::get_singleton()->instance_create2(indicator,get_world()->get_scenario());
- } break;
- case NOTIFICATION_TRANSFORM_CHANGED: {
- //VisualServer::get_singleton()->instance_set_transform(indicator_instance,get_global_transform());
- if (can_update_body && updating_body) {
- _update_body();
- }
- } break;
- case NOTIFICATION_EXIT_TREE: {
- /* if (indicator_instance.is_valid()) {
- VisualServer::get_singleton()->free(indicator_instance);
- indicator_instance=RID();
- }*/
- can_update_body = false;
- set_notify_local_transform(false);
- if (debug_shape) {
- debug_shape->queue_delete();
- debug_shape = NULL;
- }
- } break;
- case NOTIFICATION_UNPARENTED: {
- unparenting = true;
- if (can_update_body && updating_body)
- _update_body();
- } break;
- case NOTIFICATION_PARENTED: {
- if (can_update_body && updating_body)
- _update_body();
- } break;
- case NOTIFICATION_LOCAL_TRANSFORM_CHANGED: {
-
- if (!can_update_body && update_shape_index >= 0) {
-
- CollisionObject *co = get_parent()->cast_to<CollisionObject>();
- if (co) {
- co->set_shape_transform(update_shape_index, get_transform());
- }
- }
-
- } break;
- }
-}
-
-void CollisionShape::resource_changed(RES res) {
-
- update_gizmo();
-}
-
-void CollisionShape::_set_update_shape_index(int p_index) {
-
- update_shape_index = p_index;
-}
-
-int CollisionShape::_get_update_shape_index() const {
-
- return update_shape_index;
-}
-
-String CollisionShape::get_configuration_warning() const {
-
- if (!get_parent()->cast_to<CollisionObject>()) {
- return TTR("CollisionShape only serves to provide a collision shape to a CollisionObject derived node. Please only use it as a child of Area, StaticBody, RigidBody, KinematicBody, etc. to give them a shape.");
- }
-
- if (!shape.is_valid()) {
- return TTR("A shape must be provided for CollisionShape to function. Please create a shape resource for it!");
- }
-
- return String();
-}
-
-void CollisionShape::_bind_methods() {
-
- //not sure if this should do anything
- ClassDB::bind_method(D_METHOD("resource_changed", "resource"), &CollisionShape::resource_changed);
- ClassDB::bind_method(D_METHOD("set_shape", "shape"), &CollisionShape::set_shape);
- ClassDB::bind_method(D_METHOD("get_shape"), &CollisionShape::get_shape);
- ClassDB::bind_method(D_METHOD("_add_to_collision_object"), &CollisionShape::_add_to_collision_object);
- ClassDB::bind_method(D_METHOD("set_trigger", "enable"), &CollisionShape::set_trigger);
- ClassDB::bind_method(D_METHOD("is_trigger"), &CollisionShape::is_trigger);
- ClassDB::bind_method(D_METHOD("make_convex_from_brothers"), &CollisionShape::make_convex_from_brothers);
- ClassDB::set_method_flags("CollisionShape", "make_convex_from_brothers", METHOD_FLAGS_DEFAULT | METHOD_FLAG_EDITOR);
- ClassDB::bind_method(D_METHOD("_set_update_shape_index", "index"), &CollisionShape::_set_update_shape_index);
- ClassDB::bind_method(D_METHOD("_get_update_shape_index"), &CollisionShape::_get_update_shape_index);
-
- ClassDB::bind_method(D_METHOD("get_collision_object_shape_index"), &CollisionShape::get_collision_object_shape_index);
-
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "shape", PROPERTY_HINT_RESOURCE_TYPE, "Shape"), "set_shape", "get_shape");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "trigger"), "set_trigger", "is_trigger");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "_update_shape_index", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "_set_update_shape_index", "_get_update_shape_index");
-}
-
-void CollisionShape::set_shape(const Ref<Shape> &p_shape) {
-
- if (!shape.is_null())
- shape->unregister_owner(this);
- shape = p_shape;
- if (!shape.is_null())
- shape->register_owner(this);
- update_gizmo();
- if (updating_body) {
- _update_body();
- } else if (can_update_body && update_shape_index >= 0 && is_inside_tree()) {
- CollisionObject *co = get_parent()->cast_to<CollisionObject>();
- if (co) {
- co->set_shape(update_shape_index, p_shape);
- }
- }
-}
-
-Ref<Shape> CollisionShape::get_shape() const {
-
- return shape;
-}
-
-void CollisionShape::set_updating_body(bool p_update) {
- updating_body = p_update;
-}
-
-bool CollisionShape::is_updating_body() const {
-
- return updating_body;
-}
-
-void CollisionShape::set_trigger(bool p_trigger) {
-
- trigger = p_trigger;
- if (updating_body) {
- _update_body();
- } else if (can_update_body && update_shape_index >= 0 && is_inside_tree()) {
- CollisionObject *co = get_parent()->cast_to<CollisionObject>();
- if (co) {
- co->set_shape_as_trigger(update_shape_index, p_trigger);
- }
- }
-}
-
-bool CollisionShape::is_trigger() const {
-
- return trigger;
-}
-
-CollisionShape::CollisionShape() {
-
- //indicator = VisualServer::get_singleton()->mesh_create();
- updating_body = true;
- unparenting = false;
- update_shape_index = -1;
- trigger = false;
- can_update_body = false;
- debug_shape = NULL;
-}
-
-CollisionShape::~CollisionShape() {
- if (!shape.is_null())
- shape->unregister_owner(this);
- //VisualServer::get_singleton()->free(indicator);
-}
-
-void CollisionShape::_create_debug_shape() {
-
- if (debug_shape) {
- debug_shape->queue_delete();
- debug_shape = NULL;
- }
-
- Ref<Shape> s = get_shape();
-
- if (s.is_null())
- return;
-
- Ref<Mesh> mesh = s->get_debug_mesh();
-
- MeshInstance *mi = memnew(MeshInstance);
- mi->set_mesh(mesh);
-
- add_child(mi);
- debug_shape = mi;
-}
-
-#if 0
-#include "body_volume.h"
-
-#include "geometry.h"
-#include "scene/3d/physics_body.h"
-
-#define ADD_TRIANGLE(m_a, m_b, m_c, m_color) \
- { \
- Vector<Vector3> points; \
- points.resize(3); \
- points[0] = m_a; \
- points[1] = m_b; \
- points[2] = m_c; \
- Vector<Color> colors; \
- colors.resize(3); \
- colors[0] = m_color; \
- colors[1] = m_color; \
- colors[2] = m_color; \
- vs->poly_add_primitive(p_indicator, points, Vector<Vector3>(), colors, Vector<Vector3>()); \
- }
-
-
-void CollisionShape::_notification(int p_what) {
-
- switch (p_what) {
- case NOTIFICATION_ENTER_SCENE: {
-
-
- if (get_root_node()->get_editor() && !indicator.is_valid()) {
-
- indicator=VisualServer::get_singleton()->poly_create();
- RID mat=VisualServer::get_singleton()->fixed_material_create();
- VisualServer::get_singleton()->material_set_flag( mat, VisualServer::MATERIAL_FLAG_UNSHADED, true );
- VisualServer::get_singleton()->material_set_flag( mat, VisualServer::MATERIAL_FLAG_WIREFRAME, true );
- VisualServer::get_singleton()->material_set_flag( mat, VisualServer::MATERIAL_FLAG_DOUBLE_SIDED, true );
- VisualServer::get_singleton()->material_set_line_width( mat, 3 );
-
- VisualServer::get_singleton()->poly_set_material(indicator,mat,true);
-
- update_indicator(indicator);
- }
-
- if (indicator.is_valid()) {
-
- indicator_instance=VisualServer::get_singleton()->instance_create2(indicator,get_world()->get_scenario());
- VisualServer::get_singleton()->instance_attach_object_instance_ID(indicator_instance,get_instance_ID());
- }
- volume_changed();
- } break;
- case NOTIFICATION_EXIT_SCENE: {
-
- if (indicator_instance.is_valid()) {
-
- VisualServer::get_singleton()->free(indicator_instance);
- }
- volume_changed();
- } break;
- case NOTIFICATION_TRANSFORM_CHANGED: {
-
- if (indicator_instance.is_valid()) {
-
- VisualServer::get_singleton()->instance_set_transform(indicator_instance,get_global_transform());
- }
- volume_changed();
- } break;
- default: {}
- }
-}
-
-void CollisionShape::volume_changed() {
-
- if (indicator.is_valid())
- update_indicator(indicator);
-
- Object *parent=get_parent();
- if (!parent)
- return;
- PhysicsBody *physics_body=parent->cast_to<PhysicsBody>();
-
- ERR_EXPLAIN("CollisionShape parent is not of type PhysicsBody");
- ERR_FAIL_COND(!physics_body);
-
- physics_body->recompute_child_volumes();
-
-}
-
-RID CollisionShape::_get_visual_instance_rid() const {
-
- return indicator_instance;
-
-}
-
-void CollisionShape::_bind_methods() {
-
- ClassDB::bind_method("_get_visual_instance_rid",&CollisionShape::_get_visual_instance_rid);
-}
-
-CollisionShape::CollisionShape() {
-
-}
-
-CollisionShape::~CollisionShape() {
-
- if (indicator.is_valid()) {
-
- VisualServer::get_singleton()->free(indicator);
- }
-
-}
-
-void CollisionShapeSphere::_set(const String& p_name, const Variant& p_value) {
-
- if (p_name=="radius") {
- radius=p_value;
- volume_changed();
- }
-
-}
-
-Variant CollisionShapeSphere::_get(const String& p_name) const {
-
- if (p_name=="radius") {
- return radius;
- }
-
- return Variant();
-}
-
-void CollisionShapeSphere::_get_property_list( List<PropertyInfo> *p_list) const {
-
- p_list->push_back( PropertyInfo(Variant::REAL,"radius",PROPERTY_HINT_RANGE,"0.01,16384,0.01") );
-}
-
-void CollisionShapeSphere::update_indicator(RID p_indicator) {
-
- VisualServer *vs=VisualServer::get_singleton();
-
- vs->poly_clear(p_indicator);
- Color col(0.4,1.0,1.0,0.5);
-
- int lats=6;
- int lons=12;
- float size=radius;
-
- for(int i = 1; i <= lats; i++) {
- double lat0 = Math_PI * (-0.5 + (double) (i - 1) / lats);
- double z0 = Math::sin(lat0);
- double zr0 = Math::cos(lat0);
-
- double lat1 = Math_PI * (-0.5 + (double) i / lats);
- double z1 = Math::sin(lat1);
- double zr1 = Math::cos(lat1);
-
- for(int j = lons; j >= 1; j--) {
-
- double lng0 = 2 * Math_PI * (double) (j - 1) / lons;
- double x0 = Math::cos(lng0);
- double y0 = Math::sin(lng0);
-
- double lng1 = 2 * Math_PI * (double) (j) / lons;
- double x1 = Math::cos(lng1);
- double y1 = Math::sin(lng1);
-
- Vector3 v4=Vector3(x0 * zr0, z0, y0 *zr0)*size;
- Vector3 v3=Vector3(x0 * zr1, z1, y0 *zr1)*size;
- Vector3 v2=Vector3(x1 * zr1, z1, y1 *zr1)*size;
- Vector3 v1=Vector3(x1 * zr0, z0, y1 *zr0)*size;
-
- Vector<Vector3> line;
- line.push_back(v1);
- line.push_back(v2);
- line.push_back(v3);
- line.push_back(v4);
-
- Vector<Color> cols;
- cols.push_back(col);
- cols.push_back(col);
- cols.push_back(col);
- cols.push_back(col);
-
-
- VisualServer::get_singleton()->poly_add_primitive(p_indicator,line,Vector<Vector3>(),cols,Vector<Vector3>());
- }
- }
-}
-
-void CollisionShapeSphere::append_to_volume(Ref<Shape> p_volume) {
-
- p_volume->add_sphere_shape(radius,get_transform());
-}
-
-
-CollisionShapeSphere::CollisionShapeSphere() {
-
- radius=1.0;
-}
-
-/* BOX */
-
-
-void CollisionShapeBox::_set(const String& p_name, const Variant& p_value) {
-
- if (p_name=="half_extents") {
- half_extents=p_value;
- volume_changed();
- }
-
-}
-
-Variant CollisionShapeBox::_get(const String& p_name) const {
-
- if (p_name=="half_extents") {
- return half_extents;
- }
-
- return Variant();
-}
-
-void CollisionShapeBox::_get_property_list( List<PropertyInfo> *p_list) const {
-
- p_list->push_back( PropertyInfo(Variant::VECTOR3,"half_extents" ) );
-}
-
-
-void CollisionShapeBox::update_indicator(RID p_indicator) {
-
- VisualServer *vs=VisualServer::get_singleton();
-
- vs->poly_clear(p_indicator);
- Color col(0.4,1.0,1.0,0.5);
-
-
- for (int i=0;i<6;i++) {
-
-
- Vector3 face_points[4];
-
- for (int j=0;j<4;j++) {
-
- float v[3];
- v[0]=1.0;
- v[1]=1-2*((j>>1)&1);
- v[2]=v[1]*(1-2*(j&1));
-
- for (int k=0;k<3;k++) {
-
- if (i<3)
- face_points[j][(i+k)%3]=v[k]*(i>=3?-1:1);
- else
- face_points[3-j][(i+k)%3]=v[k]*(i>=3?-1:1);
- }
- }
-
- for(int j=0;j<4;j++)
- face_points[i]*=half_extents;
-
- ADD_TRIANGLE(face_points[0],face_points[1],face_points[2],col);
- ADD_TRIANGLE(face_points[2],face_points[3],face_points[0],col);
-
- }
-}
-
-void CollisionShapeBox::append_to_volume(Ref<Shape> p_volume) {
-
- p_volume->add_box_shape(half_extents,get_transform());
-}
-
-
-CollisionShapeBox::CollisionShapeBox() {
-
- half_extents=Vector3(1,1,1);
-}
-
-/* CYLINDER */
-
-
-void CollisionShapeCylinder::_set(const String& p_name, const Variant& p_value) {
-
- if (p_name=="radius") {
- radius=p_value;
- volume_changed();
- }
- if (p_name=="height") {
- height=p_value;
- volume_changed();
- }
-
-}
-
-Variant CollisionShapeCylinder::_get(const String& p_name) const {
-
- if (p_name=="radius") {
- return radius;
- }
- if (p_name=="height") {
- return height;
- }
- return Variant();
-}
-
-void CollisionShapeCylinder::_get_property_list( List<PropertyInfo> *p_list) const {
-
- p_list->push_back( PropertyInfo(Variant::REAL,"radius",PROPERTY_HINT_RANGE,"0.01,16384,0.01") );
- p_list->push_back( PropertyInfo(Variant::REAL,"height",PROPERTY_HINT_RANGE,"0.01,16384,0.01") );
-}
-
-
-void CollisionShapeCylinder::update_indicator(RID p_indicator) {
-
- VisualServer *vs=VisualServer::get_singleton();
-
- vs->poly_clear(p_indicator);
- Color col(0.4,1.0,1.0,0.5);
-
- PoolVector<Plane> planes = Geometry::build_cylinder_planes(radius, height, 12, Vector3::AXIS_Z);
- Geometry::MeshData md = Geometry::build_convex_mesh(planes);
-
- for(int i=0;i<md.faces.size();i++) {
-
- for(int j=2;j<md.faces[i].indices.size();j++) {
- ADD_TRIANGLE(md.vertices[md.faces[i].indices[0]],md.vertices[md.faces[i].indices[j-1]],md.vertices[md.faces[i].indices[j]],col);
- }
- }
-
-}
-
-void CollisionShapeCylinder::append_to_volume(Ref<Shape> p_volume) {
-
- p_volume->add_cylinder_shape(radius,height*2.0,get_transform());
-}
-
-
-CollisionShapeCylinder::CollisionShapeCylinder() {
-
- height=1;
- radius=1;
-}
-
-/* CAPSULE */
-
-
-void CollisionShapeCapsule::_set(const String& p_name, const Variant& p_value) {
-
- if (p_name=="radius") {
- radius=p_value;
- volume_changed();
- }
-
- if (p_name=="height") {
- height=p_value;
- volume_changed();
- }
-
-}
-
-Variant CollisionShapeCapsule::_get(const String& p_name) const {
-
- if (p_name=="radius") {
- return radius;
- }
- if (p_name=="height") {
- return height;
- }
- return Variant();
-}
-
-void CollisionShapeCapsule::_get_property_list( List<PropertyInfo> *p_list) const {
-
- p_list->push_back( PropertyInfo(Variant::REAL,"radius",PROPERTY_HINT_RANGE,"0.01,16384,0.01") );
- p_list->push_back( PropertyInfo(Variant::REAL,"height",PROPERTY_HINT_RANGE,"0.01,16384,0.01") );
-}
-
-
-void CollisionShapeCapsule::update_indicator(RID p_indicator) {
-
- VisualServer *vs=VisualServer::get_singleton();
-
- vs->poly_clear(p_indicator);
- Color col(0.4,1.0,1.0,0.5);
-
- PoolVector<Plane> planes = Geometry::build_capsule_planes(radius, height, 12, 3, Vector3::AXIS_Z);
- Geometry::MeshData md = Geometry::build_convex_mesh(planes);
-
- for(int i=0;i<md.faces.size();i++) {
-
- for(int j=2;j<md.faces[i].indices.size();j++) {
- ADD_TRIANGLE(md.vertices[md.faces[i].indices[0]],md.vertices[md.faces[i].indices[j-1]],md.vertices[md.faces[i].indices[j]],col);
- }
- }
-
-}
-
-void CollisionShapeCapsule::append_to_volume(Ref<Shape> p_volume) {
-
-
- p_volume->add_capsule_shape(radius,height,get_transform());
-}
-
-
-CollisionShapeCapsule::CollisionShapeCapsule() {
-
- height=1;
- radius=1;
-}
-#endif
diff --git a/scene/3d/camera.cpp b/scene/3d/camera.cpp
index 0f4378acdd..697d91c863 100644
--- a/scene/3d/camera.cpp
+++ b/scene/3d/camera.cpp
@@ -94,6 +94,8 @@ bool Camera::_set(const StringName &p_name, const Variant &p_value) {
set_cull_mask(p_value);
} else if (p_name == "environment") {
set_environment(p_value);
+ } else if (p_name == "doppler/tracking") {
+ set_doppler_tracking(DopplerTracking(int(p_value)));
} else
return false;
@@ -131,6 +133,8 @@ bool Camera::_get(const StringName &p_name, Variant &r_ret) const {
r_ret = get_v_offset();
} else if (p_name == "environment") {
r_ret = get_environment();
+ } else if (p_name == "doppler/tracking") {
+ r_ret = get_doppler_tracking();
} else
return false;
@@ -171,6 +175,7 @@ void Camera::_get_property_list(List<PropertyInfo> *p_list) const {
p_list->push_back(PropertyInfo(Variant::OBJECT, "environment", PROPERTY_HINT_RESOURCE_TYPE, "Environment"));
p_list->push_back(PropertyInfo(Variant::REAL, "h_offset"));
p_list->push_back(PropertyInfo(Variant::REAL, "v_offset"));
+ p_list->push_back(PropertyInfo(Variant::INT, "doppler/tracking", PROPERTY_HINT_ENUM, "Disabled,Idle,Fixed"));
}
void Camera::_update_camera() {
@@ -209,6 +214,9 @@ void Camera::_notification(int p_what) {
case NOTIFICATION_TRANSFORM_CHANGED: {
_request_camera_update();
+ if (doppler_tracking != DOPPLER_TRACKING_DISABLED) {
+ velocity_tracker->update_position(get_global_transform().origin);
+ }
} break;
case NOTIFICATION_EXIT_WORLD: {
@@ -507,6 +515,22 @@ Camera::KeepAspect Camera::get_keep_aspect_mode() const {
return keep_aspect;
}
+void Camera::set_doppler_tracking(DopplerTracking p_tracking) {
+
+ if (doppler_tracking == p_tracking)
+ return;
+
+ doppler_tracking = p_tracking;
+ if (p_tracking != DOPPLER_TRACKING_DISABLED) {
+ velocity_tracker->set_track_fixed_step(doppler_tracking == DOPPLER_TRACKING_FIXED_STEP);
+ velocity_tracker->reset(get_global_transform().origin);
+ }
+}
+
+Camera::DopplerTracking Camera::get_doppler_tracking() const {
+ return doppler_tracking;
+}
+
void Camera::_bind_methods() {
ClassDB::bind_method(D_METHOD("project_ray_normal", "screen_point"), &Camera::project_ray_normal);
@@ -536,6 +560,8 @@ void Camera::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_environment:Environment"), &Camera::get_environment);
ClassDB::bind_method(D_METHOD("set_keep_aspect_mode", "mode"), &Camera::set_keep_aspect_mode);
ClassDB::bind_method(D_METHOD("get_keep_aspect_mode"), &Camera::get_keep_aspect_mode);
+ ClassDB::bind_method(D_METHOD("set_doppler_tracking", "mode"), &Camera::set_doppler_tracking);
+ ClassDB::bind_method(D_METHOD("get_doppler_tracking"), &Camera::get_doppler_tracking);
//ClassDB::bind_method(D_METHOD("_camera_make_current"),&Camera::_camera_make_current );
BIND_CONSTANT(PROJECTION_PERSPECTIVE);
@@ -543,6 +569,10 @@ void Camera::_bind_methods() {
BIND_CONSTANT(KEEP_WIDTH);
BIND_CONSTANT(KEEP_HEIGHT);
+
+ BIND_CONSTANT(DOPPLER_TRACKING_DISABLED)
+ BIND_CONSTANT(DOPPLER_TRACKING_IDLE_STEP)
+ BIND_CONSTANT(DOPPLER_TRACKING_FIXED_STEP)
}
float Camera::get_fov() const {
@@ -616,6 +646,14 @@ float Camera::get_h_offset() const {
return h_offset;
}
+Vector3 Camera::get_doppler_tracked_velocity() const {
+
+ if (doppler_tracking != DOPPLER_TRACKING_DISABLED) {
+ return velocity_tracker->get_tracked_linear_velocity();
+ } else {
+ return Vector3();
+ }
+}
Camera::Camera() {
camera = VisualServer::get_singleton()->camera_create();
@@ -633,6 +671,8 @@ Camera::Camera() {
h_offset = 0;
VisualServer::get_singleton()->camera_set_cull_mask(camera, layers);
//active=false;
+ velocity_tracker.instance();
+ doppler_tracking = DOPPLER_TRACKING_DISABLED;
set_notify_transform(true);
}
diff --git a/scene/3d/camera.h b/scene/3d/camera.h
index 472cfaa008..43975892b4 100644
--- a/scene/3d/camera.h
+++ b/scene/3d/camera.h
@@ -31,6 +31,7 @@
#define CAMERA_H
#include "scene/3d/spatial.h"
+#include "scene/3d/spatial_velocity_tracker.h"
#include "scene/main/viewport.h"
#include "scene/resources/environment.h"
/**
@@ -52,6 +53,12 @@ public:
KEEP_HEIGHT
};
+ enum DopplerTracking {
+ DOPPLER_TRACKING_DISABLED,
+ DOPPLER_TRACKING_IDLE_STEP,
+ DOPPLER_TRACKING_FIXED_STEP
+ };
+
private:
bool force_change;
bool current;
@@ -80,6 +87,9 @@ private:
friend class Viewport;
void _update_audio_listener_state();
+ DopplerTracking doppler_tracking;
+ Ref<SpatialVelocityTracker> velocity_tracker;
+
protected:
void _update_camera();
virtual void _request_camera_update();
@@ -140,11 +150,17 @@ public:
void set_h_offset(float p_offset);
float get_h_offset() const;
+ void set_doppler_tracking(DopplerTracking p_tracking);
+ DopplerTracking get_doppler_tracking() const;
+
+ Vector3 get_doppler_tracked_velocity() const;
+
Camera();
~Camera();
};
VARIANT_ENUM_CAST(Camera::Projection);
VARIANT_ENUM_CAST(Camera::KeepAspect);
+VARIANT_ENUM_CAST(Camera::DopplerTracking);
#endif
diff --git a/scene/3d/collision_object.cpp b/scene/3d/collision_object.cpp
index 1b27313d3b..5a3d8e013f 100644
--- a/scene/3d/collision_object.cpp
+++ b/scene/3d/collision_object.cpp
@@ -30,17 +30,6 @@
#include "collision_object.h"
#include "scene/scene_string_names.h"
#include "servers/physics_server.h"
-void CollisionObject::_update_shapes_from_children() {
-
- shapes.clear();
- for (int i = 0; i < get_child_count(); i++) {
-
- Node *n = get_child(i);
- n->call("_add_to_collision_object", this);
- }
-
- _update_shapes();
-}
void CollisionObject::_notification(int p_what) {
@@ -87,91 +76,6 @@ void CollisionObject::_notification(int p_what) {
}
}
-void CollisionObject::_update_shapes() {
-
- if (!rid.is_valid())
- return;
-
- if (area)
- PhysicsServer::get_singleton()->area_clear_shapes(rid);
- else
- PhysicsServer::get_singleton()->body_clear_shapes(rid);
-
- for (int i = 0; i < shapes.size(); i++) {
-
- if (shapes[i].shape.is_null())
- continue;
- if (area)
- PhysicsServer::get_singleton()->area_add_shape(rid, shapes[i].shape->get_rid(), shapes[i].xform);
- else {
- PhysicsServer::get_singleton()->body_add_shape(rid, shapes[i].shape->get_rid(), shapes[i].xform);
- if (shapes[i].trigger)
- PhysicsServer::get_singleton()->body_set_shape_as_trigger(rid, i, shapes[i].trigger);
- }
- }
-}
-
-bool CollisionObject::_set(const StringName &p_name, const Variant &p_value) {
- String name = p_name;
-
- if (name == "shape_count") {
-
- shapes.resize(p_value);
- _update_shapes();
- _change_notify();
-
- } else if (name.begins_with("shapes/")) {
-
- int idx = name.get_slicec('/', 1).to_int();
- String what = name.get_slicec('/', 2);
- if (what == "shape")
- set_shape(idx, RefPtr(p_value));
- else if (what == "transform")
- set_shape_transform(idx, p_value);
- else if (what == "trigger")
- set_shape_as_trigger(idx, p_value);
-
- } else
- return false;
-
- return true;
-}
-
-bool CollisionObject::_get(const StringName &p_name, Variant &r_ret) const {
-
- String name = p_name;
-
- if (name == "shape_count") {
- r_ret = shapes.size();
- } else if (name.begins_with("shapes/")) {
-
- int idx = name.get_slicec('/', 1).to_int();
- String what = name.get_slicec('/', 2);
- if (what == "shape")
- r_ret = get_shape(idx);
- else if (what == "transform")
- r_ret = get_shape_transform(idx);
- else if (what == "trigger")
- r_ret = is_shape_set_as_trigger(idx);
-
- } else
- return false;
-
- return true;
-}
-
-void CollisionObject::_get_property_list(List<PropertyInfo> *p_list) const {
-
- p_list->push_back(PropertyInfo(Variant::INT, "shape_count", PROPERTY_HINT_RANGE, "0,256,1", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_NO_INSTANCE_STATE));
-
- for (int i = 0; i < shapes.size(); i++) {
- String path = "shapes/" + itos(i) + "/";
- p_list->push_back(PropertyInfo(Variant::OBJECT, path + "shape", PROPERTY_HINT_RESOURCE_TYPE, "Shape", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_NO_INSTANCE_STATE));
- p_list->push_back(PropertyInfo(Variant::TRANSFORM, path + "transform", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_NO_INSTANCE_STATE));
- p_list->push_back(PropertyInfo(Variant::BOOL, path + "trigger", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_NO_INSTANCE_STATE));
- }
-}
-
void CollisionObject::_input_event(Node *p_camera, const Ref<InputEvent> &p_input_event, const Vector3 &p_pos, const Vector3 &p_normal, int p_shape) {
if (get_script_instance()) {
@@ -219,22 +123,27 @@ bool CollisionObject::is_ray_pickable() const {
void CollisionObject::_bind_methods() {
- ClassDB::bind_method(D_METHOD("add_shape", "shape:Shape", "transform"), &CollisionObject::add_shape, DEFVAL(Transform()));
- ClassDB::bind_method(D_METHOD("get_shape_count"), &CollisionObject::get_shape_count);
- ClassDB::bind_method(D_METHOD("set_shape", "shape_idx", "shape:Shape"), &CollisionObject::set_shape);
- ClassDB::bind_method(D_METHOD("set_shape_transform", "shape_idx", "transform"), &CollisionObject::set_shape_transform);
- // ClassDB::bind_method(D_METHOD("set_shape_transform","shape_idx","transform"),&CollisionObject::set_shape_transform);
- ClassDB::bind_method(D_METHOD("set_shape_as_trigger", "shape_idx", "enable"), &CollisionObject::set_shape_as_trigger);
- ClassDB::bind_method(D_METHOD("is_shape_set_as_trigger", "shape_idx"), &CollisionObject::is_shape_set_as_trigger);
- ClassDB::bind_method(D_METHOD("get_shape:Shape", "shape_idx"), &CollisionObject::get_shape);
- ClassDB::bind_method(D_METHOD("get_shape_transform", "shape_idx"), &CollisionObject::get_shape_transform);
- ClassDB::bind_method(D_METHOD("remove_shape", "shape_idx"), &CollisionObject::remove_shape);
- ClassDB::bind_method(D_METHOD("clear_shapes"), &CollisionObject::clear_shapes);
ClassDB::bind_method(D_METHOD("set_ray_pickable", "ray_pickable"), &CollisionObject::set_ray_pickable);
ClassDB::bind_method(D_METHOD("is_ray_pickable"), &CollisionObject::is_ray_pickable);
ClassDB::bind_method(D_METHOD("set_capture_input_on_drag", "enable"), &CollisionObject::set_capture_input_on_drag);
ClassDB::bind_method(D_METHOD("get_capture_input_on_drag"), &CollisionObject::get_capture_input_on_drag);
ClassDB::bind_method(D_METHOD("get_rid"), &CollisionObject::get_rid);
+ ClassDB::bind_method(D_METHOD("create_shape_owner", "owner:Object"), &CollisionObject::create_shape_owner);
+ ClassDB::bind_method(D_METHOD("remove_shape_owner", "owner_id"), &CollisionObject::remove_shape_owner);
+ ClassDB::bind_method(D_METHOD("get_shape_owners"), &CollisionObject::_get_shape_owners);
+ ClassDB::bind_method(D_METHOD("shape_owner_set_transform", "owner_id", "transform:Transform"), &CollisionObject::shape_owner_set_transform);
+ ClassDB::bind_method(D_METHOD("shape_owner_get_transform", "owner_id"), &CollisionObject::shape_owner_get_transform);
+ ClassDB::bind_method(D_METHOD("shape_owner_get_owner", "owner_id"), &CollisionObject::shape_owner_get_owner);
+ ClassDB::bind_method(D_METHOD("shape_owner_set_disabled", "owner_id", "disabled"), &CollisionObject::shape_owner_set_disabled);
+ ClassDB::bind_method(D_METHOD("is_shape_owner_disabled", "owner_id"), &CollisionObject::is_shape_owner_disabled);
+ ClassDB::bind_method(D_METHOD("shape_owner_add_shape", "owner_id", "shape:Shape"), &CollisionObject::shape_owner_add_shape);
+ ClassDB::bind_method(D_METHOD("shape_owner_get_shape_count", "owner_id"), &CollisionObject::shape_owner_get_shape_count);
+ ClassDB::bind_method(D_METHOD("shape_owner_get_shape", "owner_id", "shape_id"), &CollisionObject::shape_owner_get_shape);
+ ClassDB::bind_method(D_METHOD("shape_owner_get_shape_index", "owner_id", "shape_id"), &CollisionObject::shape_owner_get_shape_index);
+ ClassDB::bind_method(D_METHOD("shape_owner_remove_shape", "owner_id", "shape_id"), &CollisionObject::shape_owner_remove_shape);
+ ClassDB::bind_method(D_METHOD("shape_owner_clear_shapes", "owner_id"), &CollisionObject::shape_owner_clear_shapes);
+ ClassDB::bind_method(D_METHOD("shape_find_owner", "shape_index"), &CollisionObject::shape_find_owner);
+
BIND_VMETHOD(MethodInfo("_input_event", PropertyInfo(Variant::OBJECT, "camera"), PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent"), PropertyInfo(Variant::VECTOR3, "click_pos"), PropertyInfo(Variant::VECTOR3, "click_normal"), PropertyInfo(Variant::INT, "shape_idx")));
ADD_SIGNAL(MethodInfo("input_event", PropertyInfo(Variant::OBJECT, "camera"), PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent"), PropertyInfo(Variant::VECTOR3, "click_pos"), PropertyInfo(Variant::VECTOR3, "click_normal"), PropertyInfo(Variant::INT, "shape_idx")));
@@ -245,72 +154,186 @@ void CollisionObject::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "input_capture_on_drag"), "set_capture_input_on_drag", "get_capture_input_on_drag");
}
-void CollisionObject::add_shape(const Ref<Shape> &p_shape, const Transform &p_transform) {
+uint32_t CollisionObject::create_shape_owner(Object *p_owner) {
+
+ ShapeData sd;
+ uint32_t id;
+
+ if (shapes.size() == 0) {
+ id = 1;
+ } else {
+ id = shapes.back()->key() + 1;
+ }
+
+ sd.owner = p_owner;
- ShapeData sdata;
- sdata.shape = p_shape;
- sdata.xform = p_transform;
- shapes.push_back(sdata);
- _update_shapes();
+ shapes[id] = sd;
+
+ return id;
}
-int CollisionObject::get_shape_count() const {
- return shapes.size();
+void CollisionObject::remove_shape_owner(uint32_t owner) {
+
+ ERR_FAIL_COND(!shapes.has(owner));
+
+ shape_owner_clear_shapes(owner);
+
+ shapes.erase(owner);
}
-void CollisionObject::set_shape(int p_shape_idx, const Ref<Shape> &p_shape) {
- ERR_FAIL_INDEX(p_shape_idx, shapes.size());
- shapes[p_shape_idx].shape = p_shape;
- _update_shapes();
+void CollisionObject::shape_owner_set_disabled(uint32_t p_owner, bool p_disabled) {
+ ERR_FAIL_COND(!shapes.has(p_owner));
+
+ ShapeData &sd = shapes[p_owner];
+ sd.disabled = p_disabled;
+ for (int i = 0; i < sd.shapes.size(); i++) {
+ if (area) {
+ PhysicsServer::get_singleton()->area_set_shape_disabled(rid, sd.shapes[i].index, p_disabled);
+ } else {
+ PhysicsServer::get_singleton()->body_set_shape_disabled(rid, sd.shapes[i].index, p_disabled);
+ }
+ }
+}
+
+bool CollisionObject::is_shape_owner_disabled(uint32_t p_owner) const {
+
+ ERR_FAIL_COND_V(!shapes.has(p_owner), false);
+
+ return shapes[p_owner].disabled;
+}
+
+void CollisionObject::get_shape_owners(List<uint32_t> *r_owners) {
+
+ for (Map<uint32_t, ShapeData>::Element *E = shapes.front(); E; E = E->next()) {
+ r_owners->push_back(E->key());
+ }
+}
+
+Array CollisionObject::_get_shape_owners() {
+
+ Array ret;
+ for (Map<uint32_t, ShapeData>::Element *E = shapes.front(); E; E = E->next()) {
+ ret.push_back(E->key());
+ }
+
+ return ret;
+}
+
+void CollisionObject::shape_owner_set_transform(uint32_t p_owner, const Transform &p_transform) {
+
+ ERR_FAIL_COND(!shapes.has(p_owner));
+
+ ShapeData &sd = shapes[p_owner];
+ sd.xform = p_transform;
+ for (int i = 0; i < sd.shapes.size(); i++) {
+ if (area) {
+ PhysicsServer::get_singleton()->area_set_shape_transform(rid, sd.shapes[i].index, p_transform);
+ } else {
+ PhysicsServer::get_singleton()->body_set_shape_transform(rid, sd.shapes[i].index, p_transform);
+ }
+ }
+}
+Transform CollisionObject::shape_owner_get_transform(uint32_t p_owner) const {
+
+ ERR_FAIL_COND_V(!shapes.has(p_owner), Transform());
+
+ return shapes[p_owner].xform;
}
-void CollisionObject::set_shape_transform(int p_shape_idx, const Transform &p_transform) {
+Object *CollisionObject::shape_owner_get_owner(uint32_t p_owner) const {
- ERR_FAIL_INDEX(p_shape_idx, shapes.size());
- shapes[p_shape_idx].xform = p_transform;
+ ERR_FAIL_COND_V(!shapes.has(p_owner), NULL);
- _update_shapes();
+ return shapes[p_owner].owner;
}
-Ref<Shape> CollisionObject::get_shape(int p_shape_idx) const {
+void CollisionObject::shape_owner_add_shape(uint32_t p_owner, const Ref<Shape> &p_shape) {
+
+ ERR_FAIL_COND(!shapes.has(p_owner));
+ ERR_FAIL_COND(p_shape.is_null());
+
+ ShapeData &sd = shapes[p_owner];
+ ShapeData::ShapeBase s;
+ s.index = total_subshapes;
+ s.shape = p_shape;
+ if (area) {
+ PhysicsServer::get_singleton()->area_add_shape(rid, p_shape->get_rid(), sd.xform);
+ } else {
+ PhysicsServer::get_singleton()->body_add_shape(rid, p_shape->get_rid(), sd.xform);
+ }
+ sd.shapes.push_back(s);
- ERR_FAIL_INDEX_V(p_shape_idx, shapes.size(), Ref<Shape>());
- return shapes[p_shape_idx].shape;
+ total_subshapes++;
}
-Transform CollisionObject::get_shape_transform(int p_shape_idx) const {
+int CollisionObject::shape_owner_get_shape_count(uint32_t p_owner) const {
- ERR_FAIL_INDEX_V(p_shape_idx, shapes.size(), Transform());
- return shapes[p_shape_idx].xform;
+ ERR_FAIL_COND_V(!shapes.has(p_owner), 0);
+
+ return shapes[p_owner].shapes.size();
}
-void CollisionObject::remove_shape(int p_shape_idx) {
+Ref<Shape> CollisionObject::shape_owner_get_shape(uint32_t p_owner, int p_shape) const {
- ERR_FAIL_INDEX(p_shape_idx, shapes.size());
- shapes.remove(p_shape_idx);
+ ERR_FAIL_COND_V(!shapes.has(p_owner), Ref<Shape>());
+ ERR_FAIL_INDEX_V(p_shape, shapes[p_owner].shapes.size(), Ref<Shape>());
- _update_shapes();
+ return shapes[p_owner].shapes[p_shape].shape;
}
+int CollisionObject::shape_owner_get_shape_index(uint32_t p_owner, int p_shape) const {
+
+ ERR_FAIL_COND_V(!shapes.has(p_owner), -1);
+ ERR_FAIL_INDEX_V(p_shape, shapes[p_owner].shapes.size(), -1);
+
+ return shapes[p_owner].shapes[p_shape].index;
+}
+
+void CollisionObject::shape_owner_remove_shape(uint32_t p_owner, int p_shape) {
-void CollisionObject::clear_shapes() {
+ ERR_FAIL_COND(!shapes.has(p_owner));
+ ERR_FAIL_INDEX(p_shape, shapes[p_owner].shapes.size());
- shapes.clear();
+ int index_to_remove = shapes[p_owner].shapes[p_shape].index;
+ if (area) {
+ PhysicsServer::get_singleton()->area_remove_shape(rid, index_to_remove);
+ } else {
+ PhysicsServer::get_singleton()->body_remove_shape(rid, index_to_remove);
+ }
+
+ shapes[p_owner].shapes.remove(p_shape);
+
+ for (Map<uint32_t, ShapeData>::Element *E = shapes.front(); E; E = E->next()) {
+ for (int i = 0; i < E->get().shapes.size(); i++) {
+ if (E->get().shapes[i].index > index_to_remove) {
+ E->get().shapes[i].index -= 1;
+ }
+ }
+ }
- _update_shapes();
+ total_subshapes--;
}
-void CollisionObject::set_shape_as_trigger(int p_shape_idx, bool p_trigger) {
+void CollisionObject::shape_owner_clear_shapes(uint32_t p_owner) {
- ERR_FAIL_INDEX(p_shape_idx, shapes.size());
- shapes[p_shape_idx].trigger = p_trigger;
- if (!area && rid.is_valid()) {
+ ERR_FAIL_COND(!shapes.has(p_owner));
- PhysicsServer::get_singleton()->body_set_shape_as_trigger(rid, p_shape_idx, p_trigger);
+ while (shape_owner_get_shape_count(p_owner) > 0) {
+ shape_owner_remove_shape(p_owner, 0);
}
}
-bool CollisionObject::is_shape_set_as_trigger(int p_shape_idx) const {
+uint32_t CollisionObject::shape_find_owner(int p_shape_index) const {
- ERR_FAIL_INDEX_V(p_shape_idx, shapes.size(), false);
- return shapes[p_shape_idx].trigger;
+ ERR_FAIL_INDEX_V(p_shape_index, total_subshapes, 0);
+
+ for (const Map<uint32_t, ShapeData>::Element *E = shapes.front(); E; E = E->next()) {
+ for (int i = 0; i < E->get().shapes.size(); i++) {
+ if (E->get().shapes[i].index == p_shape_index) {
+ return E->key();
+ }
+ }
+ }
+
+ //in theory it should be unreachable
+ return 0;
}
CollisionObject::CollisionObject(RID p_rid, bool p_area) {
@@ -320,6 +343,8 @@ CollisionObject::CollisionObject(RID p_rid, bool p_area) {
capture_input_on_drag = false;
ray_pickable = true;
set_notify_transform(true);
+ total_subshapes = 0;
+
if (p_area) {
PhysicsServer::get_singleton()->area_attach_object_instance_ID(rid, get_instance_ID());
} else {
diff --git a/scene/3d/collision_object.h b/scene/3d/collision_object.h
index 3822fb0d5a..6c13e5d505 100644
--- a/scene/3d/collision_object.h
+++ b/scene/3d/collision_object.h
@@ -41,33 +41,36 @@ class CollisionObject : public Spatial {
RID rid;
struct ShapeData {
+
+ Object *owner;
Transform xform;
- Ref<Shape> shape;
- bool trigger;
+ struct ShapeBase {
+ Ref<Shape> shape;
+ int index;
+ };
+
+ Vector<ShapeBase> shapes;
+ bool disabled;
ShapeData() {
- trigger = false;
+ disabled = false;
+ owner = NULL;
}
};
+ int total_subshapes;
+
+ Map<uint32_t, ShapeData> shapes;
+
bool capture_input_on_drag;
bool ray_pickable;
- Vector<ShapeData> shapes;
void _update_pickable();
- void _update_shapes();
-
- friend class CollisionShape;
- friend class CollisionPolygon;
- void _update_shapes_from_children();
protected:
CollisionObject(RID p_rid, bool p_area);
void _notification(int p_what);
- bool _set(const StringName &p_name, const Variant &p_value);
- bool _get(const StringName &p_name, Variant &r_ret) const;
- void _get_property_list(List<PropertyInfo> *p_list) const;
static void _bind_methods();
friend class Viewport;
virtual void _input_event(Node *p_camera, const Ref<InputEvent> &p_input_event, const Vector3 &p_pos, const Vector3 &p_normal, int p_shape);
@@ -75,16 +78,27 @@ protected:
virtual void _mouse_exit();
public:
- void add_shape(const Ref<Shape> &p_shape, const Transform &p_transform = Transform());
- int get_shape_count() const;
- void set_shape(int p_shape_idx, const Ref<Shape> &p_shape);
- void set_shape_transform(int p_shape_idx, const Transform &p_transform);
- Ref<Shape> get_shape(int p_shape_idx) const;
- Transform get_shape_transform(int p_shape_idx) const;
- void remove_shape(int p_shape_idx);
- void clear_shapes();
- void set_shape_as_trigger(int p_shape_idx, bool p_trigger);
- bool is_shape_set_as_trigger(int p_shape_idx) const;
+ uint32_t create_shape_owner(Object *p_owner);
+ void remove_shape_owner(uint32_t owner);
+ void get_shape_owners(List<uint32_t> *r_owners);
+ Array _get_shape_owners();
+
+ void shape_owner_set_transform(uint32_t p_owner, const Transform &p_transform);
+ Transform shape_owner_get_transform(uint32_t p_owner) const;
+ Object *shape_owner_get_owner(uint32_t p_owner) const;
+
+ void shape_owner_set_disabled(uint32_t p_owner, bool p_disabled);
+ bool is_shape_owner_disabled(uint32_t p_owner) const;
+
+ void shape_owner_add_shape(uint32_t p_owner, const Ref<Shape> &p_shape);
+ int shape_owner_get_shape_count(uint32_t p_owner) const;
+ Ref<Shape> shape_owner_get_shape(uint32_t p_owner, int p_shape) const;
+ int shape_owner_get_shape_index(uint32_t p_owner, int p_shape) const;
+
+ void shape_owner_remove_shape(uint32_t p_owner, int p_shape);
+ void shape_owner_clear_shapes(uint32_t p_owner);
+
+ uint32_t shape_find_owner(int p_shape_index) const;
void set_ray_pickable(bool p_ray_pickable);
bool is_ray_pickable() const;
diff --git a/scene/3d/collision_polygon.cpp b/scene/3d/collision_polygon.cpp
index d9321f7134..0c61c96d07 100644
--- a/scene/3d/collision_polygon.cpp
+++ b/scene/3d/collision_polygon.cpp
@@ -33,186 +33,82 @@
#include "scene/resources/concave_polygon_shape.h"
#include "scene/resources/convex_polygon_shape.h"
-void CollisionPolygon::_add_to_collision_object(Object *p_obj) {
+void CollisionPolygon::_build_polygon() {
- if (!can_update_body)
+ if (!parent)
return;
- CollisionObject *co = p_obj->cast_to<CollisionObject>();
- ERR_FAIL_COND(!co);
+ parent->shape_owner_clear_shapes(owner_id);
if (polygon.size() == 0)
return;
- bool solids = build_mode == BUILD_SOLIDS;
-
Vector<Vector<Vector2> > decomp = Geometry::decompose_polygon(polygon);
if (decomp.size() == 0)
return;
- if (true || solids) {
-
- //here comes the sun, lalalala
- //decompose concave into multiple convex polygons and add them
- shape_from = co->get_shape_count();
- for (int i = 0; i < decomp.size(); i++) {
- Ref<ConvexPolygonShape> convex = memnew(ConvexPolygonShape);
- PoolVector<Vector3> cp;
- int cs = decomp[i].size();
- cp.resize(cs * 2);
- {
- PoolVector<Vector3>::Write w = cp.write();
- int idx = 0;
- for (int j = 0; j < cs; j++) {
-
- Vector2 d = decomp[i][j];
- w[idx++] = Vector3(d.x, d.y, depth * 0.5);
- w[idx++] = Vector3(d.x, d.y, -depth * 0.5);
- }
+ //here comes the sun, lalalala
+ //decompose concave into multiple convex polygons and add them
+
+ for (int i = 0; i < decomp.size(); i++) {
+ Ref<ConvexPolygonShape> convex = memnew(ConvexPolygonShape);
+ PoolVector<Vector3> cp;
+ int cs = decomp[i].size();
+ cp.resize(cs * 2);
+ {
+ PoolVector<Vector3>::Write w = cp.write();
+ int idx = 0;
+ for (int j = 0; j < cs; j++) {
+
+ Vector2 d = decomp[i][j];
+ w[idx++] = Vector3(d.x, d.y, depth * 0.5);
+ w[idx++] = Vector3(d.x, d.y, -depth * 0.5);
}
-
- convex->set_points(cp);
- co->add_shape(convex, get_transform());
- }
- shape_to = co->get_shape_count() - 1;
- if (shape_to < shape_from) {
- shape_from = -1;
- shape_to = -1;
- }
-
- } else {
-#if 0
- Ref<ConcavePolygonShape> concave = memnew( ConcavePolygonShape );
-
- PoolVector<Vector2> segments;
- segments.resize(polygon.size()*2);
- PoolVector<Vector2>::Write w=segments.write();
-
- for(int i=0;i<polygon.size();i++) {
- w[(i<<1)+0]=polygon[i];
- w[(i<<1)+1]=polygon[(i+1)%polygon.size()];
}
- w=PoolVector<Vector2>::Write();
- concave->set_segments(segments);
-
- co->add_shape(concave,get_transform());
-#endif
+ convex->set_points(cp);
+ parent->shape_owner_add_shape(owner_id, convex);
+ parent->shape_owner_set_disabled(owner_id, disabled);
}
-
- //co->add_shape(shape,get_transform());
-}
-
-void CollisionPolygon::_update_parent() {
-
- if (!can_update_body)
- return;
-
- Node *parent = get_parent();
- if (!parent)
- return;
- CollisionObject *co = parent->cast_to<CollisionObject>();
- if (!co)
- return;
- co->_update_shapes_from_children();
-}
-
-void CollisionPolygon::_set_shape_range(const Vector2 &p_range) {
-
- shape_from = p_range.x;
- shape_to = p_range.y;
-}
-
-Vector2 CollisionPolygon::_get_shape_range() const {
-
- return Vector2(shape_from, shape_to);
}
void CollisionPolygon::_notification(int p_what) {
switch (p_what) {
- case NOTIFICATION_ENTER_TREE: {
- can_update_body = get_tree()->is_editor_hint();
- set_notify_local_transform(!can_update_body);
- //indicator_instance = VisualServer::get_singleton()->instance_create2(indicator,get_world()->get_scenario());
- } break;
- case NOTIFICATION_EXIT_TREE: {
- can_update_body = false;
- set_notify_local_transform(false);
- } break;
- case NOTIFICATION_TRANSFORM_CHANGED: {
-
- if (!is_inside_tree())
- break;
- if (can_update_body) {
- _update_parent();
+ case NOTIFICATION_PARENTED: {
+ parent = get_parent()->cast_to<CollisionObject>();
+ if (parent) {
+ owner_id = parent->create_shape_owner(this);
+ _build_polygon();
+ parent->shape_owner_set_transform(owner_id, get_transform());
+ parent->shape_owner_set_disabled(owner_id, disabled);
}
-
} break;
case NOTIFICATION_LOCAL_TRANSFORM_CHANGED: {
- if (!can_update_body && shape_from >= 0 && shape_to >= 0) {
-
- CollisionObject *co = get_parent()->cast_to<CollisionObject>();
- if (co) {
- for (int i = shape_from; i <= shape_to; i++) {
- co->set_shape_transform(i, get_transform());
- }
- }
- }
- } break;
-#if 0
- case NOTIFICATION_DRAW: {
- for(int i=0;i<polygon.size();i++) {
-
- Vector2 p = polygon[i];
- Vector2 n = polygon[(i+1)%polygon.size()];
- draw_line(p,n,Color(0,0.6,0.7,0.5),3);
+ if (parent) {
+ parent->shape_owner_set_transform(owner_id, get_transform());
}
- Vector< Vector<Vector2> > decomp = Geometry::decompose_polygon(polygon);
-#define DEBUG_DECOMPOSE
-#ifdef DEBUG_DECOMPOSE
- Color c(0.4,0.9,0.1);
- for(int i=0;i<decomp.size();i++) {
-
- c.set_hsv( Math::fmod(c.get_h() + 0.738,1),c.get_s(),c.get_v(),0.5);
- draw_colored_polygon(decomp[i],c);
+ } break;
+ case NOTIFICATION_UNPARENTED: {
+ if (parent) {
+ parent->remove_shape_owner(owner_id);
}
-#endif
-
+ owner_id = 0;
+ parent = NULL;
} break;
-#endif
}
}
void CollisionPolygon::set_polygon(const Vector<Point2> &p_polygon) {
polygon = p_polygon;
- if (can_update_body) {
-
- for (int i = 0; i < polygon.size(); i++) {
-
- Vector3 p1(polygon[i].x, polygon[i].y, depth * 0.5);
-
- if (i == 0)
- aabb = Rect3(p1, Vector3());
- else
- aabb.expand_to(p1);
-
- Vector3 p2(polygon[i].x, polygon[i].y, -depth * 0.5);
- aabb.expand_to(p2);
- }
- if (aabb == Rect3()) {
-
- aabb = Rect3(Vector3(-1, -1, -1), Vector3(2, 2, 2));
- } else {
- aabb.position -= aabb.size * 0.3;
- aabb.size += aabb.size * 0.6;
- }
- _update_parent();
+ if (parent) {
+ _build_polygon();
}
+ update_configuration_warning();
update_gizmo();
}
@@ -221,20 +117,6 @@ Vector<Point2> CollisionPolygon::get_polygon() const {
return polygon;
}
-void CollisionPolygon::set_build_mode(BuildMode p_mode) {
-
- ERR_FAIL_INDEX(p_mode, 2);
- build_mode = p_mode;
- if (!can_update_body)
- return;
- _update_parent();
-}
-
-CollisionPolygon::BuildMode CollisionPolygon::get_build_mode() const {
-
- return build_mode;
-}
-
Rect3 CollisionPolygon::get_item_rect() const {
return aabb;
@@ -243,9 +125,7 @@ Rect3 CollisionPolygon::get_item_rect() const {
void CollisionPolygon::set_depth(float p_depth) {
depth = p_depth;
- if (!can_update_body)
- return;
- _update_parent();
+ _build_polygon();
update_gizmo();
}
@@ -254,6 +134,17 @@ float CollisionPolygon::get_depth() const {
return depth;
}
+void CollisionPolygon::set_disabled(bool p_disabled) {
+ disabled = p_disabled;
+ if (parent) {
+ parent->shape_owner_set_disabled(owner_id, p_disabled);
+ }
+}
+
+bool CollisionPolygon::is_disabled() const {
+ return disabled;
+}
+
String CollisionPolygon::get_configuration_warning() const {
if (!get_parent()->cast_to<CollisionObject>()) {
@@ -269,36 +160,26 @@ String CollisionPolygon::get_configuration_warning() const {
void CollisionPolygon::_bind_methods() {
- ClassDB::bind_method(D_METHOD("_add_to_collision_object"), &CollisionPolygon::_add_to_collision_object);
-
- ClassDB::bind_method(D_METHOD("set_build_mode", "build_mode"), &CollisionPolygon::set_build_mode);
- ClassDB::bind_method(D_METHOD("get_build_mode"), &CollisionPolygon::get_build_mode);
-
ClassDB::bind_method(D_METHOD("set_depth", "depth"), &CollisionPolygon::set_depth);
ClassDB::bind_method(D_METHOD("get_depth"), &CollisionPolygon::get_depth);
ClassDB::bind_method(D_METHOD("set_polygon", "polygon"), &CollisionPolygon::set_polygon);
ClassDB::bind_method(D_METHOD("get_polygon"), &CollisionPolygon::get_polygon);
- ClassDB::bind_method(D_METHOD("_set_shape_range", "shape_range"), &CollisionPolygon::_set_shape_range);
- ClassDB::bind_method(D_METHOD("_get_shape_range"), &CollisionPolygon::_get_shape_range);
-
- ClassDB::bind_method(D_METHOD("get_collision_object_first_shape"), &CollisionPolygon::get_collision_object_first_shape);
- ClassDB::bind_method(D_METHOD("get_collision_object_last_shape"), &CollisionPolygon::get_collision_object_last_shape);
+ ClassDB::bind_method(D_METHOD("set_disabled", "disabled"), &CollisionPolygon::set_disabled);
+ ClassDB::bind_method(D_METHOD("is_disabled"), &CollisionPolygon::is_disabled);
- ADD_PROPERTY(PropertyInfo(Variant::INT, "build_mode", PROPERTY_HINT_ENUM, "Solids,Triangles"), "set_build_mode", "get_build_mode");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "depth"), "set_depth", "get_depth");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "disabled"), "set_disabled", "is_disabled");
ADD_PROPERTY(PropertyInfo(Variant::POOL_VECTOR2_ARRAY, "polygon"), "set_polygon", "get_polygon");
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "shape_range", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "_set_shape_range", "_get_shape_range");
}
CollisionPolygon::CollisionPolygon() {
- shape_from = -1;
- shape_to = -1;
- can_update_body = false;
-
aabb = Rect3(Vector3(-1, -1, -1), Vector3(2, 2, 2));
- build_mode = BUILD_SOLIDS;
depth = 1.0;
+ set_notify_local_transform(true);
+ parent = NULL;
+ owner_id = 0;
+ disabled = false;
}
diff --git a/scene/3d/collision_polygon.h b/scene/3d/collision_polygon.h
index d45b4738ae..beefae182c 100644
--- a/scene/3d/collision_polygon.h
+++ b/scene/3d/collision_polygon.h
@@ -33,55 +33,42 @@
#include "scene/3d/spatial.h"
#include "scene/resources/shape.h"
+class CollisionObject;
class CollisionPolygon : public Spatial {
GDCLASS(CollisionPolygon, Spatial);
-public:
- enum BuildMode {
- BUILD_SOLIDS,
- BUILD_TRIANGLES,
- };
-
protected:
float depth;
Rect3 aabb;
- BuildMode build_mode;
Vector<Point2> polygon;
- void _add_to_collision_object(Object *p_obj);
- void _update_parent();
+ uint32_t owner_id;
+ CollisionObject *parent;
- bool can_update_body;
- int shape_from;
- int shape_to;
+ bool disabled;
- void _set_shape_range(const Vector2 &p_range);
- Vector2 _get_shape_range() const;
+ void _build_polygon();
protected:
void _notification(int p_what);
static void _bind_methods();
public:
- void set_build_mode(BuildMode p_mode);
- BuildMode get_build_mode() const;
-
void set_depth(float p_depth);
float get_depth() const;
void set_polygon(const Vector<Point2> &p_polygon);
Vector<Point2> get_polygon() const;
- virtual Rect3 get_item_rect() const;
+ void set_disabled(bool p_disabled);
+ bool is_disabled() const;
- int get_collision_object_first_shape() const { return shape_from; }
- int get_collision_object_last_shape() const { return shape_to; }
+ virtual Rect3 get_item_rect() const;
String get_configuration_warning() const;
CollisionPolygon();
};
-VARIANT_ENUM_CAST(CollisionPolygon::BuildMode);
#endif // COLLISION_POLYGON_H
diff --git a/scene/3d/collision_shape.cpp b/scene/3d/collision_shape.cpp
new file mode 100644
index 0000000000..a7cfc6fef2
--- /dev/null
+++ b/scene/3d/collision_shape.cpp
@@ -0,0 +1,214 @@
+/*************************************************************************/
+/* body_shape.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+#include "collision_shape.h"
+#include "scene/resources/box_shape.h"
+#include "scene/resources/capsule_shape.h"
+#include "scene/resources/concave_polygon_shape.h"
+#include "scene/resources/convex_polygon_shape.h"
+#include "scene/resources/plane_shape.h"
+#include "scene/resources/ray_shape.h"
+#include "scene/resources/sphere_shape.h"
+#include "servers/visual_server.h"
+//TODO: Implement CylinderShape and HeightMapShape?
+#include "mesh_instance.h"
+#include "physics_body.h"
+#include "quick_hull.h"
+
+void CollisionShape::make_convex_from_brothers() {
+
+ Node *p = get_parent();
+ if (!p)
+ return;
+
+ for (int i = 0; i < p->get_child_count(); i++) {
+
+ Node *n = p->get_child(i);
+ if (n->cast_to<MeshInstance>()) {
+
+ MeshInstance *mi = n->cast_to<MeshInstance>();
+ Ref<Mesh> m = mi->get_mesh();
+ if (m.is_valid()) {
+
+ Ref<Shape> s = m->create_convex_shape();
+ set_shape(s);
+ }
+ }
+ }
+}
+
+void CollisionShape::_notification(int p_what) {
+
+ switch (p_what) {
+
+ case NOTIFICATION_PARENTED: {
+ parent = get_parent()->cast_to<CollisionObject>();
+ if (parent) {
+ owner_id = parent->create_shape_owner(this);
+ if (shape.is_valid()) {
+ parent->shape_owner_add_shape(owner_id, shape);
+ }
+ parent->shape_owner_set_transform(owner_id, get_transform());
+ parent->shape_owner_set_disabled(owner_id, disabled);
+ }
+ } break;
+ case NOTIFICATION_ENTER_TREE: {
+ if (get_tree()->is_debugging_collisions_hint()) {
+ _create_debug_shape();
+ }
+
+ } break;
+ case NOTIFICATION_LOCAL_TRANSFORM_CHANGED: {
+ if (parent) {
+ parent->shape_owner_set_transform(owner_id, get_transform());
+ }
+ } break;
+ case NOTIFICATION_EXIT_TREE: {
+ if (parent) {
+ parent->remove_shape_owner(owner_id);
+ }
+ owner_id = 0;
+ parent = NULL;
+ } break;
+ case NOTIFICATION_UNPARENTED: {
+ if (parent) {
+ parent->remove_shape_owner(owner_id);
+ }
+ owner_id = 0;
+ parent = NULL;
+ } break;
+ }
+}
+
+void CollisionShape::resource_changed(RES res) {
+
+ update_gizmo();
+}
+
+String CollisionShape::get_configuration_warning() const {
+
+ if (!get_parent()->cast_to<CollisionObject>()) {
+ return TTR("CollisionShape only serves to provide a collision shape to a CollisionObject derived node. Please only use it as a child of Area, StaticBody, RigidBody, KinematicBody, etc. to give them a shape.");
+ }
+
+ if (!shape.is_valid()) {
+ return TTR("A shape must be provided for CollisionShape to function. Please create a shape resource for it!");
+ }
+
+ return String();
+}
+
+void CollisionShape::_bind_methods() {
+
+ //not sure if this should do anything
+ ClassDB::bind_method(D_METHOD("resource_changed", "resource:Resource"), &CollisionShape::resource_changed);
+ ClassDB::bind_method(D_METHOD("set_shape", "shape:Shape"), &CollisionShape::set_shape);
+ ClassDB::bind_method(D_METHOD("get_shape:Shape"), &CollisionShape::get_shape);
+ ClassDB::bind_method(D_METHOD("set_disabled", "enable"), &CollisionShape::set_disabled);
+ ClassDB::bind_method(D_METHOD("is_disabled"), &CollisionShape::is_disabled);
+ ClassDB::bind_method(D_METHOD("make_convex_from_brothers"), &CollisionShape::make_convex_from_brothers);
+ ClassDB::set_method_flags("CollisionShape", "make_convex_from_brothers", METHOD_FLAGS_DEFAULT | METHOD_FLAG_EDITOR);
+
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "shape", PROPERTY_HINT_RESOURCE_TYPE, "Shape"), "set_shape", "get_shape");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "disabled"), "set_disabled", "is_disabled");
+}
+
+void CollisionShape::set_shape(const Ref<Shape> &p_shape) {
+
+ if (!shape.is_null())
+ shape->unregister_owner(this);
+ shape = p_shape;
+ if (!shape.is_null())
+ shape->register_owner(this);
+ update_gizmo();
+ if (parent) {
+ parent->shape_owner_clear_shapes(owner_id);
+ if (shape.is_valid()) {
+ parent->shape_owner_add_shape(owner_id, shape);
+ }
+ }
+
+ update_configuration_warning();
+}
+
+Ref<Shape> CollisionShape::get_shape() const {
+
+ return shape;
+}
+
+void CollisionShape::set_disabled(bool p_disabled) {
+
+ disabled = p_disabled;
+ update_gizmo();
+ if (parent) {
+ parent->shape_owner_set_disabled(owner_id, p_disabled);
+ }
+}
+
+bool CollisionShape::is_disabled() const {
+
+ return disabled;
+}
+
+CollisionShape::CollisionShape() {
+
+ //indicator = VisualServer::get_singleton()->mesh_create();
+ disabled = false;
+ debug_shape = NULL;
+ parent = NULL;
+ owner_id = 0;
+ set_notify_local_transform(true);
+}
+
+CollisionShape::~CollisionShape() {
+ if (!shape.is_null())
+ shape->unregister_owner(this);
+ //VisualServer::get_singleton()->free(indicator);
+}
+
+void CollisionShape::_create_debug_shape() {
+
+ if (debug_shape) {
+ debug_shape->queue_delete();
+ debug_shape = NULL;
+ }
+
+ Ref<Shape> s = get_shape();
+
+ if (s.is_null())
+ return;
+
+ Ref<Mesh> mesh = s->get_debug_mesh();
+
+ MeshInstance *mi = memnew(MeshInstance);
+ mi->set_mesh(mesh);
+
+ add_child(mi);
+ debug_shape = mi;
+}
diff --git a/scene/3d/body_shape.h b/scene/3d/collision_shape.h
index f4392dda62..277e0dfa77 100644
--- a/scene/3d/body_shape.h
+++ b/scene/3d/collision_shape.h
@@ -32,7 +32,7 @@
#include "scene/3d/spatial.h"
#include "scene/resources/shape.h"
-
+class CollisionObject;
class CollisionShape : public Spatial {
GDCLASS(CollisionShape, Spatial);
@@ -40,34 +40,13 @@ class CollisionShape : public Spatial {
Ref<Shape> shape;
- /*
- RID _get_visual_instance_rid() const;
-
-
- void _update_indicator();
-
- RID material;
- RID indicator;
- RID indicator_instance;
- */
+ uint32_t owner_id;
+ CollisionObject *parent;
Node *debug_shape;
void resource_changed(RES res);
-
- bool updating_body;
- bool unparenting;
- bool trigger;
-
- bool can_update_body;
-
- int update_shape_index;
-
- void _update_body();
- void _add_to_collision_object(Object *p_cshape);
-
- void _set_update_shape_index(int p_index);
- int _get_update_shape_index() const;
+ bool disabled;
void _create_debug_shape();
@@ -81,13 +60,8 @@ public:
void set_shape(const Ref<Shape> &p_shape);
Ref<Shape> get_shape() const;
- void set_updating_body(bool p_update);
- bool is_updating_body() const;
-
- void set_trigger(bool p_trigger);
- bool is_trigger() const;
-
- int get_collision_object_shape_index() const { return _get_update_shape_index(); }
+ void set_disabled(bool p_disabled);
+ bool is_disabled() const;
String get_configuration_warning() const;
diff --git a/scene/3d/gi_probe.cpp b/scene/3d/gi_probe.cpp
index adca1492c3..7aaf4a6e3d 100644
--- a/scene/3d/gi_probe.cpp
+++ b/scene/3d/gi_probe.cpp
@@ -95,6 +95,16 @@ float GIProbeData::get_bias() const {
return VS::get_singleton()->gi_probe_get_bias(probe);
}
+void GIProbeData::set_normal_bias(float p_range) {
+
+ VS::get_singleton()->gi_probe_set_normal_bias(probe, p_range);
+}
+
+float GIProbeData::get_normal_bias() const {
+
+ return VS::get_singleton()->gi_probe_get_normal_bias(probe);
+}
+
void GIProbeData::set_propagation(float p_range) {
VS::get_singleton()->gi_probe_set_propagation(probe, p_range);
@@ -158,6 +168,9 @@ void GIProbeData::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_bias", "bias"), &GIProbeData::set_bias);
ClassDB::bind_method(D_METHOD("get_bias"), &GIProbeData::get_bias);
+ ClassDB::bind_method(D_METHOD("set_normal_bias", "bias"), &GIProbeData::set_normal_bias);
+ ClassDB::bind_method(D_METHOD("get_normal_bias"), &GIProbeData::get_normal_bias);
+
ClassDB::bind_method(D_METHOD("set_propagation", "propagation"), &GIProbeData::set_propagation);
ClassDB::bind_method(D_METHOD("get_propagation"), &GIProbeData::get_propagation);
@@ -175,6 +188,7 @@ void GIProbeData::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "dynamic_range", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_dynamic_range", "get_dynamic_range");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "energy", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_energy", "get_energy");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "bias", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_bias", "get_bias");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "normal_bias", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_normal_bias", "get_normal_bias");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "propagation", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_propagation", "get_propagation");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "interior", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_interior", "is_interior");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "compress", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_compress", "is_compressed");
@@ -265,6 +279,18 @@ float GIProbe::get_bias() const {
return bias;
}
+void GIProbe::set_normal_bias(float p_normal_bias) {
+
+ normal_bias = p_normal_bias;
+ if (probe_data.is_valid()) {
+ probe_data->set_normal_bias(normal_bias);
+ }
+}
+float GIProbe::get_normal_bias() const {
+
+ return normal_bias;
+}
+
void GIProbe::set_propagation(float p_propagation) {
propagation = p_propagation;
@@ -973,7 +999,7 @@ GIProbe::Baker::MaterialCache GIProbe::_get_material_cache(Ref<Material> p_mater
return mc;
}
-void GIProbe::_plot_mesh(const Transform &p_xform, Ref<ArrayMesh> &p_mesh, Baker *p_baker, const Vector<Ref<Material> > &p_materials, const Ref<Material> &p_override_material) {
+void GIProbe::_plot_mesh(const Transform &p_xform, Ref<Mesh> &p_mesh, Baker *p_baker, const Vector<Ref<Material> > &p_materials, const Ref<Material> &p_override_material) {
for (int i = 0; i < p_mesh->get_surface_count(); i++) {
@@ -1067,7 +1093,7 @@ void GIProbe::_find_meshes(Node *p_at_node, Baker *p_baker) {
MeshInstance *mi = p_at_node->cast_to<MeshInstance>();
if (mi && mi->get_flag(GeometryInstance::FLAG_USE_BAKED_LIGHT)) {
- Ref<ArrayMesh> mesh = mi->get_mesh();
+ Ref<Mesh> mesh = mi->get_mesh();
if (mesh.is_valid()) {
Rect3 aabb = mesh->get_aabb();
@@ -1094,7 +1120,7 @@ void GIProbe::_find_meshes(Node *p_at_node, Baker *p_baker) {
for (int i = 0; i < meshes.size(); i += 2) {
Transform mxf = meshes[i];
- Ref<ArrayMesh> mesh = meshes[i + 1];
+ Ref<Mesh> mesh = meshes[i + 1];
if (!mesh.is_valid())
continue;
@@ -1261,6 +1287,7 @@ void GIProbe::bake(Node *p_from_node, bool p_create_visual_debug) {
probe_data->set_dynamic_range(dynamic_range);
probe_data->set_energy(energy);
probe_data->set_bias(bias);
+ probe_data->set_normal_bias(normal_bias);
probe_data->set_propagation(propagation);
probe_data->set_interior(interior);
probe_data->set_compress(compress);
@@ -1416,8 +1443,8 @@ PoolVector<Face3> GIProbe::get_faces(uint32_t p_usage_flags) const {
void GIProbe::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_probe_data", "data"), &GIProbe::set_probe_data);
- ClassDB::bind_method(D_METHOD("get_probe_data"), &GIProbe::get_probe_data);
+ ClassDB::bind_method(D_METHOD("set_probe_data", "data:GIProbeData"), &GIProbe::set_probe_data);
+ ClassDB::bind_method(D_METHOD("get_probe_data:GIProbeData"), &GIProbe::get_probe_data);
ClassDB::bind_method(D_METHOD("set_subdiv", "subdiv"), &GIProbe::set_subdiv);
ClassDB::bind_method(D_METHOD("get_subdiv"), &GIProbe::get_subdiv);
@@ -1434,6 +1461,9 @@ void GIProbe::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_bias", "max"), &GIProbe::set_bias);
ClassDB::bind_method(D_METHOD("get_bias"), &GIProbe::get_bias);
+ ClassDB::bind_method(D_METHOD("set_normal_bias", "max"), &GIProbe::set_normal_bias);
+ ClassDB::bind_method(D_METHOD("get_normal_bias"), &GIProbe::get_normal_bias);
+
ClassDB::bind_method(D_METHOD("set_propagation", "max"), &GIProbe::set_propagation);
ClassDB::bind_method(D_METHOD("get_propagation"), &GIProbe::get_propagation);
@@ -1443,7 +1473,7 @@ void GIProbe::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_compress", "enable"), &GIProbe::set_compress);
ClassDB::bind_method(D_METHOD("is_compressed"), &GIProbe::is_compressed);
- ClassDB::bind_method(D_METHOD("bake", "from_node", "create_visual_debug"), &GIProbe::bake, DEFVAL(Variant()), DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("bake", "from_node:Node", "create_visual_debug"), &GIProbe::bake, DEFVAL(Variant()), DEFVAL(false));
ClassDB::bind_method(D_METHOD("debug_bake"), &GIProbe::_debug_bake);
ClassDB::set_method_flags(get_class_static(), _scs_create("debug_bake"), METHOD_FLAGS_DEFAULT | METHOD_FLAG_EDITOR);
@@ -1453,6 +1483,7 @@ void GIProbe::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::REAL, "energy", PROPERTY_HINT_RANGE, "0,16,0.01"), "set_energy", "get_energy");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "propagation", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_propagation", "get_propagation");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "bias", PROPERTY_HINT_RANGE, "0,4,0.001"), "set_bias", "get_bias");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "normal_bias", PROPERTY_HINT_RANGE, "0,4,0.001"), "set_normal_bias", "get_normal_bias");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "interior"), "set_interior", "is_interior");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "compress"), "set_compress", "is_compressed");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "data", PROPERTY_HINT_RESOURCE_TYPE, "GIProbeData"), "set_probe_data", "get_probe_data");
@@ -1468,7 +1499,8 @@ GIProbe::GIProbe() {
subdiv = SUBDIV_128;
dynamic_range = 4;
energy = 1.0;
- bias = 1.8;
+ bias = 0.0;
+ normal_bias = 0.8;
propagation = 1.0;
extents = Vector3(10, 10, 10);
color_scan_cell_width = 4;
diff --git a/scene/3d/gi_probe.h b/scene/3d/gi_probe.h
index b5ee86455e..8346437ebd 100644
--- a/scene/3d/gi_probe.h
+++ b/scene/3d/gi_probe.h
@@ -67,6 +67,9 @@ public:
void set_bias(float p_range);
float get_bias() const;
+ void set_normal_bias(float p_range);
+ float get_normal_bias() const;
+
void set_interior(bool p_enable);
bool is_interior() const;
@@ -145,7 +148,7 @@ private:
struct PlotMesh {
Ref<Material> override_material;
Vector<Ref<Material> > instance_materials;
- Ref<ArrayMesh> mesh;
+ Ref<Mesh> mesh;
Transform local_xform;
};
@@ -163,6 +166,7 @@ private:
int dynamic_range;
float energy;
float bias;
+ float normal_bias;
float propagation;
bool interior;
bool compress;
@@ -173,7 +177,7 @@ private:
Vector<Color> _get_bake_texture(Ref<Image> p_image, const Color &p_color);
Baker::MaterialCache _get_material_cache(Ref<Material> p_material, Baker *p_baker);
void _plot_face(int p_idx, int p_level, int p_x, int p_y, int p_z, const Vector3 *p_vtx, const Vector2 *p_uv, const Baker::MaterialCache &p_material, const Rect3 &p_aabb, Baker *p_baker);
- void _plot_mesh(const Transform &p_xform, Ref<ArrayMesh> &p_mesh, Baker *p_baker, const Vector<Ref<Material> > &p_materials, const Ref<Material> &p_override_material);
+ void _plot_mesh(const Transform &p_xform, Ref<Mesh> &p_mesh, Baker *p_baker, const Vector<Ref<Material> > &p_materials, const Ref<Material> &p_override_material);
void _find_meshes(Node *p_at_node, Baker *p_baker);
void _fixup_plot(int p_idx, int p_level, int p_x, int p_y, int p_z, Baker *p_baker);
@@ -204,6 +208,9 @@ public:
void set_bias(float p_bias);
float get_bias() const;
+ void set_normal_bias(float p_normal_bias);
+ float get_normal_bias() const;
+
void set_propagation(float p_propagation);
float get_propagation() const;
diff --git a/scene/3d/light.cpp b/scene/3d/light.cpp
index 9c87acec6e..977f1f81a7 100644
--- a/scene/3d/light.cpp
+++ b/scene/3d/light.cpp
@@ -29,7 +29,7 @@
/*************************************************************************/
#include "light.h"
-#include "global_config.h"
+#include "project_settings.h"
#include "scene/resources/surface_tool.h"
bool Light::_can_gizmo_scale() const {
diff --git a/scene/3d/mesh_instance.cpp b/scene/3d/mesh_instance.cpp
index e755b1480b..51237c0bc3 100644
--- a/scene/3d/mesh_instance.cpp
+++ b/scene/3d/mesh_instance.cpp
@@ -29,9 +29,10 @@
/*************************************************************************/
#include "mesh_instance.h"
-#include "body_shape.h"
+#include "collision_shape.h"
#include "core_string_names.h"
#include "physics_body.h"
+#include "scene/resources/material.h"
#include "scene/scene_string_names.h"
#include "skeleton.h"
bool MeshInstance::_set(const StringName &p_name, const Variant &p_value) {
@@ -193,7 +194,9 @@ Node *MeshInstance::create_trimesh_collision_node() {
return NULL;
StaticBody *static_body = memnew(StaticBody);
- static_body->add_shape(shape);
+ CollisionShape *cshape = memnew(CollisionShape);
+ cshape->set_shape(shape);
+ static_body->add_child(cshape);
return static_body;
}
@@ -204,13 +207,11 @@ void MeshInstance::create_trimesh_collision() {
static_body->set_name(String(get_name()) + "_col");
add_child(static_body);
- if (get_owner())
+ if (get_owner()) {
+ CollisionShape *cshape = static_body->get_child(0)->cast_to<CollisionShape>();
static_body->set_owner(get_owner());
- CollisionShape *cshape = memnew(CollisionShape);
- cshape->set_shape(static_body->get_shape(0));
- static_body->add_child(cshape);
- if (get_owner())
cshape->set_owner(get_owner());
+ }
}
Node *MeshInstance::create_convex_collision_node() {
@@ -223,7 +224,9 @@ Node *MeshInstance::create_convex_collision_node() {
return NULL;
StaticBody *static_body = memnew(StaticBody);
- static_body->add_shape(shape);
+ CollisionShape *cshape = memnew(CollisionShape);
+ cshape->set_shape(shape);
+ static_body->add_child(cshape);
return static_body;
}
@@ -234,13 +237,11 @@ void MeshInstance::create_convex_collision() {
static_body->set_name(String(get_name()) + "_col");
add_child(static_body);
- if (get_owner())
+ if (get_owner()) {
+ CollisionShape *cshape = static_body->get_child(0)->cast_to<CollisionShape>();
static_body->set_owner(get_owner());
- CollisionShape *cshape = memnew(CollisionShape);
- cshape->set_shape(static_body->get_shape(0));
- static_body->add_child(cshape);
- if (get_owner())
cshape->set_owner(get_owner());
+ }
}
void MeshInstance::_notification(int p_what) {
@@ -274,6 +275,81 @@ void MeshInstance::_mesh_changed() {
materials.resize(mesh->get_surface_count());
}
+void MeshInstance::create_debug_tangents() {
+
+ Vector<Vector3> lines;
+ Vector<Color> colors;
+
+ Ref<Mesh> mesh = get_mesh();
+ if (!mesh.is_valid())
+ return;
+
+ for (int i = 0; i < mesh->get_surface_count(); i++) {
+ Array arrays = mesh->surface_get_arrays(i);
+ Vector<Vector3> verts = arrays[Mesh::ARRAY_VERTEX];
+ Vector<Vector3> norms = arrays[Mesh::ARRAY_NORMAL];
+ if (norms.size() == 0)
+ continue;
+ Vector<float> tangents = arrays[Mesh::ARRAY_TANGENT];
+ if (tangents.size() == 0)
+ continue;
+
+ for (int j = 0; j < verts.size(); j++) {
+ Vector3 v = verts[j];
+ Vector3 n = norms[j];
+ Vector3 t = Vector3(tangents[j * 4 + 0], tangents[j * 4 + 1], tangents[j * 4 + 2]);
+ Vector3 b = (n.cross(t)).normalized() * tangents[j * 4 + 3];
+
+ lines.push_back(v); //normal
+ colors.push_back(Color(0, 0, 1)); //color
+ lines.push_back(v + n * 0.04); //normal
+ colors.push_back(Color(0, 0, 1)); //color
+
+ lines.push_back(v); //tangent
+ colors.push_back(Color(1, 0, 0)); //color
+ lines.push_back(v + t * 0.04); //tangent
+ colors.push_back(Color(1, 0, 0)); //color
+
+ lines.push_back(v); //binormal
+ colors.push_back(Color(0, 1, 0)); //color
+ lines.push_back(v + b * 0.04); //binormal
+ colors.push_back(Color(0, 1, 0)); //color
+ }
+ }
+
+ if (lines.size()) {
+
+ Ref<SpatialMaterial> sm;
+ sm.instance();
+
+ sm->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
+ sm->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true);
+ sm->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
+
+ Ref<ArrayMesh> am;
+ am.instance();
+ Array a;
+ a.resize(Mesh::ARRAY_MAX);
+ a[Mesh::ARRAY_VERTEX] = lines;
+ a[Mesh::ARRAY_COLOR] = colors;
+
+ am->add_surface_from_arrays(Mesh::PRIMITIVE_LINES, a);
+ am->surface_set_material(0, sm);
+
+ MeshInstance *mi = memnew(MeshInstance);
+ mi->set_mesh(am);
+ mi->set_name("DebugTangents");
+ add_child(mi);
+#ifdef TOOLS_ENABLED
+
+ if (this == get_tree()->get_edited_scene_root())
+ mi->set_owner(this);
+ else
+ mi->set_owner(get_owner());
+#endif
+ }
+}
+
void MeshInstance::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_mesh", "mesh:Mesh"), &MeshInstance::set_mesh);
@@ -281,12 +357,18 @@ void MeshInstance::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_skeleton_path", "skeleton_path:NodePath"), &MeshInstance::set_skeleton_path);
ClassDB::bind_method(D_METHOD("get_skeleton_path:NodePath"), &MeshInstance::get_skeleton_path);
+ ClassDB::bind_method(D_METHOD("set_surface_material", "surface", "material:Material"), &MeshInstance::set_surface_material);
+ ClassDB::bind_method(D_METHOD("get_surface_material:Material", "surface"), &MeshInstance::get_surface_material);
+
ClassDB::bind_method(D_METHOD("create_trimesh_collision"), &MeshInstance::create_trimesh_collision);
ClassDB::set_method_flags("MeshInstance", "create_trimesh_collision", METHOD_FLAGS_DEFAULT);
ClassDB::bind_method(D_METHOD("create_convex_collision"), &MeshInstance::create_convex_collision);
ClassDB::set_method_flags("MeshInstance", "create_convex_collision", METHOD_FLAGS_DEFAULT);
ClassDB::bind_method(D_METHOD("_mesh_changed"), &MeshInstance::_mesh_changed);
+ ClassDB::bind_method(D_METHOD("create_debug_tangents"), &MeshInstance::create_debug_tangents);
+ ClassDB::set_method_flags("MeshInstance", "create_debug_tangents", METHOD_FLAGS_DEFAULT | METHOD_FLAG_EDITOR);
+
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "mesh", PROPERTY_HINT_RESOURCE_TYPE, "Mesh"), "set_mesh", "get_mesh");
ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "skeleton"), "set_skeleton_path", "get_skeleton_path");
}
diff --git a/scene/3d/mesh_instance.h b/scene/3d/mesh_instance.h
index c11c52b76d..1bb2c97d10 100644
--- a/scene/3d/mesh_instance.h
+++ b/scene/3d/mesh_instance.h
@@ -83,6 +83,8 @@ public:
Node *create_convex_collision_node();
void create_convex_collision();
+ void create_debug_tangents();
+
virtual Rect3 get_aabb() const;
virtual PoolVector<Face3> get_faces(uint32_t p_usage_flags) const;
diff --git a/scene/3d/multimesh_instance.cpp b/scene/3d/multimesh_instance.cpp
index b51953f27c..b4558698cc 100644
--- a/scene/3d/multimesh_instance.cpp
+++ b/scene/3d/multimesh_instance.cpp
@@ -31,8 +31,8 @@
void MultiMeshInstance::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_multimesh", "multimesh"), &MultiMeshInstance::set_multimesh);
- ClassDB::bind_method(D_METHOD("get_multimesh"), &MultiMeshInstance::get_multimesh);
+ ClassDB::bind_method(D_METHOD("set_multimesh", "multimesh:MultiMesh"), &MultiMeshInstance::set_multimesh);
+ ClassDB::bind_method(D_METHOD("get_multimesh:MultiMesh"), &MultiMeshInstance::get_multimesh);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "multimesh", PROPERTY_HINT_RESOURCE_TYPE, "MultiMesh"), "set_multimesh", "get_multimesh");
}
diff --git a/scene/3d/navigation_mesh.cpp b/scene/3d/navigation_mesh.cpp
index 82f6f665db..7392998d57 100644
--- a/scene/3d/navigation_mesh.cpp
+++ b/scene/3d/navigation_mesh.cpp
@@ -149,8 +149,8 @@ Ref<Mesh> NavigationMesh::get_debug_mesh() {
tw[tidx++] = f.vertex[j];
_EdgeKey ek;
- ek.from = f.vertex[j].snapped(CMP_EPSILON);
- ek.to = f.vertex[(j + 1) % 3].snapped(CMP_EPSILON);
+ ek.from = f.vertex[j].snapped(Vector3(CMP_EPSILON, CMP_EPSILON, CMP_EPSILON));
+ ek.to = f.vertex[(j + 1) % 3].snapped(Vector3(CMP_EPSILON, CMP_EPSILON, CMP_EPSILON));
if (ek.from < ek.to)
SWAP(ek.from, ek.to);
@@ -374,8 +374,8 @@ String NavigationMeshInstance::get_configuration_warning() const {
void NavigationMeshInstance::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_navigation_mesh", "navmesh"), &NavigationMeshInstance::set_navigation_mesh);
- ClassDB::bind_method(D_METHOD("get_navigation_mesh"), &NavigationMeshInstance::get_navigation_mesh);
+ ClassDB::bind_method(D_METHOD("set_navigation_mesh", "navmesh:NavigationMesh"), &NavigationMeshInstance::set_navigation_mesh);
+ ClassDB::bind_method(D_METHOD("get_navigation_mesh:NavigationMesh"), &NavigationMeshInstance::get_navigation_mesh);
ClassDB::bind_method(D_METHOD("set_enabled", "enabled"), &NavigationMeshInstance::set_enabled);
ClassDB::bind_method(D_METHOD("is_enabled"), &NavigationMeshInstance::is_enabled);
diff --git a/scene/3d/physics_body.cpp b/scene/3d/physics_body.cpp
index 2a7a804470..7e599ce2f5 100644
--- a/scene/3d/physics_body.cpp
+++ b/scene/3d/physics_body.cpp
@@ -520,11 +520,11 @@ real_t RigidBody::get_mass() const {
void RigidBody::set_weight(real_t p_weight) {
- set_mass(p_weight / 9.8);
+ set_mass(p_weight / real_t(GLOBAL_DEF("physics/3d/default_gravity", 9.8)));
}
real_t RigidBody::get_weight() const {
- return mass * 9.8;
+ return mass * real_t(GLOBAL_DEF("physics/3d/default_gravity", 9.8));
}
void RigidBody::set_friction(real_t p_friction) {
@@ -879,313 +879,105 @@ RigidBody::~RigidBody() {
//////////////////////////////////////////////////////
//////////////////////////
-Variant KinematicBody::_get_collider() const {
-
- ObjectID oid = get_collider();
- if (oid == 0)
- return Variant();
- Object *obj = ObjectDB::get_instance(oid);
- if (!obj)
- return Variant();
-
- Reference *ref = obj->cast_to<Reference>();
- if (ref) {
- return Ref<Reference>(ref);
- }
+Dictionary KinematicBody::_move(const Vector3 &p_motion) {
+
+ Collision col;
+ if (move(p_motion, col)) {
+ Dictionary d;
+ d["position"] = col.collision;
+ d["normal"] = col.collision;
+ d["local_shape"] = col.local_shape;
+ d["travel"] = col.travel;
+ d["remainder"] = col.remainder;
+ d["collider_id"] = col.collider;
+ if (col.collider) {
+ d["collider"] = ObjectDB::get_instance(col.collider);
+ } else {
+ d["collider"] = Variant();
+ }
- return obj;
-}
+ d["collider_shape_index"] = col.collider_shape;
+ d["collider_metadata"] = col.collider_metadata;
-bool KinematicBody::_ignores_mode(PhysicsServer::BodyMode p_mode) const {
+ return d;
- switch (p_mode) {
- case PhysicsServer::BODY_MODE_STATIC: return !collide_static;
- case PhysicsServer::BODY_MODE_KINEMATIC: return !collide_kinematic;
- case PhysicsServer::BODY_MODE_RIGID: return !collide_rigid;
- case PhysicsServer::BODY_MODE_CHARACTER: return !collide_character;
+ } else {
+ return Dictionary();
}
-
- return true;
}
-void KinematicBody::revert_motion() {
+bool KinematicBody::move(const Vector3 &p_motion, Collision &r_collision) {
Transform gt = get_global_transform();
- gt.origin -= travel; //I do hope this is correct.
- travel = Vector3();
- set_global_transform(gt);
-}
-
-Vector3 KinematicBody::get_travel() const {
-
- return travel;
-}
-
-Vector3 KinematicBody::move(const Vector3 &p_motion) {
-
- //give me back regular physics engine logic
- //this is madness
- //and most people using this function will think
- //what it does is simpler than using physics
- //this took about a week to get right..
- //but is it right? who knows at this point..
-
- colliding = false;
- ERR_FAIL_COND_V(!is_inside_tree(), Vector3());
- PhysicsDirectSpaceState *dss = PhysicsServer::get_singleton()->space_get_direct_state(get_world()->get_space());
- ERR_FAIL_COND_V(!dss, Vector3());
- const int max_shapes = 32;
- Vector3 sr[max_shapes * 2];
- int res_shapes;
-
- Set<RID> exclude;
- exclude.insert(get_rid());
-
- //recover first
- int recover_attempts = 4;
-
- bool collided = false;
- uint32_t mask = 0;
- if (collide_static)
- mask |= PhysicsDirectSpaceState::TYPE_MASK_STATIC_BODY;
- if (collide_kinematic)
- mask |= PhysicsDirectSpaceState::TYPE_MASK_KINEMATIC_BODY;
- if (collide_rigid)
- mask |= PhysicsDirectSpaceState::TYPE_MASK_RIGID_BODY;
- if (collide_character)
- mask |= PhysicsDirectSpaceState::TYPE_MASK_CHARACTER_BODY;
-
- //print_line("motion: "+p_motion+" margin: "+rtos(margin));
-
- //print_line("margin: "+rtos(margin));
-
- float m = margin;
- //m=0.001;
-
- do {
-
- //motion recover
- for (int i = 0; i < get_shape_count(); i++) {
-
- if (is_shape_set_as_trigger(i))
- continue;
-
- if (dss->collide_shape(get_shape(i)->get_rid(), get_global_transform() * get_shape_transform(i), m, sr, max_shapes, res_shapes, exclude, get_collision_layer(), mask)) {
- collided = true;
- }
- }
-
- if (!collided)
- break;
-
- //print_line("have to recover");
- Vector3 recover_motion;
- bool all_outside = true;
- for (int j = 0; j < 8; j++) {
- for (int i = 0; i < res_shapes; i++) {
-
- Vector3 a = sr[i * 2 + 0];
- Vector3 b = sr[i * 2 + 1];
-//print_line(String()+a+" -> "+b);
-#if 0
- float d = a.distance_to(b);
-
- /*
- if (d<margin)
- continue;
- */
- recover_motion+=(b-a)*0.2;
-#else
- float dist = a.distance_to(b);
- if (dist > CMP_EPSILON) {
- Vector3 norm = (b - a).normalized();
- if (dist > margin * 0.5)
- all_outside = false;
- float adv = norm.dot(recover_motion);
- //print_line(itos(i)+" dist: "+rtos(dist)+" adv: "+rtos(adv));
- recover_motion += norm * MAX(dist - adv, 0) * 0.4;
- }
-#endif
- }
- }
-
- if (recover_motion == Vector3()) {
- collided = false;
- break;
- }
-
- //print_line("**** RECOVER: "+recover_motion);
-
- Transform gt = get_global_transform();
- gt.origin += recover_motion;
- set_global_transform(gt);
-
- recover_attempts--;
-
- if (all_outside)
- break;
-
- } while (recover_attempts);
-
- //move second
- float safe = 1.0;
- float unsafe = 1.0;
- int best_shape = -1;
-
- PhysicsDirectSpaceState::ShapeRestInfo rest;
-
- //print_line("pos: "+get_global_transform().origin);
- //print_line("motion: "+p_motion);
-
- for (int i = 0; i < get_shape_count(); i++) {
-
- if (is_shape_set_as_trigger(i))
- continue;
-
- float lsafe, lunsafe;
- PhysicsDirectSpaceState::ShapeRestInfo lrest;
- bool valid = dss->cast_motion(get_shape(i)->get_rid(), get_global_transform() * get_shape_transform(i), p_motion, 0, lsafe, lunsafe, exclude, get_collision_layer(), mask, &lrest);
- //print_line("shape: "+itos(i)+" travel:"+rtos(ltravel));
- if (!valid) {
- safe = 0;
- unsafe = 0;
- best_shape = i; //sadly it's the best
- //print_line("initial stuck");
-
- break;
- }
- if (lsafe == 1.0) {
- //print_line("initial free");
- continue;
- }
- if (lsafe < safe) {
-
- //print_line("initial at "+rtos(lsafe));
- safe = lsafe;
- safe = MAX(0, lsafe - 0.01);
- unsafe = lunsafe;
- best_shape = i;
- rest = lrest;
- }
- }
-
- //print_line("best shape: "+itos(best_shape)+" motion "+p_motion);
-
- if (safe >= 1) {
- //not collided
- colliding = false;
- } else {
-
- colliding = true;
-
- if (true || (safe == 0 && unsafe == 0)) { //use it always because it's more precise than GJK
- //no advance, use rest info from collision
- Transform ugt = get_global_transform();
- ugt.origin += p_motion * unsafe;
-
- PhysicsDirectSpaceState::ShapeRestInfo rest_info;
- bool c2 = dss->rest_info(get_shape(best_shape)->get_rid(), ugt * get_shape_transform(best_shape), m, &rest, exclude, get_collision_layer(), mask);
- if (!c2) {
- //should not happen, but floating point precision is so weird..
- colliding = false;
- }
-
- //print_line("Rest Travel: "+rest.normal);
- }
-
- if (colliding) {
-
- collision = rest.point;
- normal = rest.normal;
- collider = rest.collider_id;
- collider_vel = rest.linear_velocity;
- collider_shape = rest.shape;
- }
+ PhysicsServer::MotionResult result;
+ bool colliding = PhysicsServer::get_singleton()->body_test_motion(get_rid(), gt, p_motion, margin, &result);
+
+ if (colliding) {
+ r_collision.collider_metadata = result.collider_metadata;
+ r_collision.collider_shape = result.collider_shape;
+ r_collision.collider_vel = result.collider_velocity;
+ r_collision.collision = result.collision_point;
+ r_collision.normal = result.collision_normal;
+ r_collision.collider = result.collider_id;
+ r_collision.travel = result.motion;
+ r_collision.remainder = result.remainder;
+ r_collision.local_shape = result.collision_local_shape;
}
- Vector3 motion = p_motion * safe;
- /*
- if (colliding)
- motion+=normal*0.001;
- */
- Transform gt = get_global_transform();
- gt.origin += motion;
+ gt.origin += result.motion;
set_global_transform(gt);
- travel = motion;
- return p_motion - motion;
+ return colliding;
}
-Vector3 KinematicBody::move_and_slide(const Vector3 &p_linear_velocity, const Vector3 &p_floor_direction, const Vector3 &p_ceil_direction, float p_slope_stop_min_velocity, int p_max_bounces, float p_floor_max_angle, float p_ceil_max_angle) {
+Vector3 KinematicBody::move_and_slide(const Vector3 &p_linear_velocity, const Vector3 &p_floor_direction, float p_slope_stop_min_velocity, int p_max_bounces, float p_floor_max_angle) {
- /*
- Things to note:
- 1. This function is basically the KinematicBody2D function ported over.
- 2. The 'travel' variable and stuff relating to it exists more or less for this function's sake.
- 3. Someone is going to have to document this, so here's an example for them:
- vel = move_and_slide(vel, Vector3(0, 1, 0), Vector3(0, -1, 0), 0.1);
- Very useful for FPS controllers so long as you control horizontal motion properly - even for Quake-style AABB colliders.
- The slope stop system is... rather weird, and it's correct operation depends on what scale your game is built on,
- but as far as I can tell in theory it's suppposed to be a way of turning impassable slopes into invisible walls.
- It can also be a pain, since there's a better-known way of defining such things: "let gravity do the work".
- If you don't like it, set it to positive infinity.
- 4. Might be a bug somewhere else in physics: When there are two CollisionShape nodes with a shared Shape, only one is considered, I think.
- Test this further.
- */
-
- Vector3 motion = (move_and_slide_floor_velocity + p_linear_velocity) * get_fixed_process_delta_time();
+ Vector3 motion = (floor_velocity + p_linear_velocity) * get_fixed_process_delta_time();
Vector3 lv = p_linear_velocity;
- move_and_slide_on_floor = false;
- move_and_slide_on_ceiling = false;
- move_and_slide_on_wall = false;
- move_and_slide_colliders.clear();
- move_and_slide_floor_velocity = Vector3();
+ on_floor = false;
+ on_ceiling = false;
+ on_wall = false;
+ colliders.clear();
+ floor_velocity = Vector3();
while (p_max_bounces) {
- motion = move(motion);
+ Collision collision;
- if (is_colliding()) {
+ bool collided = move(motion, collision);
- bool hit_horizontal = false; //hit floor or ceiling
+ if (collided) {
- if (p_floor_direction != Vector3()) {
- if (get_collision_normal().dot(p_floor_direction) >= Math::cos(p_floor_max_angle)) { //floor
+ motion = collision.remainder;
- hit_horizontal = true;
- move_and_slide_on_floor = true;
- move_and_slide_floor_velocity = get_collider_velocity();
+ if (p_floor_direction == Vector3()) {
+ //all is a wall
+ on_wall = true;
+ } else {
+ if (collision.normal.dot(p_floor_direction) >= Math::cos(p_floor_max_angle)) { //floor
- //Note: These two lines are the only lines that really changed between 3D/2D, see if it can't be reused somehow???
- Vector2 hz_velocity = Vector2(lv.x - move_and_slide_floor_velocity.x, lv.z - move_and_slide_floor_velocity.z);
- if (get_travel().length() < 1 && hz_velocity.length() < p_slope_stop_min_velocity) {
- revert_motion();
- return Vector3();
- }
- }
- }
+ on_floor = true;
+ floor_velocity = collision.collider_vel;
- if (p_ceil_direction != Vector3()) {
- if (get_collision_normal().dot(p_ceil_direction) >= Math::cos(p_ceil_max_angle)) { //ceiling
- hit_horizontal = true;
- move_and_slide_on_ceiling = true;
+ /*if (collision.travel.length() < 0.01 && ABS((lv.x - floor_velocity.x)) < p_slope_stop_min_velocity) {
+ Transform gt = get_global_transform();
+ gt.elements[2] -= collision.travel;
+ set_global_transform(gt);
+ return Vector3();
+ }*/
+ } else if (collision.normal.dot(-p_floor_direction) >= Math::cos(p_floor_max_angle)) { //ceiling
+ on_ceiling = true;
+ } else {
+ on_wall = true;
}
}
- //if it hit something but didn't hit a floor or ceiling, it is by default a wall
- //(this imitates the pre-specifiable-ceiling logic more or less, except ceiling is optional)
- if (!hit_horizontal) {
- move_and_slide_on_wall = true;
- }
-
- Vector3 n = get_collision_normal();
+ Vector3 n = collision.normal;
motion = motion.slide(n);
lv = lv.slide(n);
- Variant collider = _get_collider();
- if (collider.get_type() != Variant::NIL) {
- move_and_slide_colliders.push_back(collider);
- }
+
+ colliders.push_back(collision);
} else {
break;
@@ -1199,199 +991,148 @@ Vector3 KinematicBody::move_and_slide(const Vector3 &p_linear_velocity, const Ve
return lv;
}
-bool KinematicBody::is_move_and_slide_on_floor() const {
-
- return move_and_slide_on_floor;
-}
-bool KinematicBody::is_move_and_slide_on_wall() const {
+bool KinematicBody::is_on_floor() const {
- return move_and_slide_on_wall;
+ return on_floor;
}
-bool KinematicBody::is_move_and_slide_on_ceiling() const {
+bool KinematicBody::is_on_wall() const {
- return move_and_slide_on_ceiling;
+ return on_wall;
}
-Array KinematicBody::get_move_and_slide_colliders() const {
+bool KinematicBody::is_on_ceiling() const {
- return move_and_slide_colliders;
+ return on_ceiling;
}
-Vector3 KinematicBody::move_to(const Vector3 &p_position) {
+Vector3 KinematicBody::get_floor_velocity() const {
- return move(p_position - get_global_transform().origin);
+ return floor_velocity;
}
-bool KinematicBody::can_teleport_to(const Vector3 &p_position) {
+bool KinematicBody::test_move(const Transform &p_from, const Vector3 &p_motion) {
ERR_FAIL_COND_V(!is_inside_tree(), false);
- PhysicsDirectSpaceState *dss = PhysicsServer::get_singleton()->space_get_direct_state(get_world()->get_space());
- ERR_FAIL_COND_V(!dss, false);
-
- uint32_t mask = 0;
- if (collide_static)
- mask |= PhysicsDirectSpaceState::TYPE_MASK_STATIC_BODY;
- if (collide_kinematic)
- mask |= PhysicsDirectSpaceState::TYPE_MASK_KINEMATIC_BODY;
- if (collide_rigid)
- mask |= PhysicsDirectSpaceState::TYPE_MASK_RIGID_BODY;
- if (collide_character)
- mask |= PhysicsDirectSpaceState::TYPE_MASK_CHARACTER_BODY;
-
- Transform xform = get_global_transform();
- xform.origin = p_position;
-
- Set<RID> exclude;
- exclude.insert(get_rid());
-
- for (int i = 0; i < get_shape_count(); i++) {
-
- if (is_shape_set_as_trigger(i))
- continue;
-
- bool col = dss->intersect_shape(get_shape(i)->get_rid(), xform * get_shape_transform(i), 0, NULL, 1, exclude, get_collision_layer(), mask);
- if (col)
- return false;
- }
- return true;
+ return PhysicsServer::get_singleton()->body_test_motion(get_rid(), p_from, p_motion, margin);
}
-bool KinematicBody::is_colliding() const {
+void KinematicBody::set_safe_margin(float p_margin) {
- ERR_FAIL_COND_V(!is_inside_tree(), false);
-
- return colliding;
+ margin = p_margin;
}
-Vector3 KinematicBody::get_collision_pos() const {
- ERR_FAIL_COND_V(!colliding, Vector3());
- return collision;
-}
-Vector3 KinematicBody::get_collision_normal() const {
+float KinematicBody::get_safe_margin() const {
- ERR_FAIL_COND_V(!colliding, Vector3());
- return normal;
+ return margin;
}
-Vector3 KinematicBody::get_collider_velocity() const {
+int KinematicBody::get_collision_count() const {
- return collider_vel;
+ return colliders.size();
}
+Vector3 KinematicBody::get_collision_position(int p_collision) const {
-ObjectID KinematicBody::get_collider() const {
-
- ERR_FAIL_COND_V(!colliding, 0);
- return collider;
-}
-int KinematicBody::get_collider_shape() const {
+ ERR_FAIL_INDEX_V(p_collision, colliders.size(), Vector3());
- ERR_FAIL_COND_V(!colliding, -1);
- return collider_shape;
+ return colliders[p_collision].collision;
}
-void KinematicBody::set_collide_with_static_bodies(bool p_enable) {
-
- collide_static = p_enable;
+Vector3 KinematicBody::get_collision_normal(int p_collision) const {
+ ERR_FAIL_INDEX_V(p_collision, colliders.size(), Vector3());
+ return colliders[p_collision].normal;
}
-bool KinematicBody::can_collide_with_static_bodies() const {
- return collide_static;
+Vector3 KinematicBody::get_collision_travel(int p_collision) const {
+ ERR_FAIL_INDEX_V(p_collision, colliders.size(), Vector3());
+ return colliders[p_collision].travel;
}
-
-void KinematicBody::set_collide_with_rigid_bodies(bool p_enable) {
-
- collide_rigid = p_enable;
+Vector3 KinematicBody::get_collision_remainder(int p_collision) const {
+ ERR_FAIL_INDEX_V(p_collision, colliders.size(), Vector3());
+ return colliders[p_collision].remainder;
}
-bool KinematicBody::can_collide_with_rigid_bodies() const {
-
- return collide_rigid;
+Object *KinematicBody::get_collision_local_shape(int p_collision) const {
+ ERR_FAIL_INDEX_V(p_collision, colliders.size(), NULL);
+ uint32_t owner = shape_find_owner(colliders[p_collision].local_shape);
+ return shape_owner_get_owner(owner);
}
+Object *KinematicBody::get_collision_collider(int p_collision) const {
+ ERR_FAIL_INDEX_V(p_collision, colliders.size(), NULL);
-void KinematicBody::set_collide_with_kinematic_bodies(bool p_enable) {
+ if (colliders[p_collision].collider) {
+ return ObjectDB::get_instance(colliders[p_collision].collider);
+ }
- collide_kinematic = p_enable;
+ return NULL;
}
-bool KinematicBody::can_collide_with_kinematic_bodies() const {
+ObjectID KinematicBody::get_collision_collider_id(int p_collision) const {
+ ERR_FAIL_INDEX_V(p_collision, colliders.size(), 0);
- return collide_kinematic;
+ return colliders[p_collision].collider;
}
+Object *KinematicBody::get_collision_collider_shape(int p_collision) const {
+ ERR_FAIL_INDEX_V(p_collision, colliders.size(), NULL);
+ Object *collider = get_collision_collider(p_collision);
+ if (collider) {
+ CollisionObject *obj2d = collider->cast_to<CollisionObject>();
+ if (obj2d) {
+ uint32_t owner = shape_find_owner(colliders[p_collision].collider_shape);
+ return obj2d->shape_owner_get_owner(owner);
+ }
+ }
-void KinematicBody::set_collide_with_character_bodies(bool p_enable) {
-
- collide_character = p_enable;
+ return NULL;
}
-bool KinematicBody::can_collide_with_character_bodies() const {
-
- return collide_character;
+int KinematicBody::get_collision_collider_shape_index(int p_collision) const {
+ ERR_FAIL_INDEX_V(p_collision, colliders.size(), -1);
+ return colliders[p_collision].collider_shape;
}
-
-void KinematicBody::set_collision_margin(float p_margin) {
-
- margin = p_margin;
+Vector3 KinematicBody::get_collision_collider_velocity(int p_collision) const {
+ ERR_FAIL_INDEX_V(p_collision, colliders.size(), Vector3());
+ return colliders[p_collision].collider_vel;
}
-
-float KinematicBody::get_collision_margin() const {
-
- return margin;
+Variant KinematicBody::get_collision_collider_metadata(int p_collision) const {
+ ERR_FAIL_INDEX_V(p_collision, colliders.size(), Variant());
+ return colliders[p_collision].collider_metadata;
}
void KinematicBody::_bind_methods() {
- ClassDB::bind_method(D_METHOD("move", "rel_vec"), &KinematicBody::move);
- ClassDB::bind_method(D_METHOD("move_to", "position"), &KinematicBody::move_to);
- ClassDB::bind_method(D_METHOD("move_and_slide", "linear_velocity", "floor_normal", "ceil_normal", "slope_stop_min_velocity", "max_bounces", "floor_max_angle", "ceil_max_angle"), &KinematicBody::move_and_slide, DEFVAL(Vector3(0, 0, 0)), DEFVAL(Vector3(0, 0, 0)), DEFVAL(5), DEFVAL(4), DEFVAL(Math::deg2rad((float)45)), DEFVAL(Math::deg2rad((float)45)));
-
- ClassDB::bind_method(D_METHOD("can_teleport_to", "position"), &KinematicBody::can_teleport_to);
+ ClassDB::bind_method(D_METHOD("move", "rel_vec"), &KinematicBody::_move);
+ ClassDB::bind_method(D_METHOD("move_and_slide", "linear_velocity", "floor_normal", "slope_stop_min_velocity", "max_bounces", "floor_max_angle"), &KinematicBody::move_and_slide, DEFVAL(Vector3(0, 0, 0)), DEFVAL(0.05), DEFVAL(4), DEFVAL(Math::deg2rad((float)45)));
- ClassDB::bind_method(D_METHOD("is_colliding"), &KinematicBody::is_colliding);
+ ClassDB::bind_method(D_METHOD("test_move", "from", "rel_vec"), &KinematicBody::test_move);
- ClassDB::bind_method(D_METHOD("get_collision_pos"), &KinematicBody::get_collision_pos);
- ClassDB::bind_method(D_METHOD("get_collision_normal"), &KinematicBody::get_collision_normal);
- ClassDB::bind_method(D_METHOD("get_collider_velocity"), &KinematicBody::get_collider_velocity);
- ClassDB::bind_method(D_METHOD("get_collider:Variant"), &KinematicBody::_get_collider);
- ClassDB::bind_method(D_METHOD("get_collider_shape"), &KinematicBody::get_collider_shape);
+ ClassDB::bind_method(D_METHOD("is_on_floor"), &KinematicBody::is_on_floor);
+ ClassDB::bind_method(D_METHOD("is_on_ceiling"), &KinematicBody::is_on_ceiling);
+ ClassDB::bind_method(D_METHOD("is_on_wall"), &KinematicBody::is_on_wall);
+ ClassDB::bind_method(D_METHOD("get_floor_velocity"), &KinematicBody::get_floor_velocity);
- ClassDB::bind_method(D_METHOD("set_collide_with_static_bodies", "enable"), &KinematicBody::set_collide_with_static_bodies);
- ClassDB::bind_method(D_METHOD("can_collide_with_static_bodies"), &KinematicBody::can_collide_with_static_bodies);
+ ClassDB::bind_method(D_METHOD("set_safe_margin", "pixels"), &KinematicBody::set_safe_margin);
+ ClassDB::bind_method(D_METHOD("get_safe_margin", "pixels"), &KinematicBody::get_safe_margin);
- ClassDB::bind_method(D_METHOD("set_collide_with_kinematic_bodies", "enable"), &KinematicBody::set_collide_with_kinematic_bodies);
- ClassDB::bind_method(D_METHOD("can_collide_with_kinematic_bodies"), &KinematicBody::can_collide_with_kinematic_bodies);
+ ClassDB::bind_method(D_METHOD("get_collision_count"), &KinematicBody::get_collision_count);
+ ClassDB::bind_method(D_METHOD("get_collision_position", "collision"), &KinematicBody::get_collision_position);
+ ClassDB::bind_method(D_METHOD("get_collision_normal", "collision"), &KinematicBody::get_collision_normal);
+ ClassDB::bind_method(D_METHOD("get_collision_travel", "collision"), &KinematicBody::get_collision_travel);
+ ClassDB::bind_method(D_METHOD("get_collision_remainder", "collision"), &KinematicBody::get_collision_remainder);
+ ClassDB::bind_method(D_METHOD("get_collision_local_shape", "collision"), &KinematicBody::get_collision_local_shape);
+ ClassDB::bind_method(D_METHOD("get_collision_collider", "collision"), &KinematicBody::get_collision_collider);
+ ClassDB::bind_method(D_METHOD("get_collision_collider_id", "collision"), &KinematicBody::get_collision_collider_id);
+ ClassDB::bind_method(D_METHOD("get_collision_collider_shape", "collision"), &KinematicBody::get_collision_collider_shape);
+ ClassDB::bind_method(D_METHOD("get_collision_collider_shape_index", "collision"), &KinematicBody::get_collision_collider_shape_index);
+ ClassDB::bind_method(D_METHOD("get_collision_collider_velocity", "collision"), &KinematicBody::get_collision_collider_velocity);
+ ClassDB::bind_method(D_METHOD("get_collision_collider_metadata", "collision"), &KinematicBody::get_collision_collider_metadata);
- ClassDB::bind_method(D_METHOD("set_collide_with_rigid_bodies", "enable"), &KinematicBody::set_collide_with_rigid_bodies);
- ClassDB::bind_method(D_METHOD("can_collide_with_rigid_bodies"), &KinematicBody::can_collide_with_rigid_bodies);
-
- ClassDB::bind_method(D_METHOD("set_collide_with_character_bodies", "enable"), &KinematicBody::set_collide_with_character_bodies);
- ClassDB::bind_method(D_METHOD("can_collide_with_character_bodies"), &KinematicBody::can_collide_with_character_bodies);
-
- ClassDB::bind_method(D_METHOD("set_collision_margin", "pixels"), &KinematicBody::set_collision_margin);
- ClassDB::bind_method(D_METHOD("get_collision_margin", "pixels"), &KinematicBody::get_collision_margin);
-
- ClassDB::bind_method(D_METHOD("get_travel"), &KinematicBody::get_travel);
- ClassDB::bind_method(D_METHOD("revert_motion"), &KinematicBody::revert_motion);
-
- ClassDB::bind_method(D_METHOD("get_move_and_slide_colliders"), &KinematicBody::get_move_and_slide_colliders);
- ClassDB::bind_method(D_METHOD("is_move_and_slide_on_floor"), &KinematicBody::is_move_and_slide_on_floor);
- ClassDB::bind_method(D_METHOD("is_move_and_slide_on_ceiling"), &KinematicBody::is_move_and_slide_on_ceiling);
- ClassDB::bind_method(D_METHOD("is_move_and_slide_on_wall"), &KinematicBody::is_move_and_slide_on_wall);
-
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collide_with/static"), "set_collide_with_static_bodies", "can_collide_with_static_bodies");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collide_with/kinematic"), "set_collide_with_kinematic_bodies", "can_collide_with_kinematic_bodies");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collide_with/rigid"), "set_collide_with_rigid_bodies", "can_collide_with_rigid_bodies");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collide_with/character"), "set_collide_with_character_bodies", "can_collide_with_character_bodies");
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "collision/margin", PROPERTY_HINT_RANGE, "0.001,256,0.001"), "set_collision_margin", "get_collision_margin");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "collision/safe_margin", PROPERTY_HINT_RANGE, "0.001,256,0.001"), "set_safe_margin", "get_safe_margin");
}
KinematicBody::KinematicBody()
: PhysicsBody(PhysicsServer::BODY_MODE_KINEMATIC) {
- collide_static = true;
- collide_rigid = true;
- collide_kinematic = true;
- collide_character = true;
-
- colliding = false;
- collider = 0;
margin = 0.001;
- collider_shape = 0;
+
+ on_floor = false;
+ on_ceiling = false;
+ on_wall = false;
}
KinematicBody::~KinematicBody() {
}
diff --git a/scene/3d/physics_body.h b/scene/3d/physics_body.h
index db4147f8f6..f86d7d957f 100644
--- a/scene/3d/physics_body.h
+++ b/scene/3d/physics_body.h
@@ -263,75 +263,60 @@ class KinematicBody : public PhysicsBody {
GDCLASS(KinematicBody, PhysicsBody);
- float margin;
- bool collide_static;
- bool collide_rigid;
- bool collide_kinematic;
- bool collide_character;
-
- bool colliding;
- Vector3 collision;
- Vector3 normal;
- Vector3 collider_vel;
- ObjectID collider;
- int collider_shape;
- Vector3 travel;
-
- Vector3 move_and_slide_floor_velocity;
- bool move_and_slide_on_floor;
- bool move_and_slide_on_ceiling;
- bool move_and_slide_on_wall;
- Array move_and_slide_colliders;
-
- Variant _get_collider() const;
-
- _FORCE_INLINE_ bool _ignores_mode(PhysicsServer::BodyMode) const;
-
-protected:
- static void _bind_methods();
-
public:
- enum {
- SLIDE_FLAG_FLOOR,
- SLIDE_FLAG_WALL,
- SLIDE_FLAG_ROOF
+ struct Collision {
+ Vector3 collision;
+ Vector3 normal;
+ Vector3 collider_vel;
+ ObjectID collider;
+ int collider_shape;
+ Variant collider_metadata;
+ Vector3 remainder;
+ Vector3 travel;
+ int local_shape;
};
- Vector3 move(const Vector3 &p_motion);
- Vector3 move_to(const Vector3 &p_position);
-
- bool can_teleport_to(const Vector3 &p_position);
- bool is_colliding() const;
-
- Vector3 get_travel() const; // Set by move and others. Consider unreliable except immediately after a move call.
- void revert_motion();
-
- Vector3 get_collision_pos() const;
- Vector3 get_collision_normal() const;
- Vector3 get_collider_velocity() const;
- ObjectID get_collider() const;
- int get_collider_shape() const;
-
- void set_collide_with_static_bodies(bool p_enable);
- bool can_collide_with_static_bodies() const;
+private:
+ float margin;
- void set_collide_with_rigid_bodies(bool p_enable);
- bool can_collide_with_rigid_bodies() const;
+ Vector3 floor_velocity;
+ bool on_floor;
+ bool on_ceiling;
+ bool on_wall;
+ Vector<Collision> colliders;
- void set_collide_with_kinematic_bodies(bool p_enable);
- bool can_collide_with_kinematic_bodies() const;
+ _FORCE_INLINE_ bool _ignores_mode(PhysicsServer::BodyMode) const;
- void set_collide_with_character_bodies(bool p_enable);
- bool can_collide_with_character_bodies() const;
+ Dictionary _move(const Vector3 &p_motion);
- void set_collision_margin(float p_margin);
- float get_collision_margin() const;
+protected:
+ static void _bind_methods();
- Vector3 move_and_slide(const Vector3 &p_linear_velocity, const Vector3 &p_floor_direction = Vector3(0, 0, 0), const Vector3 &p_ceil_direction = Vector3(0, 0, 0), float p_slope_stop_min_velocity = 5, int p_max_bounces = 4, float p_floor_max_angle = Math::deg2rad((float)45), float p_ceil_max_angle = Math::deg2rad((float)45));
- bool is_move_and_slide_on_floor() const;
- bool is_move_and_slide_on_wall() const;
- bool is_move_and_slide_on_ceiling() const;
- Array get_move_and_slide_colliders() const;
+public:
+ bool move(const Vector3 &p_motion, Collision &r_collision);
+ bool test_move(const Transform &p_from, const Vector3 &p_motion);
+
+ void set_safe_margin(float p_margin);
+ float get_safe_margin() const;
+
+ Vector3 move_and_slide(const Vector3 &p_linear_velocity, const Vector3 &p_floor_direction = Vector3(0, 0, 0), float p_slope_stop_min_velocity = 0.05, int p_max_bounces = 4, float p_floor_max_angle = Math::deg2rad((float)45));
+ bool is_on_floor() const;
+ bool is_on_wall() const;
+ bool is_on_ceiling() const;
+ Vector3 get_floor_velocity() const;
+
+ int get_collision_count() const;
+ Vector3 get_collision_position(int p_collision) const;
+ Vector3 get_collision_normal(int p_collision) const;
+ Vector3 get_collision_travel(int p_collision) const;
+ Vector3 get_collision_remainder(int p_collision) const;
+ Object *get_collision_local_shape(int p_collision) const;
+ Object *get_collision_collider(int p_collision) const;
+ ObjectID get_collision_collider_id(int p_collision) const;
+ Object *get_collision_collider_shape(int p_collision) const;
+ int get_collision_collider_shape_index(int p_collision) const;
+ Vector3 get_collision_collider_velocity(int p_collision) const;
+ Variant get_collision_collider_metadata(int p_collision) const;
KinematicBody();
~KinematicBody();
diff --git a/scene/3d/portal.cpp b/scene/3d/portal.cpp
index 64a9dc14ab..d77dde1dd8 100644
--- a/scene/3d/portal.cpp
+++ b/scene/3d/portal.cpp
@@ -28,7 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "portal.h"
-#include "global_config.h"
+#include "project_settings.h"
#include "scene/resources/surface_tool.h"
#include "servers/visual_server.h"
diff --git a/scene/3d/reflection_probe.cpp b/scene/3d/reflection_probe.cpp
index 86a62bec97..0dc5b58e45 100644
--- a/scene/3d/reflection_probe.cpp
+++ b/scene/3d/reflection_probe.cpp
@@ -162,7 +162,7 @@ bool ReflectionProbe::are_shadows_enabled() const {
void ReflectionProbe::set_cull_mask(uint32_t p_layers) {
cull_mask = p_layers;
- VS::get_singleton()->reflection_probe_set_enable_shadows(probe, p_layers);
+ VS::get_singleton()->reflection_probe_set_cull_mask(probe, p_layers);
}
uint32_t ReflectionProbe::get_cull_mask() const {
diff --git a/scene/3d/remote_transform.cpp b/scene/3d/remote_transform.cpp
index b36f444bea..4dcfb5f94e 100644
--- a/scene/3d/remote_transform.cpp
+++ b/scene/3d/remote_transform.cpp
@@ -63,7 +63,45 @@ void RemoteTransform::_update_remote() {
return;
//todo make faster
- n->set_global_transform(get_global_transform());
+ if (use_global_coordinates) {
+
+ if (update_remote_position && update_remote_rotation && update_remote_scale) {
+ n->set_global_transform(get_global_transform());
+ } else {
+ Transform n_trans = n->get_global_transform();
+ Transform our_trans = get_global_transform();
+
+ if (!update_remote_position)
+ our_trans.set_origin(n_trans.get_origin());
+
+ n->set_global_transform(our_trans);
+
+ if (!update_remote_rotation)
+ n->set_rotation(n_trans.basis.get_rotation());
+
+ if (!update_remote_scale)
+ n->set_scale(n_trans.basis.get_scale());
+ }
+
+ } else {
+ if (update_remote_position && update_remote_rotation && update_remote_scale) {
+ n->set_global_transform(get_global_transform());
+ } else {
+ Transform n_trans = n->get_transform();
+ Transform our_trans = get_transform();
+
+ if (!update_remote_position)
+ our_trans.set_origin(n_trans.get_origin());
+
+ n->set_transform(our_trans);
+
+ if (!update_remote_rotation)
+ n->set_rotation(n_trans.basis.get_rotation());
+
+ if (!update_remote_scale)
+ n->set_scale(n_trans.basis.get_scale());
+ }
+ }
}
void RemoteTransform::_notification(int p_what) {
@@ -102,6 +140,41 @@ NodePath RemoteTransform::get_remote_node() const {
return remote_node;
}
+void RemoteTransform::set_use_global_coordinates(const bool p_enable) {
+ use_global_coordinates = p_enable;
+}
+
+bool RemoteTransform::get_use_global_coordinates() const {
+ return use_global_coordinates;
+}
+
+void RemoteTransform::set_update_position(const bool p_update) {
+ update_remote_position = p_update;
+ _update_remote();
+}
+
+bool RemoteTransform::get_update_position() const {
+ return update_remote_position;
+}
+
+void RemoteTransform::set_update_rotation(const bool p_update) {
+ update_remote_rotation = p_update;
+ _update_remote();
+}
+
+bool RemoteTransform::get_update_rotation() const {
+ return update_remote_rotation;
+}
+
+void RemoteTransform::set_update_scale(const bool p_update) {
+ update_remote_scale = p_update;
+ _update_remote();
+}
+
+bool RemoteTransform::get_update_scale() const {
+ return update_remote_scale;
+}
+
String RemoteTransform::get_configuration_warning() const {
if (!has_node(remote_node) || !get_node(remote_node) || !get_node(remote_node)->cast_to<Spatial>()) {
@@ -116,11 +189,32 @@ void RemoteTransform::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_remote_node", "path"), &RemoteTransform::set_remote_node);
ClassDB::bind_method(D_METHOD("get_remote_node"), &RemoteTransform::get_remote_node);
+ ClassDB::bind_method(D_METHOD("set_use_global_coordinates", "use_global_coordinates"), &RemoteTransform::set_use_global_coordinates);
+ ClassDB::bind_method(D_METHOD("get_use_global_coordinates"), &RemoteTransform::get_use_global_coordinates);
+
+ ClassDB::bind_method(D_METHOD("set_update_position", "update_remote_position"), &RemoteTransform::set_update_position);
+ ClassDB::bind_method(D_METHOD("get_update_position"), &RemoteTransform::get_update_position);
+ ClassDB::bind_method(D_METHOD("set_update_rotation", "update_remote_rotation"), &RemoteTransform::set_update_rotation);
+ ClassDB::bind_method(D_METHOD("get_update_rotation"), &RemoteTransform::get_update_rotation);
+ ClassDB::bind_method(D_METHOD("set_update_scale", "update_remote_scale"), &RemoteTransform::set_update_scale);
+ ClassDB::bind_method(D_METHOD("get_update_scale"), &RemoteTransform::get_update_scale);
+
ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "remote_path"), "set_remote_node", "get_remote_node");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_global_coordinates"), "set_use_global_coordinates", "get_use_global_coordinates");
+
+ ADD_GROUP("Update", "update_");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "update_position"), "set_update_position", "get_update_position");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "update_rotation"), "set_update_rotation", "get_update_rotation");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "update_scale"), "set_update_scale", "get_update_scale");
}
RemoteTransform::RemoteTransform() {
+ use_global_coordinates = true;
+ update_remote_position = true;
+ update_remote_rotation = true;
+ update_remote_scale = true;
+
cache = 0;
set_notify_transform(true);
}
diff --git a/scene/3d/remote_transform.h b/scene/3d/remote_transform.h
index 9fa3011185..c25b57966e 100644
--- a/scene/3d/remote_transform.h
+++ b/scene/3d/remote_transform.h
@@ -39,6 +39,11 @@ class RemoteTransform : public Spatial {
ObjectID cache;
+ bool use_global_coordinates;
+ bool update_remote_position;
+ bool update_remote_rotation;
+ bool update_remote_scale;
+
void _update_remote();
void _update_cache();
@@ -50,6 +55,18 @@ public:
void set_remote_node(const NodePath &p_remote_node);
NodePath get_remote_node() const;
+ void set_use_global_coordinates(const bool p_enable);
+ bool get_use_global_coordinates() const;
+
+ void set_update_position(const bool p_update);
+ bool get_update_position() const;
+
+ void set_update_rotation(const bool p_update);
+ bool get_update_rotation() const;
+
+ void set_update_scale(const bool p_update);
+ bool get_update_scale() const;
+
virtual String get_configuration_warning() const;
RemoteTransform();
diff --git a/scene/3d/room_instance.cpp b/scene/3d/room_instance.cpp
index 85713cf43a..7827768c09 100644
--- a/scene/3d/room_instance.cpp
+++ b/scene/3d/room_instance.cpp
@@ -32,7 +32,7 @@
#include "servers/visual_server.h"
#include "geometry.h"
-#include "global_config.h"
+#include "project_settings.h"
#include "scene/resources/surface_tool.h"
void Room::_notification(int p_what) {
diff --git a/scene/3d/skeleton.cpp b/scene/3d/skeleton.cpp
index d498947a41..71af77c027 100644
--- a/scene/3d/skeleton.cpp
+++ b/scene/3d/skeleton.cpp
@@ -31,7 +31,7 @@
#include "message_queue.h"
-#include "core/global_config.h"
+#include "core/project_settings.h"
#include "scene/resources/surface_tool.h"
bool Skeleton::_set(const StringName &p_path, const Variant &p_value) {
diff --git a/scene/3d/spatial.cpp b/scene/3d/spatial.cpp
index 3debbf02c3..6106b0904a 100644
--- a/scene/3d/spatial.cpp
+++ b/scene/3d/spatial.cpp
@@ -541,10 +541,7 @@ void Spatial::show() {
if (!is_inside_tree())
return;
- if (!data.parent || is_visible_in_tree()) {
-
- _propagate_visibility_changed();
- }
+ _propagate_visibility_changed();
}
void Spatial::hide() {
@@ -552,14 +549,14 @@ void Spatial::hide() {
if (!data.visible)
return;
- bool was_visible = is_visible_in_tree();
data.visible = false;
- if (!data.parent || was_visible) {
+ if (!is_inside_tree())
+ return;
- _propagate_visibility_changed();
- }
+ _propagate_visibility_changed();
}
+
bool Spatial::is_visible_in_tree() const {
const Spatial *s = this;
@@ -677,6 +674,16 @@ void Spatial::look_at_from_pos(const Vector3 &p_pos, const Vector3 &p_target, co
set_global_transform(lookat);
}
+Vector3 Spatial::to_local(Vector3 p_global) const {
+
+ return get_global_transform().affine_inverse().xform(p_global);
+}
+
+Vector3 Spatial::to_global(Vector3 p_local) const {
+
+ return get_global_transform().xform(p_local);
+}
+
void Spatial::set_notify_transform(bool p_enable) {
data.notify_transform = p_enable;
}
@@ -707,7 +714,7 @@ void Spatial::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_scale"), &Spatial::get_scale);
ClassDB::bind_method(D_METHOD("set_global_transform", "global"), &Spatial::set_global_transform);
ClassDB::bind_method(D_METHOD("get_global_transform"), &Spatial::get_global_transform);
- ClassDB::bind_method(D_METHOD("get_parent_spatial"), &Spatial::get_parent_spatial);
+ ClassDB::bind_method(D_METHOD("get_parent_spatial:Spatial"), &Spatial::get_parent_spatial);
ClassDB::bind_method(D_METHOD("set_ignore_transform_notification", "enabled"), &Spatial::set_ignore_transform_notification);
ClassDB::bind_method(D_METHOD("set_as_toplevel", "enable"), &Spatial::set_as_toplevel);
ClassDB::bind_method(D_METHOD("is_set_as_toplevel"), &Spatial::is_set_as_toplevel);
@@ -725,7 +732,7 @@ void Spatial::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_gizmo", "gizmo:SpatialGizmo"), &Spatial::set_gizmo);
ClassDB::bind_method(D_METHOD("get_gizmo:SpatialGizmo"), &Spatial::get_gizmo);
- ClassDB::bind_method(D_METHOD("set_visible"), &Spatial::set_visible);
+ ClassDB::bind_method(D_METHOD("set_visible", "visible"), &Spatial::set_visible);
ClassDB::bind_method(D_METHOD("is_visible"), &Spatial::is_visible);
ClassDB::bind_method(D_METHOD("is_visible_in_tree"), &Spatial::is_visible_in_tree);
ClassDB::bind_method(D_METHOD("show"), &Spatial::show);
@@ -759,6 +766,9 @@ void Spatial::_bind_methods() {
ClassDB::bind_method(D_METHOD("look_at", "target", "up"), &Spatial::look_at);
ClassDB::bind_method(D_METHOD("look_at_from_pos", "pos", "target", "up"), &Spatial::look_at_from_pos);
+ ClassDB::bind_method(D_METHOD("to_local", "global_point"), &Spatial::to_local);
+ ClassDB::bind_method(D_METHOD("to_global", "local_point"), &Spatial::to_global);
+
BIND_CONSTANT(NOTIFICATION_TRANSFORM_CHANGED);
BIND_CONSTANT(NOTIFICATION_ENTER_WORLD);
BIND_CONSTANT(NOTIFICATION_EXIT_WORLD);
diff --git a/scene/3d/spatial.h b/scene/3d/spatial.h
index d114a6231b..f22b19d3cc 100644
--- a/scene/3d/spatial.h
+++ b/scene/3d/spatial.h
@@ -173,6 +173,9 @@ public:
void look_at(const Vector3 &p_target, const Vector3 &p_up_normal);
void look_at_from_pos(const Vector3 &p_pos, const Vector3 &p_target, const Vector3 &p_up_normal);
+ Vector3 to_local(Vector3 p_global) const;
+ Vector3 to_global(Vector3 p_local) const;
+
void set_notify_transform(bool p_enable);
bool is_transform_notification_enabled() const;
diff --git a/scene/3d/spatial_velocity_tracker.cpp b/scene/3d/spatial_velocity_tracker.cpp
new file mode 100644
index 0000000000..dc822d0446
--- /dev/null
+++ b/scene/3d/spatial_velocity_tracker.cpp
@@ -0,0 +1,104 @@
+#include "spatial_velocity_tracker.h"
+#include "engine.h"
+
+void SpatialVelocityTracker::set_track_fixed_step(bool p_track_fixed_step) {
+
+ fixed_step = p_track_fixed_step;
+}
+
+bool SpatialVelocityTracker::is_tracking_fixed_step() const {
+
+ return fixed_step;
+}
+void SpatialVelocityTracker::update_position(const Vector3 &p_position) {
+
+ PositionHistory ph;
+ ph.position = p_position;
+ if (fixed_step) {
+ ph.frame = Engine::get_singleton()->get_fixed_frames();
+ } else {
+ ph.frame = Engine::get_singleton()->get_idle_frame_ticks();
+ }
+
+ if (position_history_len == 0 || position_history[0].frame != ph.frame) { //in same frame, use latest
+ position_history_len = MIN(position_history.size(), position_history_len + 1);
+ for (int i = position_history_len - 1; i > 0; i--) {
+ position_history[i] = position_history[i - 1];
+ }
+ }
+
+ position_history[0] = ph;
+}
+Vector3 SpatialVelocityTracker::get_tracked_linear_velocity() const {
+
+ Vector3 linear_velocity;
+
+ float max_time = 1 / 5.0; //maximum time to interpolate a velocity
+
+ Vector3 distance_accum;
+ float time_accum = 0.0;
+ float base_time = 0.0;
+
+ if (position_history_len) {
+ if (fixed_step) {
+ uint64_t base = Engine::get_singleton()->get_fixed_frames();
+ base_time = float(base - position_history[0].frame) / Engine::get_singleton()->get_iterations_per_second();
+ } else {
+ uint64_t base = Engine::get_singleton()->get_idle_frame_ticks();
+ base_time = double(base - position_history[0].frame) / 1000000.0;
+ }
+ }
+
+ for (int i = 0; i < position_history_len - 1; i++) {
+ float delta = 0.0;
+ uint64_t diff = position_history[i].frame - position_history[i + 1].frame;
+ Vector3 distance = position_history[i].position - position_history[i + 1].position;
+
+ if (fixed_step) {
+ delta = float(diff) / Engine::get_singleton()->get_iterations_per_second();
+ } else {
+ delta = double(diff) / 1000000.0;
+ }
+
+ if (base_time + time_accum + delta > max_time)
+ break;
+
+ distance_accum += distance;
+ time_accum += delta;
+ }
+
+ if (time_accum) {
+ linear_velocity = distance_accum / time_accum;
+ }
+
+ return linear_velocity;
+}
+
+void SpatialVelocityTracker::reset(const Vector3 &p_new_pos) {
+
+ PositionHistory ph;
+ ph.position = p_new_pos;
+ if (fixed_step) {
+ ph.frame = Engine::get_singleton()->get_fixed_frames();
+ } else {
+ ph.frame = Engine::get_singleton()->get_idle_frame_ticks();
+ }
+
+ position_history[0] = ph;
+ position_history_len = 1;
+}
+
+void SpatialVelocityTracker::_bind_methods() {
+
+ ClassDB::bind_method(D_METHOD("set_track_fixed_step", "enable"), &SpatialVelocityTracker::set_track_fixed_step);
+ ClassDB::bind_method(D_METHOD("is_tracking_fixed_step"), &SpatialVelocityTracker::is_tracking_fixed_step);
+ ClassDB::bind_method(D_METHOD("update_position", "position"), &SpatialVelocityTracker::update_position);
+ ClassDB::bind_method(D_METHOD("get_tracked_linear_velocity"), &SpatialVelocityTracker::get_tracked_linear_velocity);
+ ClassDB::bind_method(D_METHOD("reset", "position"), &SpatialVelocityTracker::reset);
+}
+
+SpatialVelocityTracker::SpatialVelocityTracker() {
+ position_history.resize(4); // should be configurable
+ position_history_len = 0;
+ fixed_step = false;
+}
diff --git a/scene/3d/spatial_velocity_tracker.h b/scene/3d/spatial_velocity_tracker.h
new file mode 100644
index 0000000000..65f3eaca93
--- /dev/null
+++ b/scene/3d/spatial_velocity_tracker.h
@@ -0,0 +1,31 @@
+#ifndef SPATIAL_VELOCITY_TRACKER_H
+#define SPATIAL_VELOCITY_TRACKER_H
+
+#include "scene/3d/spatial.h"
+
+class SpatialVelocityTracker : public Reference {
+ GDCLASS(SpatialVelocityTracker, Reference)
+
+ struct PositionHistory {
+ uint64_t frame;
+ Vector3 position;
+ };
+
+ bool fixed_step;
+ Vector<PositionHistory> position_history;
+ int position_history_len;
+
+protected:
+ static void _bind_methods();
+
+public:
+ void reset(const Vector3 &p_new_pos);
+ void set_track_fixed_step(bool p_use_fixed_step);
+ bool is_tracking_fixed_step() const;
+ void update_position(const Vector3 &p_position);
+ Vector3 get_tracked_linear_velocity() const;
+
+ SpatialVelocityTracker();
+};
+
+#endif // SPATIAL_VELOCITY_TRACKER_H
diff --git a/scene/audio/audio_player.cpp b/scene/audio/audio_player.cpp
index bcca834642..fdf61c40d8 100644
--- a/scene/audio/audio_player.cpp
+++ b/scene/audio/audio_player.cpp
@@ -263,7 +263,7 @@ void AudioStreamPlayer::_bus_layout_changed() {
void AudioStreamPlayer::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_stream", "stream:AudioStream"), &AudioStreamPlayer::set_stream);
- ClassDB::bind_method(D_METHOD("get_stream"), &AudioStreamPlayer::get_stream);
+ ClassDB::bind_method(D_METHOD("get_stream:AudioStream"), &AudioStreamPlayer::get_stream);
ClassDB::bind_method(D_METHOD("set_volume_db", "volume_db"), &AudioStreamPlayer::set_volume_db);
ClassDB::bind_method(D_METHOD("get_volume_db"), &AudioStreamPlayer::get_volume_db);
diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp
index c1dbc82f3c..9a5f55698e 100644
--- a/scene/gui/base_button.cpp
+++ b/scene/gui/base_button.cpp
@@ -493,11 +493,11 @@ void BaseButton::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_enabled_focus_mode", "mode"), &BaseButton::set_enabled_focus_mode);
ClassDB::bind_method(D_METHOD("get_enabled_focus_mode"), &BaseButton::get_enabled_focus_mode);
- ClassDB::bind_method(D_METHOD("set_shortcut", "shortcut"), &BaseButton::set_shortcut);
- ClassDB::bind_method(D_METHOD("get_shortcut"), &BaseButton::get_shortcut);
+ ClassDB::bind_method(D_METHOD("set_shortcut", "shortcut:ShortCut"), &BaseButton::set_shortcut);
+ ClassDB::bind_method(D_METHOD("get_shortcut:ShortCut"), &BaseButton::get_shortcut);
- ClassDB::bind_method(D_METHOD("set_button_group", "button_group"), &BaseButton::set_button_group);
- ClassDB::bind_method(D_METHOD("get_button_group"), &BaseButton::get_button_group);
+ ClassDB::bind_method(D_METHOD("set_button_group", "button_group:ButtonGroup"), &BaseButton::set_button_group);
+ ClassDB::bind_method(D_METHOD("get_button_group:ButtonGroup"), &BaseButton::get_button_group);
BIND_VMETHOD(MethodInfo("_pressed"));
BIND_VMETHOD(MethodInfo("_toggled", PropertyInfo(Variant::BOOL, "pressed")));
diff --git a/scene/gui/button.cpp b/scene/gui/button.cpp
index a456759281..03798c01a2 100644
--- a/scene/gui/button.cpp
+++ b/scene/gui/button.cpp
@@ -89,7 +89,8 @@ void Button::_notification(int p_what) {
case DRAW_PRESSED: {
style = get_stylebox("pressed");
- style->draw(ci, Rect2(Point2(0, 0), size));
+ if (!flat)
+ style->draw(ci, Rect2(Point2(0, 0), size));
if (has_color("font_color_pressed"))
color = get_color("font_color_pressed");
else
@@ -101,7 +102,8 @@ void Button::_notification(int p_what) {
case DRAW_HOVER: {
style = get_stylebox("hover");
- style->draw(ci, Rect2(Point2(0, 0), size));
+ if (!flat)
+ style->draw(ci, Rect2(Point2(0, 0), size));
color = get_color("font_color_hover");
if (has_color("icon_color_hover"))
color_icon = get_color("icon_color_hover");
@@ -110,7 +112,8 @@ void Button::_notification(int p_what) {
case DRAW_DISABLED: {
style = get_stylebox("disabled");
- style->draw(ci, Rect2(Point2(0, 0), size));
+ if (!flat)
+ style->draw(ci, Rect2(Point2(0, 0), size));
color = get_color("font_color_disabled");
if (has_color("icon_color_disabled"))
color_icon = get_color("icon_color_disabled");
diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp
index 9ef340edbc..48cac69956 100644
--- a/scene/gui/color_picker.cpp
+++ b/scene/gui/color_picker.cpp
@@ -50,6 +50,19 @@ void ColorPicker::_notification(int p_what) {
_update_color();
} break;
+ case NOTIFICATION_PARENTED: {
+ for (int i = 0; i < 4; i++)
+ set_margin((Margin)i, get_constant("margin"));
+ } break;
+
+ case NOTIFICATION_VISIBILITY_CHANGED: {
+ if (get_parent()) {
+ Popup *p = get_parent()->cast_to<Popup>();
+ if (p)
+ p->set_size(Size2(get_combined_minimum_size().width + get_constant("margin") * 2, get_combined_minimum_size().height + get_constant("margin") * 2));
+ }
+ } break;
+
case MainLoop::NOTIFICATION_WM_QUIT_REQUEST: {
if (screen != NULL) {
if (screen->is_visible()) {
@@ -254,13 +267,13 @@ void ColorPicker::_update_text_value() {
}
void ColorPicker::_sample_draw() {
- sample->draw_rect(Rect2(Point2(), Size2(uv_edit->get_size().width, 20)), color);
+ sample->draw_rect(Rect2(Point2(), Size2(uv_edit->get_size().width, sample->get_size().height * 0.95)), color);
}
-void ColorPicker::_hsv_draw(int p_wich, Control *c) {
+void ColorPicker::_hsv_draw(int p_which, Control *c) {
if (!c)
return;
- if (p_wich == 0) {
+ if (p_which == 0) {
Vector<Point2> points;
points.push_back(Vector2());
points.push_back(Vector2(c->get_size().x, 0));
@@ -291,7 +304,7 @@ void ColorPicker::_hsv_draw(int p_wich, Control *c) {
c->draw_line(Point2(x, 0), Point2(x, c->get_size().y), col.inverted());
c->draw_line(Point2(0, y), Point2(c->get_size().x, y), col.inverted());
c->draw_line(Point2(x, y), Point2(x, y), Color(1, 1, 1), 2);
- } else if (p_wich == 1) {
+ } else if (p_which == 1) {
Ref<Texture> hue = get_icon("color_hue", "ColorPicker");
c->draw_texture_rect(hue, Rect2(Point2(), c->get_size()));
int y = c->get_size().y - c->get_size().y * (1.0 - h);
@@ -465,7 +478,7 @@ void ColorPicker::_bind_methods() {
ClassDB::bind_method(D_METHOD("is_raw_mode"), &ColorPicker::is_raw_mode);
ClassDB::bind_method(D_METHOD("set_edit_alpha", "show"), &ColorPicker::set_edit_alpha);
ClassDB::bind_method(D_METHOD("is_editing_alpha"), &ColorPicker::is_editing_alpha);
- ClassDB::bind_method(D_METHOD("add_preset"), &ColorPicker::add_preset);
+ ClassDB::bind_method(D_METHOD("add_preset", "color"), &ColorPicker::add_preset);
ClassDB::bind_method(D_METHOD("_value_changed"), &ColorPicker::_value_changed);
ClassDB::bind_method(D_METHOD("_html_entered"), &ColorPicker::_html_entered);
ClassDB::bind_method(D_METHOD("_text_type_toggled"), &ColorPicker::_text_type_toggled);
@@ -512,23 +525,18 @@ ColorPicker::ColorPicker()
uv_edit->set_mouse_filter(MOUSE_FILTER_PASS);
uv_edit->set_h_size_flags(SIZE_EXPAND_FILL);
uv_edit->set_v_size_flags(SIZE_EXPAND_FILL);
- Vector<Variant> args = Vector<Variant>();
- args.push_back(0);
- args.push_back(uv_edit);
- uv_edit->connect("draw", this, "_hsv_draw", args);
+ uv_edit->set_custom_minimum_size(Size2(get_constant("sv_width"), get_constant("sv_height")));
+ uv_edit->connect("draw", this, "_hsv_draw", make_binds(0, uv_edit));
add_child(hb_edit);
w_edit = memnew(Control);
//w_edit->set_ignore_mouse(false);
- w_edit->set_custom_minimum_size(Size2(30, 0));
+ w_edit->set_custom_minimum_size(Size2(get_constant("h_width"), 0));
w_edit->set_h_size_flags(SIZE_FILL);
w_edit->set_v_size_flags(SIZE_EXPAND_FILL);
w_edit->connect("gui_input", this, "_w_input");
- args.clear();
- args.push_back(1);
- args.push_back(w_edit);
- w_edit->connect("draw", this, "_hsv_draw", args);
+ w_edit->connect("draw", this, "_hsv_draw", make_binds(1, w_edit));
hb_edit->add_child(uv_edit);
hb_edit->add_child(memnew(VSeparator));
@@ -549,10 +557,12 @@ ColorPicker::ColorPicker()
HBoxContainer *hbc = memnew(HBoxContainer);
labels[i] = memnew(Label(lt[i]));
- labels[i]->set_custom_minimum_size(Size2(10, 0));
+ labels[i]->set_custom_minimum_size(Size2(get_constant("label_width"), 0));
+ labels[i]->set_v_size_flags(SIZE_SHRINK_CENTER);
hbc->add_child(labels[i]);
scroll[i] = memnew(HSlider);
+ scroll[i]->set_v_size_flags(SIZE_SHRINK_CENTER);
hbc->add_child(scroll[i]);
values[i] = memnew(SpinBox);
@@ -571,7 +581,7 @@ ColorPicker::ColorPicker()
HBoxContainer *hhb = memnew(HBoxContainer);
btn_mode = memnew(CheckButton);
- btn_mode->set_text(TTR("RAW Mode"));
+ btn_mode->set_text(TTR("Raw Mode"));
btn_mode->connect("toggled", this, "set_raw_mode");
hhb->add_child(btn_mode);
vbr->add_child(hhb);
@@ -617,9 +627,7 @@ void ColorPickerButton::_color_changed(const Color &p_color) {
void ColorPickerButton::pressed() {
- Size2 ms = Size2(300, picker->get_combined_minimum_size().height + 10);
- popup->set_position(get_global_position() - Size2(0, ms.height));
- popup->set_size(ms);
+ popup->set_position(get_global_position() - picker->get_combined_minimum_size());
popup->popup();
picker->set_focus_on_line_edit();
}
diff --git a/scene/gui/color_picker.h b/scene/gui/color_picker.h
index de624fd029..1a79266409 100644
--- a/scene/gui/color_picker.h
+++ b/scene/gui/color_picker.h
@@ -79,7 +79,7 @@ private:
void _update_text_value();
void _text_type_toggled();
void _sample_draw();
- void _hsv_draw(int p_wich, Control *c);
+ void _hsv_draw(int p_which, Control *c);
void _uv_input(const Ref<InputEvent> &p_input);
void _w_input(const Ref<InputEvent> &p_input);
diff --git a/scene/gui/container.cpp b/scene/gui/container.cpp
index 92bb5d43a7..2a96f8260c 100644
--- a/scene/gui/container.cpp
+++ b/scene/gui/container.cpp
@@ -95,13 +95,25 @@ void Container::fit_child_in_rect(Control *p_child, const Rect2 &p_rect) {
Rect2 r = p_rect;
if (!(p_child->get_h_size_flags() & SIZE_FILL)) {
- r.size.x = minsize.x;
- r.position.x += Math::floor((p_rect.size.x - minsize.x) / 2);
+ r.size.x = minsize.width;
+ if (p_child->get_h_size_flags() & SIZE_SHRINK_END) {
+ r.position.x += p_rect.size.width - minsize.width;
+ } else if (p_child->get_h_size_flags() & SIZE_SHRINK_CENTER) {
+ r.position.x += Math::floor((p_rect.size.x - minsize.width) / 2);
+ } else {
+ r.position.x += 0;
+ }
}
if (!(p_child->get_v_size_flags() & SIZE_FILL)) {
r.size.y = minsize.y;
- r.position.y += Math::floor((p_rect.size.y - minsize.y) / 2);
+ if (p_child->get_v_size_flags() & SIZE_SHRINK_END) {
+ r.position.y += p_rect.size.height - minsize.height;
+ } else if (p_child->get_v_size_flags() & SIZE_SHRINK_CENTER) {
+ r.position.y += Math::floor((p_rect.size.y - minsize.height) / 2);
+ } else {
+ r.position.y += 0;
+ }
}
for (int i = 0; i < 4; i++)
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index 45485b768e..ca81b72e89 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -28,7 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "control.h"
-#include "global_config.h"
+#include "project_settings.h"
#include "scene/main/canvas_layer.h"
#include "scene/main/viewport.h"
#include "servers/visual_server.h"
@@ -90,11 +90,22 @@ Size2 Control::edit_get_minimum_size() const {
return get_combined_minimum_size();
}
+Transform2D Control::_get_internal_transform() const {
+
+ Transform2D rot_scale;
+ rot_scale.set_rotation_and_scale(data.rotation, data.scale);
+ Transform2D offset;
+ offset.set_origin(-data.pivot_offset);
+
+ return offset.affine_inverse() * (rot_scale * offset);
+}
void Control::edit_set_rect(const Rect2 &p_edit_rect) {
- Transform2D postxf;
- postxf.set_rotation_and_scale(data.rotation, data.scale);
- Vector2 new_pos = postxf.xform(p_edit_rect.position);
+ Transform2D xform = _get_internal_transform();
+
+ // xform[2] += get_position();
+
+ Vector2 new_pos = xform.basis_xform(p_edit_rect.position);
Vector2 pos = get_position() + new_pos;
@@ -353,8 +364,9 @@ void Control::remove_child_notify(Node *p_child) {
void Control::_update_canvas_item_transform() {
- Transform2D xform = Transform2D(data.rotation, get_position());
- xform.scale_basis(data.scale);
+ Transform2D xform = _get_internal_transform();
+ xform[2] += get_position();
+
VisualServer::get_singleton()->canvas_item_set_transform(get_canvas_item(), xform);
}
@@ -1217,12 +1229,28 @@ void Control::_size_changed() {
}
}
- Point2 new_pos_cache = Point2(margin_pos[0], margin_pos[1]).floor();
- Size2 new_size_cache = Point2(margin_pos[2], margin_pos[3]).floor() - new_pos_cache;
+ Point2 new_pos_cache = Point2(margin_pos[0], margin_pos[1]);
+ Size2 new_size_cache = Point2(margin_pos[2], margin_pos[3]) - new_pos_cache;
+
Size2 minimum_size = get_combined_minimum_size();
- new_size_cache.x = MAX(minimum_size.x, new_size_cache.x);
- new_size_cache.y = MAX(minimum_size.y, new_size_cache.y);
+ if (data.h_grow == GROW_DIRECTION_BEGIN) {
+ if (minimum_size.width > new_size_cache.width) {
+ new_pos_cache.x = new_pos_cache.x + new_size_cache.width - minimum_size.width;
+ new_size_cache.width = minimum_size.width;
+ }
+ } else {
+ new_size_cache.width = MAX(minimum_size.width, new_size_cache.width);
+ }
+
+ if (data.v_grow == GROW_DIRECTION_BEGIN) {
+ if (minimum_size.height > new_size_cache.height) {
+ new_pos_cache.y = new_pos_cache.y + new_size_cache.height - minimum_size.height;
+ new_size_cache.height = minimum_size.height;
+ }
+ } else {
+ new_size_cache.height = MAX(minimum_size.height, new_size_cache.height);
+ }
bool pos_changed = new_pos_cache != data.pos_cache;
bool size_changed = new_size_cache != data.size_cache;
@@ -1887,8 +1915,8 @@ Control::CursorShape Control::get_cursor_shape(const Point2 &p_pos) const {
Transform2D Control::get_transform() const {
- Transform2D xform = Transform2D(data.rotation, get_position());
- xform.scale_basis(data.scale);
+ Transform2D xform = _get_internal_transform();
+ xform[2] += get_position();
return xform;
}
@@ -2214,6 +2242,19 @@ void Control::_font_changed() {
minimum_size_changed(); //fonts affect minimum size pretty much almost always
}
+void Control::set_pivot_offset(const Vector2 &p_pivot) {
+
+ data.pivot_offset = p_pivot;
+ update();
+ _notify_transform();
+ _change_notify("rect_pivot_offset");
+}
+
+Vector2 Control::get_pivot_offset() const {
+
+ return data.pivot_offset;
+}
+
void Control::set_scale(const Vector2 &p_scale) {
data.scale = p_scale;
@@ -2300,6 +2341,27 @@ bool Control::is_clipping_contents() {
return data.clip_contents;
}
+void Control::set_h_grow_direction(GrowDirection p_direction) {
+
+ data.h_grow = p_direction;
+ _size_changed();
+}
+
+Control::GrowDirection Control::get_h_grow_direction() const {
+
+ return data.h_grow;
+}
+
+void Control::set_v_grow_direction(GrowDirection p_direction) {
+
+ data.v_grow = p_direction;
+ _size_changed();
+}
+Control::GrowDirection Control::get_v_grow_direction() const {
+
+ return data.v_grow;
+}
+
void Control::_bind_methods() {
//ClassDB::bind_method(D_METHOD("_window_resize_event"),&Control::_window_resize_event);
@@ -2325,6 +2387,7 @@ void Control::_bind_methods() {
// TODO: Obsolete this method (old name) properly (GH-4397)
ClassDB::bind_method(D_METHOD("_set_rotation_deg", "degrees"), &Control::_set_rotation_deg);
ClassDB::bind_method(D_METHOD("set_scale", "scale"), &Control::set_scale);
+ ClassDB::bind_method(D_METHOD("set_pivot_offset", "pivot_offset"), &Control::set_pivot_offset);
ClassDB::bind_method(D_METHOD("get_margin", "margin"), &Control::get_margin);
ClassDB::bind_method(D_METHOD("get_begin"), &Control::get_begin);
ClassDB::bind_method(D_METHOD("get_end"), &Control::get_end);
@@ -2335,6 +2398,7 @@ void Control::_bind_methods() {
// TODO: Obsolete this method (old name) properly (GH-4397)
ClassDB::bind_method(D_METHOD("_get_rotation_deg"), &Control::_get_rotation_deg);
ClassDB::bind_method(D_METHOD("get_scale"), &Control::get_scale);
+ ClassDB::bind_method(D_METHOD("get_pivot_offset"), &Control::get_pivot_offset);
ClassDB::bind_method(D_METHOD("get_custom_minimum_size"), &Control::get_custom_minimum_size);
ClassDB::bind_method(D_METHOD("get_parent_area_size"), &Control::get_size);
ClassDB::bind_method(D_METHOD("get_global_position"), &Control::get_global_position);
@@ -2388,6 +2452,12 @@ void Control::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_parent_control:Control"), &Control::get_parent_control);
+ ClassDB::bind_method(D_METHOD("set_h_grow_direction", "direction"), &Control::set_h_grow_direction);
+ ClassDB::bind_method(D_METHOD("get_h_grow_direction"), &Control::get_h_grow_direction);
+
+ ClassDB::bind_method(D_METHOD("set_v_grow_direction", "direction"), &Control::set_v_grow_direction);
+ ClassDB::bind_method(D_METHOD("get_v_grow_direction"), &Control::get_v_grow_direction);
+
ClassDB::bind_method(D_METHOD("set_tooltip", "tooltip"), &Control::set_tooltip);
ClassDB::bind_method(D_METHOD("get_tooltip", "atpos"), &Control::get_tooltip, DEFVAL(Point2()));
ClassDB::bind_method(D_METHOD("_get_tooltip"), &Control::_get_tooltip);
@@ -2399,7 +2469,7 @@ void Control::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_focus_neighbour", "margin", "neighbour"), &Control::set_focus_neighbour);
ClassDB::bind_method(D_METHOD("get_focus_neighbour", "margin"), &Control::get_focus_neighbour);
- ClassDB::bind_method(D_METHOD("force_drag", "data", "preview"), &Control::force_drag);
+ ClassDB::bind_method(D_METHOD("force_drag", "data", "preview:Control"), &Control::force_drag);
ClassDB::bind_method(D_METHOD("set_mouse_filter", "filter"), &Control::set_mouse_filter);
ClassDB::bind_method(D_METHOD("get_mouse_filter"), &Control::get_mouse_filter);
@@ -2438,12 +2508,17 @@ void Control::_bind_methods() {
ADD_PROPERTYINZ(PropertyInfo(Variant::INT, "margin_right", PROPERTY_HINT_RANGE, "-4096,4096"), "set_margin", "get_margin", MARGIN_RIGHT);
ADD_PROPERTYINZ(PropertyInfo(Variant::INT, "margin_bottom", PROPERTY_HINT_RANGE, "-4096,4096"), "set_margin", "get_margin", MARGIN_BOTTOM);
+ ADD_GROUP("Grow Direction", "grow_");
+ ADD_PROPERTYNO(PropertyInfo(Variant::INT, "grow_horizontal", PROPERTY_HINT_ENUM, "Begin,End"), "set_h_grow_direction", "get_h_grow_direction");
+ ADD_PROPERTYNO(PropertyInfo(Variant::INT, "grow_vertical", PROPERTY_HINT_ENUM, "Begin,End"), "set_v_grow_direction", "get_v_grow_direction");
+
ADD_GROUP("Rect", "rect_");
ADD_PROPERTYNZ(PropertyInfo(Variant::VECTOR2, "rect_position", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "set_position", "get_position");
ADD_PROPERTYNZ(PropertyInfo(Variant::VECTOR2, "rect_size", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "set_size", "get_size");
ADD_PROPERTYNZ(PropertyInfo(Variant::VECTOR2, "rect_min_size"), "set_custom_minimum_size", "get_custom_minimum_size");
ADD_PROPERTYNZ(PropertyInfo(Variant::REAL, "rect_rotation", PROPERTY_HINT_RANGE, "-1080,1080,0.01"), "set_rotation_deg", "get_rotation_deg");
ADD_PROPERTYNO(PropertyInfo(Variant::VECTOR2, "rect_scale"), "set_scale", "get_scale");
+ ADD_PROPERTYNO(PropertyInfo(Variant::VECTOR2, "rect_pivot_offset"), "set_pivot_offset", "get_pivot_offset");
ADD_PROPERTYNO(PropertyInfo(Variant::BOOL, "rect_clip_content"), "set_clip_contents", "is_clipping_contents");
ADD_GROUP("Hint", "hint_");
@@ -2459,9 +2534,9 @@ void Control::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "mouse_filter", PROPERTY_HINT_ENUM, "Stop,Pass,Ignore"), "set_mouse_filter", "get_mouse_filter");
ADD_GROUP("Size Flags", "size_flags_");
- ADD_PROPERTYNO(PropertyInfo(Variant::INT, "size_flags_horizontal", PROPERTY_HINT_FLAGS, "Fill,Expand"), "set_h_size_flags", "get_h_size_flags");
- ADD_PROPERTYNO(PropertyInfo(Variant::INT, "size_flags_vertical", PROPERTY_HINT_FLAGS, "Fill,Expand"), "set_v_size_flags", "get_v_size_flags");
- ADD_PROPERTYNO(PropertyInfo(Variant::INT, "size_flags_stretch_ratio", PROPERTY_HINT_RANGE, "1,128,0.01"), "set_stretch_ratio", "get_stretch_ratio");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "size_flags_horizontal", PROPERTY_HINT_FLAGS, "Fill,Expand,Shrink Center,Shrink End"), "set_h_size_flags", "get_h_size_flags");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "size_flags_vertical", PROPERTY_HINT_FLAGS, "Fill,Expand,Shrink Center,Shrink End"), "set_v_size_flags", "get_v_size_flags");
+ ADD_PROPERTYNO(PropertyInfo(Variant::REAL, "size_flags_stretch_ratio", PROPERTY_HINT_RANGE, "0,128,0.01"), "set_stretch_ratio", "get_stretch_ratio");
ADD_GROUP("Theme", "");
ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT, "theme", PROPERTY_HINT_RESOURCE_TYPE, "Theme"), "set_theme", "get_theme");
ADD_GROUP("", "");
@@ -2502,11 +2577,16 @@ void Control::_bind_methods() {
BIND_CONSTANT(SIZE_EXPAND);
BIND_CONSTANT(SIZE_FILL);
BIND_CONSTANT(SIZE_EXPAND_FILL);
+ BIND_CONSTANT(SIZE_SHRINK_CENTER);
+ BIND_CONSTANT(SIZE_SHRINK_END);
BIND_CONSTANT(MOUSE_FILTER_STOP);
BIND_CONSTANT(MOUSE_FILTER_PASS);
BIND_CONSTANT(MOUSE_FILTER_IGNORE);
+ BIND_CONSTANT(GROW_DIRECTION_BEGIN);
+ BIND_CONSTANT(GROW_DIRECTION_END);
+
ADD_SIGNAL(MethodInfo("resized"));
ADD_SIGNAL(MethodInfo("gui_input", PropertyInfo(Variant::OBJECT, "ev", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent")));
ADD_SIGNAL(MethodInfo("mouse_entered"));
@@ -2543,6 +2623,8 @@ Control::Control() {
data.modal_frame = 0;
data.block_minimum_size_adjust = false;
data.disable_visibility_clip = false;
+ data.h_grow = GROW_DIRECTION_END;
+ data.v_grow = GROW_DIRECTION_END;
data.clip_contents = false;
for (int i = 0; i < 4; i++) {
diff --git a/scene/gui/control.h b/scene/gui/control.h
index 5834d1550a..86cf8f6dbd 100644
--- a/scene/gui/control.h
+++ b/scene/gui/control.h
@@ -57,6 +57,11 @@ public:
ANCHOR_CENTER,
};
+ enum GrowDirection {
+ GROW_DIRECTION_BEGIN,
+ GROW_DIRECTION_END
+ };
+
enum FocusMode {
FOCUS_NONE,
FOCUS_CLICK,
@@ -67,7 +72,9 @@ public:
SIZE_FILL = 1,
SIZE_EXPAND = 2,
- SIZE_EXPAND_FILL = SIZE_EXPAND | SIZE_FILL
+ SIZE_EXPAND_FILL = SIZE_EXPAND | SIZE_FILL,
+ SIZE_SHRINK_CENTER = 4, //ignored by expand or fill
+ SIZE_SHRINK_END = 8, //ignored by expand or fil
};
@@ -117,9 +124,12 @@ private:
float margin[4];
AnchorType anchor[4];
FocusMode focus_mode;
+ GrowDirection h_grow;
+ GrowDirection v_grow;
float rotation;
Vector2 scale;
+ Vector2 pivot_offset;
bool pending_resize;
@@ -200,6 +210,8 @@ private:
void _update_canvas_item_transform();
+ Transform2D _get_internal_transform() const;
+
friend class Viewport;
void _modal_stack_remove();
void _modal_set_prev_focus_owner(ObjectID p_prev);
@@ -273,6 +285,12 @@ public:
void set_begin(const Point2 &p_point); // helper
void set_end(const Point2 &p_point); // helper
+ void set_h_grow_direction(GrowDirection p_direction);
+ GrowDirection get_h_grow_direction() const;
+
+ void set_v_grow_direction(GrowDirection p_direction);
+ GrowDirection get_v_grow_direction() const;
+
float get_margin(Margin p_margin) const;
Point2 get_begin() const;
Point2 get_end() const;
@@ -293,6 +311,9 @@ public:
float get_rotation() const;
float get_rotation_deg() const;
+ void set_pivot_offset(const Vector2 &p_pivot);
+ Vector2 get_pivot_offset() const;
+
void set_scale(const Vector2 &p_scale);
Vector2 get_scale() const;
@@ -409,5 +430,6 @@ VARIANT_ENUM_CAST(Control::FocusMode);
VARIANT_ENUM_CAST(Control::SizeFlags);
VARIANT_ENUM_CAST(Control::CursorShape);
VARIANT_ENUM_CAST(Control::MouseFilter);
+VARIANT_ENUM_CAST(Control::GrowDirection);
#endif
diff --git a/scene/gui/dialogs.cpp b/scene/gui/dialogs.cpp
index 60d1350405..7d7c636bc2 100644
--- a/scene/gui/dialogs.cpp
+++ b/scene/gui/dialogs.cpp
@@ -357,6 +357,9 @@ void AcceptDialog::_notification(int p_what) {
if (p_what == NOTIFICATION_MODAL_CLOSE) {
cancel_pressed();
+ } else if (p_what == NOTIFICATION_READY) {
+
+ _update_child_rects();
} else if (p_what == NOTIFICATION_RESIZED) {
_update_child_rects();
@@ -581,5 +584,8 @@ Button *ConfirmationDialog::get_cancel() {
ConfirmationDialog::ConfirmationDialog() {
set_title(RTR("Please Confirm..."));
+#ifdef TOOLS_ENABLED
+ set_custom_minimum_size(Size2(200, 70) * EDSCALE);
+#endif
cancel = add_cancel();
}
diff --git a/scene/gui/gradient_edit.cpp b/scene/gui/gradient_edit.cpp
index 58bce57580..22de28ea7f 100644
--- a/scene/gui/gradient_edit.cpp
+++ b/scene/gui/gradient_edit.cpp
@@ -61,10 +61,8 @@ int GradientEdit::_get_point_from_pos(int x) {
void GradientEdit::_show_color_picker() {
if (grabbed == -1)
return;
- Size2 ms = Size2(350, picker->get_combined_minimum_size().height + 10);
picker->set_pick_color(points[grabbed].color);
- popup->set_position(get_global_position() - Vector2(ms.width - get_size().width, ms.height));
- popup->set_size(ms);
+ popup->set_position(get_global_position() - popup->get_combined_minimum_size());
popup->popup();
}
diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp
index 8d085d5399..11f750ea70 100644
--- a/scene/gui/graph_edit.cpp
+++ b/scene/gui/graph_edit.cpp
@@ -568,7 +568,7 @@ static _FORCE_INLINE_ Vector2 _bezier_interp(real_t t, Vector2 start, Vector2 co
return start * omt3 + control_1 * omt2 * t * 3.0 + control_2 * omt * t2 * 3.0 + end * t3;
}
-void GraphEdit::_bake_segment2d(CanvasItem *p_where, float p_begin, float p_end, const Vector2 &p_a, const Vector2 &p_out, const Vector2 &p_b, const Vector2 &p_in, int p_depth, int p_min_depth, int p_max_depth, float p_tol, const Color &p_color, const Color &p_to_color, int &lines) const {
+void GraphEdit::_bake_segment2d(Vector<Vector2> &points, Vector<Color> &colors, float p_begin, float p_end, const Vector2 &p_a, const Vector2 &p_out, const Vector2 &p_b, const Vector2 &p_in, int p_depth, int p_min_depth, int p_max_depth, float p_tol, const Color &p_color, const Color &p_to_color, int &lines) const {
float mp = p_begin + (p_end - p_begin) * 0.5;
Vector2 beg = _bezier_interp(p_begin, p_a, p_a + p_out, p_b + p_in, p_b);
@@ -581,11 +581,12 @@ void GraphEdit::_bake_segment2d(CanvasItem *p_where, float p_begin, float p_end,
if (p_depth >= p_min_depth && (dp < p_tol || p_depth >= p_max_depth)) {
- p_where->draw_line(beg, end, p_color.linear_interpolate(p_to_color, mp), 2, true);
+ points.push_back((beg + end) * 0.5);
+ colors.push_back(p_color.linear_interpolate(p_to_color, mp));
lines++;
} else {
- _bake_segment2d(p_where, p_begin, mp, p_a, p_out, p_b, p_in, p_depth + 1, p_min_depth, p_max_depth, p_tol, p_color, p_to_color, lines);
- _bake_segment2d(p_where, mp, p_end, p_a, p_out, p_b, p_in, p_depth + 1, p_min_depth, p_max_depth, p_tol, p_color, p_to_color, lines);
+ _bake_segment2d(points, colors, p_begin, mp, p_a, p_out, p_b, p_in, p_depth + 1, p_min_depth, p_max_depth, p_tol, p_color, p_to_color, lines);
+ _bake_segment2d(points, colors, mp, p_end, p_a, p_out, p_b, p_in, p_depth + 1, p_min_depth, p_max_depth, p_tol, p_color, p_to_color, lines);
}
}
@@ -600,7 +601,7 @@ void GraphEdit::_draw_cos_line(CanvasItem *p_where, const Vector2 &p_from, const
int cp_neg_len = get_constant("bezier_len_neg");
if (diff > 0) {
- cp_offset = MAX(cp_len, diff * 0.5);
+ cp_offset = MIN(cp_len, diff * 0.5);
} else {
cp_offset = MAX(MIN(cp_len - diff, cp_neg_len), -diff * 0.5);
}
@@ -609,7 +610,16 @@ void GraphEdit::_draw_cos_line(CanvasItem *p_where, const Vector2 &p_from, const
Vector2 c2 = Vector2(-cp_offset * zoom, 0);
int lines = 0;
- _bake_segment2d(p_where, 0, 1, p_from, c1, p_to, c2, 0, 3, 9, 8, p_color, p_to_color, lines);
+
+ Vector<Point2> points;
+ Vector<Color> colors;
+ points.push_back(p_from);
+ colors.push_back(p_color);
+ _bake_segment2d(points, colors, 0, 1, p_from, c1, p_to, c2, 0, 3, 9, 8, p_color, p_to_color, lines);
+ points.push_back(p_to);
+ colors.push_back(p_to_color);
+
+ p_where->draw_polyline_colors(points, colors, 2, true);
#else
@@ -1183,7 +1193,7 @@ void GraphEdit::_bind_methods() {
ClassDB::bind_method(D_METHOD("_update_scroll_offset"), &GraphEdit::_update_scroll_offset);
ClassDB::bind_method(D_METHOD("_connections_layer_draw"), &GraphEdit::_connections_layer_draw);
- ClassDB::bind_method(D_METHOD("set_selected", "node"), &GraphEdit::set_selected);
+ ClassDB::bind_method(D_METHOD("set_selected", "node:Node"), &GraphEdit::set_selected);
ADD_SIGNAL(MethodInfo("connection_request", PropertyInfo(Variant::STRING, "from"), PropertyInfo(Variant::INT, "from_slot"), PropertyInfo(Variant::STRING, "to"), PropertyInfo(Variant::INT, "to_slot")));
ADD_SIGNAL(MethodInfo("disconnection_request", PropertyInfo(Variant::STRING, "from"), PropertyInfo(Variant::INT, "from_slot"), PropertyInfo(Variant::STRING, "to"), PropertyInfo(Variant::INT, "to_slot")));
diff --git a/scene/gui/graph_edit.h b/scene/gui/graph_edit.h
index 22d053d312..e908829d5f 100644
--- a/scene/gui/graph_edit.h
+++ b/scene/gui/graph_edit.h
@@ -110,7 +110,7 @@ private:
bool awaiting_scroll_offset_update;
List<Connection> connections;
- void _bake_segment2d(CanvasItem *p_where, float p_begin, float p_end, const Vector2 &p_a, const Vector2 &p_out, const Vector2 &p_b, const Vector2 &p_in, int p_depth, int p_min_depth, int p_max_depth, float p_tol, const Color &p_color, const Color &p_to_color, int &lines) const;
+ void _bake_segment2d(Vector<Vector2> &points, Vector<Color> &colors, float p_begin, float p_end, const Vector2 &p_a, const Vector2 &p_out, const Vector2 &p_b, const Vector2 &p_in, int p_depth, int p_min_depth, int p_max_depth, float p_tol, const Color &p_color, const Color &p_to_color, int &lines) const;
void _draw_cos_line(CanvasItem *p_where, const Vector2 &p_from, const Vector2 &p_to, const Color &p_color, const Color &p_to_color);
diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp
index 2f0c7b9aaf..97f49da2be 100644
--- a/scene/gui/item_list.cpp
+++ b/scene/gui/item_list.cpp
@@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "item_list.h"
-#include "global_config.h"
#include "os/os.h"
+#include "project_settings.h"
void ItemList::add_item(const String &p_item, const Ref<Texture> &p_texture, bool p_selectable) {
@@ -534,7 +534,7 @@ void ItemList::_gui_input(const Ref<InputEvent> &p_event) {
uint64_t now = OS::get_singleton()->get_ticks_msec();
uint64_t diff = now - search_time_msec;
- if (diff < int(GlobalConfig::get_singleton()->get("gui/timers/incremental_search_max_interval_msec")) * 2) {
+ if (diff < int(ProjectSettings::get_singleton()->get("gui/timers/incremental_search_max_interval_msec")) * 2) {
for (int i = current - 1; i >= 0; i--) {
@@ -569,7 +569,7 @@ void ItemList::_gui_input(const Ref<InputEvent> &p_event) {
uint64_t now = OS::get_singleton()->get_ticks_msec();
uint64_t diff = now - search_time_msec;
- if (diff < int(GlobalConfig::get_singleton()->get("gui/timers/incremental_search_max_interval_msec")) * 2) {
+ if (diff < int(ProjectSettings::get_singleton()->get("gui/timers/incremental_search_max_interval_msec")) * 2) {
for (int i = current + 1; i < items.size(); i++) {
@@ -743,12 +743,10 @@ void ItemList::_notification(int p_what) {
Size2 size = get_size();
- float page = size.height - bg->get_minimum_size().height;
int width = size.width - bg->get_minimum_size().width;
if (scroll_bar->is_visible()) {
width -= mw + bg->get_margin(MARGIN_RIGHT);
}
- scroll_bar->set_page(page);
draw_style_box(bg, Rect2(Point2(), size));
@@ -883,8 +881,12 @@ void ItemList::_notification(int p_what) {
}
if (all_fit) {
+ float page = size.height - bg->get_minimum_size().height;
float max = MAX(page, ofs.y + max_h);
+ if (auto_height)
+ auto_height_value = ofs.y + max_h + bg->get_minimum_size().height;
scroll_bar->set_max(max);
+ scroll_bar->set_page(page);
//print_line("max: "+rtos(max)+" page "+rtos(page));
if (max <= page) {
scroll_bar->set_value(0);
@@ -1223,6 +1225,56 @@ Vector<int> ItemList::get_selected_items() {
return selected;
}
+void ItemList::_set_items(const Array &p_items) {
+
+ ERR_FAIL_COND(p_items.size() % 3);
+ clear();
+
+ for (int i = 0; i < p_items.size(); i += 3) {
+
+ String text = p_items[i + 0];
+ Ref<Texture> icon = p_items[i + 1];
+ bool disabled = p_items[i + 2];
+
+ int idx = get_item_count();
+ add_item(text, icon);
+ set_item_disabled(idx, disabled);
+ }
+}
+
+Array ItemList::_get_items() const {
+
+ Array items;
+ for (int i = 0; i < get_item_count(); i++) {
+
+ items.push_back(get_item_text(i));
+ items.push_back(get_item_icon(i));
+ items.push_back(is_item_disabled(i));
+ }
+
+ return items;
+}
+
+Size2 ItemList::get_minimum_size() const {
+
+ if (auto_height) {
+ return Size2(0, auto_height_value);
+ }
+ return Size2();
+}
+
+void ItemList::set_auto_height(bool p_enable) {
+
+ auto_height = p_enable;
+ shape_changed = true;
+ update();
+}
+
+bool ItemList::has_auto_height() const {
+
+ return auto_height;
+}
+
void ItemList::_bind_methods() {
ClassDB::bind_method(D_METHOD("add_item", "text", "icon:Texture", "selectable"), &ItemList::add_item, DEFVAL(Variant()), DEFVAL(true));
@@ -1244,7 +1296,7 @@ void ItemList::_bind_methods() {
ClassDB::bind_method(D_METHOD("is_item_disabled", "idx"), &ItemList::is_item_disabled);
ClassDB::bind_method(D_METHOD("set_item_metadata", "idx", "metadata"), &ItemList::set_item_metadata);
- ClassDB::bind_method(D_METHOD("get_item_metadata", "idx"), &ItemList::get_item_metadata);
+ ClassDB::bind_method(D_METHOD("get_item_metadata:Variant", "idx"), &ItemList::get_item_metadata);
ClassDB::bind_method(D_METHOD("set_item_custom_bg_color", "idx", "custom_bg_color"), &ItemList::set_item_custom_bg_color);
ClassDB::bind_method(D_METHOD("get_item_custom_bg_color", "idx"), &ItemList::get_item_custom_bg_color);
@@ -1293,15 +1345,35 @@ void ItemList::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_allow_rmb_select", "allow"), &ItemList::set_allow_rmb_select);
ClassDB::bind_method(D_METHOD("get_allow_rmb_select"), &ItemList::get_allow_rmb_select);
+ ClassDB::bind_method(D_METHOD("set_auto_height", "enable"), &ItemList::set_auto_height);
+ ClassDB::bind_method(D_METHOD("has_auto_height"), &ItemList::has_auto_height);
+
ClassDB::bind_method(D_METHOD("get_item_at_pos", "pos", "exact"), &ItemList::get_item_at_pos, DEFVAL(false));
ClassDB::bind_method(D_METHOD("ensure_current_is_visible"), &ItemList::ensure_current_is_visible);
- ClassDB::bind_method(D_METHOD("get_v_scroll"), &ItemList::get_v_scroll);
+ ClassDB::bind_method(D_METHOD("get_v_scroll:VScrollBar"), &ItemList::get_v_scroll);
ClassDB::bind_method(D_METHOD("_scroll_changed"), &ItemList::_scroll_changed);
ClassDB::bind_method(D_METHOD("_gui_input"), &ItemList::_gui_input);
+ ClassDB::bind_method(D_METHOD("_set_items"), &ItemList::_set_items);
+ ClassDB::bind_method(D_METHOD("_get_items"), &ItemList::_get_items);
+
+ ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "items", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "_set_items", "_get_items");
+
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "select_mode", PROPERTY_HINT_ENUM, "Single,Multi"), "set_select_mode", "get_select_mode");
+ ADD_PROPERTYNZ(PropertyInfo(Variant::BOOL, "allow_rmb_select"), "set_allow_rmb_select", "get_allow_rmb_select");
+ ADD_PROPERTYNO(PropertyInfo(Variant::INT, "max_text_lines"), "set_max_text_lines", "get_max_text_lines");
+ ADD_PROPERTYNZ(PropertyInfo(Variant::BOOL, "auto_height"), "set_auto_height", "has_auto_height");
+ ADD_GROUP("Columns", "");
+ ADD_PROPERTYNO(PropertyInfo(Variant::INT, "max_columns"), "set_max_columns", "get_max_columns");
+ ADD_PROPERTYNZ(PropertyInfo(Variant::BOOL, "same_column_width"), "set_same_column_width", "is_same_column_width");
+ ADD_PROPERTYNZ(PropertyInfo(Variant::INT, "fixed_column_width"), "set_fixed_column_width", "get_fixed_column_width");
+ ADD_GROUP("Icon", "");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "icon_mode", PROPERTY_HINT_ENUM, "Top,Left"), "set_icon_mode", "get_icon_mode");
+ ADD_PROPERTYNO(PropertyInfo(Variant::REAL, "icon_scale"), "set_icon_scale", "get_icon_scale");
+
BIND_CONSTANT(ICON_MODE_TOP);
BIND_CONSTANT(ICON_MODE_LEFT);
BIND_CONSTANT(SELECT_SINGLE);
@@ -1326,6 +1398,8 @@ ItemList::ItemList() {
same_column_width = false;
max_text_lines = 1;
max_columns = 1;
+ auto_height = false;
+ auto_height_value = 0.0f;
scroll_bar = memnew(VScrollBar);
add_child(scroll_bar);
diff --git a/scene/gui/item_list.h b/scene/gui/item_list.h
index c7abc2990f..137eff8885 100644
--- a/scene/gui/item_list.h
+++ b/scene/gui/item_list.h
@@ -78,6 +78,9 @@ private:
bool ensure_selected_visible;
bool same_column_width;
+ bool auto_height;
+ float auto_height_value;
+
Vector<Item> items;
Vector<int> separators;
@@ -103,6 +106,9 @@ private:
real_t icon_scale;
+ Array _get_items() const;
+ void _set_items(const Array &p_items);
+
void _scroll_changed(double);
void _gui_input(const Ref<InputEvent> &p_event);
@@ -195,6 +201,11 @@ public:
void set_icon_scale(real_t p_scale);
real_t get_icon_scale() const;
+ void set_auto_height(bool p_enable);
+ bool has_auto_height() const;
+
+ Size2 get_minimum_size() const;
+
VScrollBar *get_v_scroll() { return scroll_bar; }
ItemList();
diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp
index fb85930ceb..874156821e 100644
--- a/scene/gui/label.cpp
+++ b/scene/gui/label.cpp
@@ -28,15 +28,14 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "label.h"
-#include "global_config.h"
#include "print_string.h"
+#include "project_settings.h"
#include "translation.h"
void Label::set_autowrap(bool p_autowrap) {
autowrap = p_autowrap;
word_cache_dirty = true;
- minimum_size_changed();
update();
}
bool Label::has_autowrap() const {
@@ -48,7 +47,6 @@ void Label::set_uppercase(bool p_uppercase) {
uppercase = p_uppercase;
word_cache_dirty = true;
- minimum_size_changed();
update();
}
bool Label::is_uppercase() const {
@@ -71,7 +69,6 @@ void Label::_notification(int p_what) {
xl_text = new_text;
regenerate_word_cache();
- minimum_size_changed();
update();
}
@@ -292,7 +289,7 @@ void Label::_notification(int p_what) {
Size2 Label::get_minimum_size() const {
if (autowrap)
- return Size2(1, 1);
+ return Size2(1, clip ? 1 : minsize.height);
else {
// don't want to mutable everything
@@ -487,15 +484,16 @@ void Label::regenerate_word_cache() {
}
}
- if (!autowrap) {
+ if (!autowrap)
minsize.width = width;
- if (max_lines_visible > 0 && line_count > max_lines_visible) {
- minsize.height = (font->get_height() * max_lines_visible) + (line_spacing * (max_lines_visible - 1));
- } else {
- minsize.height = (font->get_height() * line_count) + (line_spacing * (line_count - 1));
- }
+
+ if (max_lines_visible > 0 && line_count > max_lines_visible) {
+ minsize.height = (font->get_height() * max_lines_visible) + (line_spacing * (max_lines_visible - 1));
+ } else {
+ minsize.height = (font->get_height() * line_count) + (line_spacing * (line_count - 1));
}
+ minimum_size_changed();
word_cache_dirty = false;
}
@@ -533,9 +531,6 @@ void Label::set_text(const String &p_string) {
if (percent_visible < 1)
visible_chars = get_total_character_count() * percent_visible;
update();
- if (!autowrap) {
- minimum_size_changed();
- }
}
void Label::set_clip_text(bool p_clip) {
@@ -686,6 +681,7 @@ Label::Label(const String &p_text) {
max_lines_visible = -1;
set_text(p_text);
uppercase = false;
+ set_v_size_flags(SIZE_SHRINK_CENTER);
}
Label::~Label() {
diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp
index bc579020bd..f4dd3e92cd 100644
--- a/scene/gui/line_edit.cpp
+++ b/scene/gui/line_edit.cpp
@@ -574,8 +574,12 @@ void LineEdit::_notification(int p_what) {
RID ci = get_canvas_item();
Ref<StyleBox> style = get_stylebox("normal");
- if (!is_editable())
+ float disabled_alpha = 1.0; // used to set the disabled input text color
+ if (!is_editable()) {
style = get_stylebox("read_only");
+ disabled_alpha = .5;
+ draw_caret = false;
+ }
Ref<Font> font = get_font("font");
@@ -622,6 +626,13 @@ void LineEdit::_notification(int p_what) {
// draw placeholder color
if (text.empty())
font_color.a *= placeholder_alpha;
+ font_color.a *= disabled_alpha;
+
+ if (has_icon("right_icon")) {
+ Ref<Texture> r_icon = Control::get_icon("right_icon");
+ ofs_max -= r_icon->get_width();
+ r_icon->draw(ci, Point2(width - r_icon->get_width() - x_ofs, y_ofs), Color(1, 1, 1, disabled_alpha * .9));
+ }
int caret_height = font->get_height() > y_area ? y_area : font->get_height();
while (true) {
@@ -660,6 +671,11 @@ void LineEdit::_notification(int p_what) {
Point2(x_ofs, y_ofs), Size2(1, caret_height)),
cursor_color);
}
+
+ if (has_focus()) {
+
+ OS::get_singleton()->set_ime_position(get_global_position() + Point2(x_ofs, y_ofs + caret_height));
+ }
} break;
case NOTIFICATION_FOCUS_ENTER: {
@@ -667,12 +683,17 @@ void LineEdit::_notification(int p_what) {
draw_caret = true;
}
+ Point2 cursor_pos = Point2(get_cursor_pos(), 1) * get_minimum_size().height;
+ OS::get_singleton()->set_ime_position(get_global_position() + cursor_pos);
+
if (OS::get_singleton()->has_virtual_keyboard())
OS::get_singleton()->show_virtual_keyboard(text, get_global_rect());
} break;
case NOTIFICATION_FOCUS_EXIT: {
+ OS::get_singleton()->set_ime_position(Point2());
+
if (OS::get_singleton()->has_virtual_keyboard())
OS::get_singleton()->hide_virtual_keyboard();
@@ -1181,7 +1202,9 @@ void LineEdit::menu_option(int p_option) {
select_all();
} break;
case MENU_UNDO: {
- undo();
+ if (editable) {
+ undo();
+ }
} break;
}
}
diff --git a/scene/gui/option_button.cpp b/scene/gui/option_button.cpp
index 0806d35d48..b842419eab 100644
--- a/scene/gui/option_button.cpp
+++ b/scene/gui/option_button.cpp
@@ -52,11 +52,26 @@ void OptionButton::_notification(int p_what) {
RID ci = get_canvas_item();
Ref<Texture> arrow = Control::get_icon("arrow");
Ref<StyleBox> normal = get_stylebox("normal");
+ Color clr = Color(1, 1, 1);
+ if (get_constant("modulate_arrow"))
+ switch (get_draw_mode()) {
+ case DRAW_PRESSED:
+ clr = get_color("font_color_pressed");
+ break;
+ case DRAW_HOVER:
+ clr = get_color("font_color_hover");
+ break;
+ case DRAW_DISABLED:
+ clr = get_color("font_color_disabled");
+ break;
+ default:
+ clr = get_color("font_color");
+ }
Size2 size = get_size();
Point2 ofs(size.width - arrow->get_width() - get_constant("arrow_margin"), int(Math::abs((size.height - arrow->get_height()) / 2)));
- arrow->draw(ci, ofs);
+ arrow->draw(ci, ofs, clr);
} break;
}
@@ -283,7 +298,7 @@ void OptionButton::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_item_text", "idx"), &OptionButton::get_item_text);
ClassDB::bind_method(D_METHOD("get_item_icon:Texture", "idx"), &OptionButton::get_item_icon);
ClassDB::bind_method(D_METHOD("get_item_ID", "idx"), &OptionButton::get_item_ID);
- ClassDB::bind_method(D_METHOD("get_item_metadata", "idx"), &OptionButton::get_item_metadata);
+ ClassDB::bind_method(D_METHOD("get_item_metadata:Variant", "idx"), &OptionButton::get_item_metadata);
ClassDB::bind_method(D_METHOD("is_item_disabled", "idx"), &OptionButton::is_item_disabled);
ClassDB::bind_method(D_METHOD("get_item_count"), &OptionButton::get_item_count);
ClassDB::bind_method(D_METHOD("add_separator"), &OptionButton::add_separator);
@@ -291,7 +306,7 @@ void OptionButton::_bind_methods() {
ClassDB::bind_method(D_METHOD("select", "idx"), &OptionButton::select);
ClassDB::bind_method(D_METHOD("get_selected"), &OptionButton::get_selected);
ClassDB::bind_method(D_METHOD("get_selected_ID"), &OptionButton::get_selected_ID);
- ClassDB::bind_method(D_METHOD("get_selected_metadata"), &OptionButton::get_selected_metadata);
+ ClassDB::bind_method(D_METHOD("get_selected_metadata:Variant"), &OptionButton::get_selected_metadata);
ClassDB::bind_method(D_METHOD("remove_item", "idx"), &OptionButton::remove_item);
ClassDB::bind_method(D_METHOD("_select_int"), &OptionButton::_select_int);
diff --git a/scene/gui/patch_9_rect.cpp b/scene/gui/patch_9_rect.cpp
index 249090830d..e577000f99 100644
--- a/scene/gui/patch_9_rect.cpp
+++ b/scene/gui/patch_9_rect.cpp
@@ -54,8 +54,8 @@ Size2 NinePatchRect::get_minimum_size() const {
}
void NinePatchRect::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_texture", "texture"), &NinePatchRect::set_texture);
- ClassDB::bind_method(D_METHOD("get_texture"), &NinePatchRect::get_texture);
+ ClassDB::bind_method(D_METHOD("set_texture", "texture:Texture"), &NinePatchRect::set_texture);
+ ClassDB::bind_method(D_METHOD("get_texture:Texture"), &NinePatchRect::get_texture);
ClassDB::bind_method(D_METHOD("set_patch_margin", "margin", "value"), &NinePatchRect::set_patch_margin);
ClassDB::bind_method(D_METHOD("get_patch_margin", "margin"), &NinePatchRect::get_patch_margin);
ClassDB::bind_method(D_METHOD("set_region_rect", "rect"), &NinePatchRect::set_region_rect);
diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp
index 74b26da580..f59a2e06eb 100644
--- a/scene/gui/popup_menu.cpp
+++ b/scene/gui/popup_menu.cpp
@@ -696,6 +696,17 @@ String PopupMenu::get_item_text(int p_idx) const {
ERR_FAIL_INDEX_V(p_idx, items.size(), "");
return items[p_idx].text;
}
+
+int PopupMenu::get_item_idx_from_text(const String &text) const {
+
+ for (int idx = 0; idx < items.size(); idx++) {
+ if (items[idx].text == text)
+ return idx;
+ }
+
+ return -1;
+}
+
Ref<Texture> PopupMenu::get_item_icon(int p_idx) const {
ERR_FAIL_INDEX_V(p_idx, items.size(), Ref<Texture>());
@@ -1064,19 +1075,19 @@ void PopupMenu::clear_autohide_areas() {
void PopupMenu::_bind_methods() {
ClassDB::bind_method(D_METHOD("_gui_input"), &PopupMenu::_gui_input);
- ClassDB::bind_method(D_METHOD("add_icon_item", "texture", "label", "id", "accel"), &PopupMenu::add_icon_item, DEFVAL(-1), DEFVAL(0));
+ ClassDB::bind_method(D_METHOD("add_icon_item", "texture:Texture", "label", "id", "accel"), &PopupMenu::add_icon_item, DEFVAL(-1), DEFVAL(0));
ClassDB::bind_method(D_METHOD("add_item", "label", "id", "accel"), &PopupMenu::add_item, DEFVAL(-1), DEFVAL(0));
- ClassDB::bind_method(D_METHOD("add_icon_check_item", "texture", "label", "id", "accel"), &PopupMenu::add_icon_check_item, DEFVAL(-1), DEFVAL(0));
+ ClassDB::bind_method(D_METHOD("add_icon_check_item", "texture:Texture", "label", "id", "accel"), &PopupMenu::add_icon_check_item, DEFVAL(-1), DEFVAL(0));
ClassDB::bind_method(D_METHOD("add_check_item", "label", "id", "accel"), &PopupMenu::add_check_item, DEFVAL(-1), DEFVAL(0));
ClassDB::bind_method(D_METHOD("add_submenu_item", "label", "submenu", "id"), &PopupMenu::add_submenu_item, DEFVAL(-1));
- ClassDB::bind_method(D_METHOD("add_icon_shortcut", "texture", "shortcut:ShortCut", "id", "global"), &PopupMenu::add_icon_shortcut, DEFVAL(-1), DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("add_icon_shortcut", "texture:Texture", "shortcut:ShortCut", "id", "global"), &PopupMenu::add_icon_shortcut, DEFVAL(-1), DEFVAL(false));
ClassDB::bind_method(D_METHOD("add_shortcut", "shortcut:ShortCut", "id", "global"), &PopupMenu::add_shortcut, DEFVAL(-1), DEFVAL(false));
- ClassDB::bind_method(D_METHOD("add_icon_check_shortcut", "texture", "shortcut:ShortCut", "id", "global"), &PopupMenu::add_icon_check_shortcut, DEFVAL(-1), DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("add_icon_check_shortcut", "texture:Texture", "shortcut:ShortCut", "id", "global"), &PopupMenu::add_icon_check_shortcut, DEFVAL(-1), DEFVAL(false));
ClassDB::bind_method(D_METHOD("add_check_shortcut", "shortcut:ShortCut", "id", "global"), &PopupMenu::add_check_shortcut, DEFVAL(-1), DEFVAL(false));
ClassDB::bind_method(D_METHOD("set_item_text", "idx", "text"), &PopupMenu::set_item_text);
- ClassDB::bind_method(D_METHOD("set_item_icon", "idx", "icon"), &PopupMenu::set_item_icon);
+ ClassDB::bind_method(D_METHOD("set_item_icon", "idx", "icon:Texture"), &PopupMenu::set_item_icon);
ClassDB::bind_method(D_METHOD("set_item_checked", "idx", "checked"), &PopupMenu::set_item_checked);
ClassDB::bind_method(D_METHOD("set_item_ID", "idx", "id"), &PopupMenu::set_item_ID);
ClassDB::bind_method(D_METHOD("set_item_accelerator", "idx", "accel"), &PopupMenu::set_item_accelerator);
@@ -1091,12 +1102,12 @@ void PopupMenu::_bind_methods() {
ClassDB::bind_method(D_METHOD("toggle_item_checked", "idx"), &PopupMenu::toggle_item_checked);
ClassDB::bind_method(D_METHOD("get_item_text", "idx"), &PopupMenu::get_item_text);
- ClassDB::bind_method(D_METHOD("get_item_icon", "idx"), &PopupMenu::get_item_icon);
+ ClassDB::bind_method(D_METHOD("get_item_icon:Texture", "idx"), &PopupMenu::get_item_icon);
ClassDB::bind_method(D_METHOD("is_item_checked", "idx"), &PopupMenu::is_item_checked);
ClassDB::bind_method(D_METHOD("get_item_ID", "idx"), &PopupMenu::get_item_ID);
ClassDB::bind_method(D_METHOD("get_item_index", "id"), &PopupMenu::get_item_index);
ClassDB::bind_method(D_METHOD("get_item_accelerator", "idx"), &PopupMenu::get_item_accelerator);
- ClassDB::bind_method(D_METHOD("get_item_metadata", "idx"), &PopupMenu::get_item_metadata);
+ ClassDB::bind_method(D_METHOD("get_item_metadata:Variant", "idx"), &PopupMenu::get_item_metadata);
ClassDB::bind_method(D_METHOD("is_item_disabled", "idx"), &PopupMenu::is_item_disabled);
ClassDB::bind_method(D_METHOD("get_item_submenu", "idx"), &PopupMenu::get_item_submenu);
ClassDB::bind_method(D_METHOD("is_item_separator", "idx"), &PopupMenu::is_item_separator);
diff --git a/scene/gui/popup_menu.h b/scene/gui/popup_menu.h
index a9bd8f7e50..6f1a2db363 100644
--- a/scene/gui/popup_menu.h
+++ b/scene/gui/popup_menu.h
@@ -132,6 +132,7 @@ public:
void toggle_item_checked(int p_idx);
String get_item_text(int p_idx) const;
+ int get_item_idx_from_text(const String &text) const;
Ref<Texture> get_item_icon(int p_idx) const;
bool is_item_checked(int p_idx) const;
int get_item_ID(int p_idx) const;
diff --git a/scene/gui/range.cpp b/scene/gui/range.cpp
index 7158592bb1..6bec365dcf 100644
--- a/scene/gui/range.cpp
+++ b/scene/gui/range.cpp
@@ -234,7 +234,7 @@ void Range::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_exp_ratio", "enabled"), &Range::set_exp_ratio);
ClassDB::bind_method(D_METHOD("is_ratio_exp"), &Range::is_ratio_exp);
- ClassDB::bind_method(D_METHOD("share", "with"), &Range::_share);
+ ClassDB::bind_method(D_METHOD("share", "with:Node"), &Range::_share);
ClassDB::bind_method(D_METHOD("unshare"), &Range::unshare);
ADD_SIGNAL(MethodInfo("value_changed", PropertyInfo(Variant::REAL, "value")));
@@ -273,8 +273,8 @@ Range::Range() {
shared = memnew(Shared);
shared->min = 0;
shared->max = 100;
- shared->val =
- shared->step = 1;
+ shared->val = 0;
+ shared->step = 1;
shared->page = 0;
shared->owners.insert(this);
shared->exp_ratio = false;
diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp
index 78ede6e494..9f71fa070c 100644
--- a/scene/gui/rich_text_label.cpp
+++ b/scene/gui/rich_text_label.cpp
@@ -1822,15 +1822,40 @@ String RichTextLabel::get_text() {
return text;
}
+void RichTextLabel::set_text(const String &p_string) {
+ clear();
+ add_text(p_string);
+}
+
+void RichTextLabel::set_percent_visible(float p_percent) {
+
+ if (p_percent < 0 || p_percent >= 1) {
+
+ visible_characters = -1;
+ percent_visible = 1;
+
+ } else {
+
+ visible_characters = get_total_character_count() * p_percent;
+ percent_visible = p_percent;
+ }
+ update();
+}
+
+float RichTextLabel::get_percent_visible() const {
+ return percent_visible;
+}
+
void RichTextLabel::_bind_methods() {
ClassDB::bind_method(D_METHOD("_gui_input"), &RichTextLabel::_gui_input);
ClassDB::bind_method(D_METHOD("_scroll_changed"), &RichTextLabel::_scroll_changed);
ClassDB::bind_method(D_METHOD("get_text"), &RichTextLabel::get_text);
ClassDB::bind_method(D_METHOD("add_text", "text"), &RichTextLabel::add_text);
+ ClassDB::bind_method(D_METHOD("set_text", "text"), &RichTextLabel::set_text);
ClassDB::bind_method(D_METHOD("add_image", "image:Texture"), &RichTextLabel::add_image);
ClassDB::bind_method(D_METHOD("newline"), &RichTextLabel::add_newline);
- ClassDB::bind_method(D_METHOD("remove_line"), &RichTextLabel::remove_line);
+ ClassDB::bind_method(D_METHOD("remove_line", "line"), &RichTextLabel::remove_line);
ClassDB::bind_method(D_METHOD("push_font", "font:Font"), &RichTextLabel::push_font);
ClassDB::bind_method(D_METHOD("push_color", "color"), &RichTextLabel::push_color);
ClassDB::bind_method(D_METHOD("push_align", "align"), &RichTextLabel::push_align);
@@ -1873,6 +1898,9 @@ void RichTextLabel::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_visible_characters", "amount"), &RichTextLabel::set_visible_characters);
ClassDB::bind_method(D_METHOD("get_visible_characters"), &RichTextLabel::get_visible_characters);
+ ClassDB::bind_method(D_METHOD("set_percent_visible", "percent_visible"), &RichTextLabel::set_percent_visible);
+ ClassDB::bind_method(D_METHOD("get_percent_visible"), &RichTextLabel::get_percent_visible);
+
ClassDB::bind_method(D_METHOD("get_total_character_count"), &RichTextLabel::get_total_character_count);
ClassDB::bind_method(D_METHOD("set_use_bbcode", "enable"), &RichTextLabel::set_use_bbcode);
@@ -1881,7 +1909,9 @@ void RichTextLabel::_bind_methods() {
ADD_GROUP("BBCode", "bbcode_");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "bbcode_enabled"), "set_use_bbcode", "is_using_bbcode");
ADD_PROPERTY(PropertyInfo(Variant::STRING, "bbcode_text", PROPERTY_HINT_MULTILINE_TEXT), "set_bbcode", "get_bbcode");
+
ADD_PROPERTY(PropertyInfo(Variant::INT, "visible_characters", PROPERTY_HINT_RANGE, "-1,128000,1"), "set_visible_characters", "get_visible_characters");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "percent_visible", PROPERTY_HINT_RANGE, "0,1,0.001"), "set_percent_visible", "get_percent_visible");
ADD_SIGNAL(MethodInfo("meta_clicked", PropertyInfo(Variant::NIL, "meta")));
@@ -1914,7 +1944,6 @@ void RichTextLabel::set_visible_characters(int p_visible) {
}
int RichTextLabel::get_visible_characters() const {
-
return visible_characters;
}
int RichTextLabel::get_total_character_count() const {
@@ -1964,11 +1993,11 @@ RichTextLabel::RichTextLabel() {
selection.enabled = false;
visible_characters = -1;
+ percent_visible = 1;
set_clip_contents(true);
}
RichTextLabel::~RichTextLabel() {
-
memdelete(main);
}
diff --git a/scene/gui/rich_text_label.h b/scene/gui/rich_text_label.h
index eedb7e54db..409a8f6b3f 100644
--- a/scene/gui/rich_text_label.h
+++ b/scene/gui/rich_text_label.h
@@ -258,6 +258,7 @@ private:
Selection selection;
int visible_characters;
+ float percent_visible;
void _process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &y, int p_width, int p_line, ProcessMode p_mode, const Ref<Font> &p_base_font, const Color &p_base_color, const Point2i &p_click_pos = Point2i(), Item **r_click_item = NULL, int *r_click_char = NULL, bool *r_outside = NULL, int p_char_count = 0);
void _find_click(ItemFrame *p_frame, const Point2i &p_click, Item **r_click_item = NULL, int *r_click_char = NULL, bool *r_outside = NULL);
@@ -340,10 +341,15 @@ public:
void set_bbcode(const String &p_bbcode);
String get_bbcode() const;
+ void set_text(const String &p_string);
+
void set_visible_characters(int p_visible);
int get_visible_characters() const;
int get_total_character_count() const;
+ void set_percent_visible(float p_percent);
+ float get_percent_visible() const;
+
RichTextLabel();
~RichTextLabel();
};
diff --git a/scene/gui/slider.cpp b/scene/gui/slider.cpp
index d0e708bf73..9ba17ce34f 100644
--- a/scene/gui/slider.cpp
+++ b/scene/gui/slider.cpp
@@ -39,6 +39,10 @@ Size2 Slider::get_minimum_size() const {
void Slider::_gui_input(Ref<InputEvent> p_event) {
+ if (!editable) {
+ return;
+ }
+
Ref<InputEventMouseButton> mb = p_event;
if (mb.is_valid()) {
@@ -158,12 +162,13 @@ void Slider::_notification(int p_what) {
Size2i size = get_size();
Ref<StyleBox> style = get_stylebox("slider");
Ref<StyleBox> focus = get_stylebox("focus");
- Ref<Texture> grabber = get_icon(mouse_inside || has_focus() ? "grabber_highlight" : "grabber");
+ Ref<Texture> grabber = get_icon(editable ? ((mouse_inside || has_focus()) ? "grabber_highlight" : "grabber") : "grabber_disabled");
Ref<Texture> tick = get_icon("tick");
if (orientation == VERTICAL) {
- style->draw(ci, Rect2i(Point2i(), Size2i(style->get_minimum_size().width + style->get_center_size().width, size.height)));
+ int widget_width = style->get_minimum_size().width + style->get_center_size().width;
+ style->draw(ci, Rect2i(Point2i(size.width / 2 - widget_width / 2, 0), Size2i(widget_width, size.height)));
/*
if (mouse_inside||has_focus())
focus->draw(ci,Rect2i(Point2i(),Size2i(style->get_minimum_size().width+style->get_center_size().width,size.height)));
@@ -179,7 +184,9 @@ void Slider::_notification(int p_what) {
}
grabber->draw(ci, Point2i(size.width / 2 - grabber->get_size().width / 2, size.height - get_as_ratio() * areasize - grabber->get_size().height));
} else {
- style->draw(ci, Rect2i(Point2i(), Size2i(size.width, style->get_minimum_size().height + style->get_center_size().height)));
+
+ int widget_height = style->get_minimum_size().height + style->get_center_size().height;
+ style->draw(ci, Rect2i(Point2i(0, size.height / 2 - widget_height / 2), Size2i(size.width, widget_height)));
/*
if (mouse_inside||has_focus())
focus->draw(ci,Rect2i(Point2i(),Size2i(size.width,style->get_minimum_size().height+style->get_center_size().height)));
@@ -231,6 +238,17 @@ void Slider::set_ticks_on_borders(bool _tob) {
update();
}
+void Slider::set_editable(bool p_editable) {
+
+ editable = p_editable;
+ update();
+}
+
+bool Slider::is_editable() const {
+
+ return editable;
+}
+
void Slider::_bind_methods() {
ClassDB::bind_method(D_METHOD("_gui_input"), &Slider::_gui_input);
@@ -240,6 +258,10 @@ void Slider::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_ticks_on_borders"), &Slider::get_ticks_on_borders);
ClassDB::bind_method(D_METHOD("set_ticks_on_borders", "ticks_on_border"), &Slider::set_ticks_on_borders);
+ ClassDB::bind_method(D_METHOD("set_editable", "editable"), &Slider::set_editable);
+ ClassDB::bind_method(D_METHOD("is_editable"), &Slider::is_editable);
+
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "editable"), "set_editable", "is_editable");
ADD_PROPERTY(PropertyInfo(Variant::INT, "tick_count", PROPERTY_HINT_RANGE, "0,4096,1"), "set_ticks", "get_ticks");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "ticks_on_borders"), "set_ticks_on_borders", "get_ticks_on_borders");
ADD_PROPERTY(PropertyInfo(Variant::INT, "focus_mode", PROPERTY_HINT_ENUM, "None,Click,All"), "set_focus_mode", "get_focus_mode");
@@ -251,5 +273,6 @@ Slider::Slider(Orientation p_orientation) {
grab.active = false;
ticks = 0;
custom_step = -1;
+ editable = true;
set_focus_mode(FOCUS_ALL);
}
diff --git a/scene/gui/slider.h b/scene/gui/slider.h
index 7194484058..f3cf3c6f48 100644
--- a/scene/gui/slider.h
+++ b/scene/gui/slider.h
@@ -46,6 +46,7 @@ class Slider : public Range {
bool mouse_inside;
Orientation orientation;
float custom_step;
+ bool editable;
protected:
void _gui_input(Ref<InputEvent> p_event);
@@ -65,6 +66,9 @@ public:
void set_ticks_on_borders(bool);
bool get_ticks_on_borders() const;
+ void set_editable(bool p_editable);
+ bool is_editable() const;
+
Slider(Orientation p_orientation = VERTICAL);
};
diff --git a/scene/gui/spin_box.cpp b/scene/gui/spin_box.cpp
index c5b9df15b9..1ba6e6e4bd 100644
--- a/scene/gui/spin_box.cpp
+++ b/scene/gui/spin_box.cpp
@@ -253,7 +253,7 @@ void SpinBox::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_editable", "editable"), &SpinBox::set_editable);
ClassDB::bind_method(D_METHOD("is_editable"), &SpinBox::is_editable);
ClassDB::bind_method(D_METHOD("_line_edit_focus_exit"), &SpinBox::_line_edit_focus_exit);
- ClassDB::bind_method(D_METHOD("get_line_edit"), &SpinBox::get_line_edit);
+ ClassDB::bind_method(D_METHOD("get_line_edit:LineEdit"), &SpinBox::get_line_edit);
ClassDB::bind_method(D_METHOD("_line_edit_input"), &SpinBox::_line_edit_input);
ClassDB::bind_method(D_METHOD("_range_click_timeout"), &SpinBox::_range_click_timeout);
diff --git a/scene/gui/split_container.cpp b/scene/gui/split_container.cpp
index 31236fa277..e3dad08809 100644
--- a/scene/gui/split_container.cpp
+++ b/scene/gui/split_container.cpp
@@ -131,7 +131,12 @@ void SplitContainer::_resort() {
if (ratiomode) {
- middle_sep = ms_first[axis] + available / 2;
+ int first_ratio = first->get_stretch_ratio();
+ int second_ratio = second->get_stretch_ratio();
+
+ float ratio = float(first_ratio) / (first_ratio + second_ratio);
+
+ middle_sep = ms_first[axis] + available * ratio;
} else if (expand_first_mode) {
@@ -144,12 +149,17 @@ void SplitContainer::_resort() {
} else if (ratiomode) {
- if (expand_ofs < -(available / 2))
- expand_ofs = -(available / 2);
- else if (expand_ofs > (available / 2))
- expand_ofs = (available / 2);
+ int first_ratio = first->get_stretch_ratio();
+ int second_ratio = second->get_stretch_ratio();
+
+ float ratio = float(first_ratio) / (first_ratio + second_ratio);
+
+ if (expand_ofs < -(available * ratio))
+ expand_ofs = -(available * ratio);
+ else if (expand_ofs > (available * (1.0 - ratio)))
+ expand_ofs = (available * (1.0 - ratio));
- middle_sep = ms_first[axis] + available / 2 + expand_ofs;
+ middle_sep = ms_first[axis] + available * ratio + expand_ofs;
} else if (expand_first_mode) {
diff --git a/scene/gui/tabs.cpp b/scene/gui/tabs.cpp
index 600493b439..24eb19fbc2 100644
--- a/scene/gui/tabs.cpp
+++ b/scene/gui/tabs.cpp
@@ -593,8 +593,44 @@ void Tabs::remove_tab(int p_idx) {
_ensure_no_over_offset();
}
+Variant Tabs::get_drag_data(const Point2 &p_point) {
+
+ return get_tab_idx_at_point(p_point);
+}
+
+bool Tabs::can_drop_data(const Point2 &p_point, const Variant &p_data) const {
+
+ return get_tab_idx_at_point(p_point) > -1;
+}
+
+void Tabs::drop_data(const Point2 &p_point, const Variant &p_data) {
+
+ int hover_now = get_tab_idx_at_point(p_point);
+
+ ERR_FAIL_INDEX(hover_now, tabs.size());
+ emit_signal("reposition_active_tab_request", hover_now);
+}
+
+int Tabs::get_tab_idx_at_point(const Point2 &p_point) const {
+
+ int hover_now = -1;
+ for (int i = 0; i < tabs.size(); i++) {
+
+ if (i < offset)
+ continue;
+
+ Rect2 rect = get_tab_rect(i);
+ if (rect.has_point(p_point)) {
+ hover_now = i;
+ }
+ }
+
+ return hover_now;
+}
+
void Tabs::set_tab_align(TabAlign p_align) {
+ ERR_FAIL_INDEX(p_align, ALIGN_MAX);
tab_align = p_align;
update();
}
@@ -604,6 +640,22 @@ Tabs::TabAlign Tabs::get_tab_align() const {
return tab_align;
}
+void Tabs::move_tab(int from, int to) {
+
+ if (from == to)
+ return;
+
+ ERR_FAIL_INDEX(from, tabs.size());
+ ERR_FAIL_INDEX(to, tabs.size());
+
+ Tab tab_from = tabs[from];
+ tabs.remove(from);
+ tabs.insert(to, tab_from);
+
+ _update_cache();
+ update();
+}
+
int Tabs::get_tab_width(int p_idx) const {
ERR_FAIL_INDEX_V(p_idx, tabs.size(), 0);
@@ -708,15 +760,22 @@ void Tabs::ensure_tab_visible(int p_idx) {
}
}
-Rect2 Tabs::get_tab_rect(int p_tab) {
+Rect2 Tabs::get_tab_rect(int p_tab) const {
return Rect2(tabs[p_tab].ofs_cache, 0, tabs[p_tab].size_cache, get_size().height);
}
void Tabs::set_tab_close_display_policy(CloseButtonDisplayPolicy p_policy) {
+
+ ERR_FAIL_INDEX(p_policy, CLOSE_BUTTON_MAX);
cb_displaypolicy = p_policy;
update();
}
+Tabs::CloseButtonDisplayPolicy Tabs::get_tab_close_display_policy() const {
+
+ return cb_displaypolicy;
+}
+
void Tabs::set_min_width(int p_width) {
min_width = p_width;
}
@@ -734,25 +793,33 @@ void Tabs::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_tab_disabled", "tab_idx", "disabled"), &Tabs::set_tab_disabled);
ClassDB::bind_method(D_METHOD("get_tab_disabled", "tab_idx"), &Tabs::get_tab_disabled);
ClassDB::bind_method(D_METHOD("remove_tab", "tab_idx"), &Tabs::remove_tab);
- ClassDB::bind_method(D_METHOD("add_tab", "title", "icon:Texture"), &Tabs::add_tab);
+ ClassDB::bind_method(D_METHOD("add_tab", "title", "icon:Texture"), &Tabs::add_tab, DEFVAL(""), DEFVAL(Ref<Texture>()));
ClassDB::bind_method(D_METHOD("set_tab_align", "align"), &Tabs::set_tab_align);
ClassDB::bind_method(D_METHOD("get_tab_align"), &Tabs::get_tab_align);
ClassDB::bind_method(D_METHOD("ensure_tab_visible", "idx"), &Tabs::ensure_tab_visible);
+ ClassDB::bind_method(D_METHOD("get_tab_rect", "tab_idx"), &Tabs::get_tab_rect);
+ ClassDB::bind_method(D_METHOD("move_tab", "from", "to"), &Tabs::move_tab);
+ ClassDB::bind_method(D_METHOD("set_tab_close_display_policy", "policy"), &Tabs::set_tab_close_display_policy);
+ ClassDB::bind_method(D_METHOD("get_tab_close_display_policy"), &Tabs::get_tab_close_display_policy);
ADD_SIGNAL(MethodInfo("tab_changed", PropertyInfo(Variant::INT, "tab")));
ADD_SIGNAL(MethodInfo("right_button_pressed", PropertyInfo(Variant::INT, "tab")));
ADD_SIGNAL(MethodInfo("tab_close", PropertyInfo(Variant::INT, "tab")));
ADD_SIGNAL(MethodInfo("tab_hover", PropertyInfo(Variant::INT, "tab")));
+ ADD_SIGNAL(MethodInfo("reposition_active_tab_request", PropertyInfo(Variant::INT, "idx_to")));
ADD_PROPERTY(PropertyInfo(Variant::INT, "current_tab", PROPERTY_HINT_RANGE, "-1,4096,1", PROPERTY_USAGE_EDITOR), "set_current_tab", "get_current_tab");
+ ADD_PROPERTYNZ(PropertyInfo(Variant::INT, "tab_close_display_policy", PROPERTY_HINT_ENUM, "Show Never,Show Active Only,Show Always"), "set_tab_close_display_policy", "get_tab_close_display_policy");
BIND_CONSTANT(ALIGN_LEFT);
BIND_CONSTANT(ALIGN_CENTER);
BIND_CONSTANT(ALIGN_RIGHT);
+ BIND_CONSTANT(ALIGN_MAX);
BIND_CONSTANT(CLOSE_BUTTON_SHOW_ACTIVE_ONLY);
BIND_CONSTANT(CLOSE_BUTTON_SHOW_ALWAYS);
BIND_CONSTANT(CLOSE_BUTTON_SHOW_NEVER);
+ BIND_CONSTANT(CLOSE_BUTTON_MAX);
}
Tabs::Tabs() {
diff --git a/scene/gui/tabs.h b/scene/gui/tabs.h
index 65d409c410..86ad128dcd 100644
--- a/scene/gui/tabs.h
+++ b/scene/gui/tabs.h
@@ -41,7 +41,8 @@ public:
ALIGN_LEFT,
ALIGN_CENTER,
- ALIGN_RIGHT
+ ALIGN_RIGHT,
+ ALIGN_MAX
};
enum CloseButtonDisplayPolicy {
@@ -49,6 +50,7 @@ public:
CLOSE_BUTTON_SHOW_NEVER,
CLOSE_BUTTON_SHOW_ACTIVE_ONLY,
CLOSE_BUTTON_SHOW_ALWAYS,
+ CLOSE_BUTTON_MAX
};
private:
@@ -96,6 +98,11 @@ protected:
void _notification(int p_what);
static void _bind_methods();
+ Variant get_drag_data(const Point2 &p_point);
+ bool can_drop_data(const Point2 &p_point, const Variant &p_data) const;
+ void drop_data(const Point2 &p_point, const Variant &p_data);
+ int get_tab_idx_at_point(const Point2 &p_point) const;
+
public:
void add_tab(const String &p_str = "", const Ref<Texture> &p_icon = Ref<Texture>());
@@ -114,7 +121,10 @@ public:
void set_tab_align(TabAlign p_align);
TabAlign get_tab_align() const;
+ void move_tab(int from, int to);
+
void set_tab_close_display_policy(CloseButtonDisplayPolicy p_policy);
+ CloseButtonDisplayPolicy get_tab_close_display_policy() const;
int get_tab_count() const;
void set_current_tab(int p_current);
@@ -128,12 +138,13 @@ public:
void ensure_tab_visible(int p_idx);
void set_min_width(int p_width);
- Rect2 get_tab_rect(int p_tab);
+ Rect2 get_tab_rect(int p_tab) const;
Size2 get_minimum_size() const;
Tabs();
};
VARIANT_ENUM_CAST(Tabs::TabAlign);
+VARIANT_ENUM_CAST(Tabs::CloseButtonDisplayPolicy);
#endif // TABS_H
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 936a9b77f8..8baca50d32 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -33,8 +33,8 @@
#include "os/keyboard.h"
#include "os/os.h"
-#include "global_config.h"
#include "message_queue.h"
+#include "project_settings.h"
#include "scene/main/viewport.h"
#define TAB_PIXELS
@@ -1191,12 +1191,19 @@ void TextEdit::_notification(int p_what) {
}
}
+ if (has_focus()) {
+ OS::get_singleton()->set_ime_position(get_global_position() + cursor_pos + Point2(0, get_row_height()));
+ }
} break;
case NOTIFICATION_FOCUS_ENTER: {
if (!caret_blink_enabled) {
draw_caret = true;
}
+
+ Point2 cursor_pos = Point2(cursor_get_column(), cursor_get_line()) * get_row_height();
+ OS::get_singleton()->set_ime_position(get_global_position() + cursor_pos);
+
if (OS::get_singleton()->has_virtual_keyboard())
OS::get_singleton()->show_virtual_keyboard(get_text(), get_global_rect());
if (raised_from_completion) {
@@ -1206,6 +1213,8 @@ void TextEdit::_notification(int p_what) {
} break;
case NOTIFICATION_FOCUS_EXIT: {
+ OS::get_singleton()->set_ime_position(Point2());
+
if (OS::get_singleton()->has_virtual_keyboard())
OS::get_singleton()->hide_virtual_keyboard();
if (raised_from_completion) {
@@ -4588,7 +4597,7 @@ void TextEdit::_bind_methods() {
ClassDB::bind_method(D_METHOD("add_keyword_color", "keyword", "color"), &TextEdit::add_keyword_color);
ClassDB::bind_method(D_METHOD("add_color_region", "begin_key", "end_key", "color", "line_only"), &TextEdit::add_color_region, DEFVAL(false));
ClassDB::bind_method(D_METHOD("clear_colors"), &TextEdit::clear_colors);
- ClassDB::bind_method(D_METHOD("menu_option"), &TextEdit::menu_option);
+ ClassDB::bind_method(D_METHOD("menu_option", "option"), &TextEdit::menu_option);
ClassDB::bind_method(D_METHOD("get_menu:PopupMenu"), &TextEdit::get_menu);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "syntax_highlighting"), "set_syntax_coloring", "is_syntax_coloring_enabled");
diff --git a/scene/gui/texture_button.cpp b/scene/gui/texture_button.cpp
index 33d9b76b70..2912aa82fc 100644
--- a/scene/gui/texture_button.cpp
+++ b/scene/gui/texture_button.cpp
@@ -206,7 +206,7 @@ void TextureButton::_bind_methods() {
ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT, "texture_focused", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_focused_texture", "get_focused_texture");
ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT, "texture_click_mask", PROPERTY_HINT_RESOURCE_TYPE, "BitMap"), "set_click_mask", "get_click_mask");
ADD_PROPERTYNZ(PropertyInfo(Variant::BOOL, "expand", PROPERTY_HINT_RESOURCE_TYPE, "bool"), "set_expand", "get_expand");
- ADD_PROPERTYNO(PropertyInfo(Variant::INT, "stretch_mode", PROPERTY_HINT_ENUM, "Scale,Tile,Keep,Keep Centered,Keep Aspect,Keep Aspect Centered,Keep Aspect Covered"), "set_stretch_mode", "get_stretch_mode");
+ ADD_PROPERTYNZ(PropertyInfo(Variant::INT, "stretch_mode", PROPERTY_HINT_ENUM, "Scale,Tile,Keep,Keep Centered,Keep Aspect,Keep Aspect Centered,Keep Aspect Covered"), "set_stretch_mode", "get_stretch_mode");
BIND_CONSTANT(STRETCH_SCALE);
BIND_CONSTANT(STRETCH_TILE);
diff --git a/scene/gui/texture_progress.cpp b/scene/gui/texture_progress.cpp
index 081c7ddb73..40995b19fa 100644
--- a/scene/gui/texture_progress.cpp
+++ b/scene/gui/texture_progress.cpp
@@ -242,14 +242,14 @@ Point2 TextureProgress::get_radial_center_offset() {
void TextureProgress::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_under_texture", "tex"), &TextureProgress::set_under_texture);
- ClassDB::bind_method(D_METHOD("get_under_texture"), &TextureProgress::get_under_texture);
+ ClassDB::bind_method(D_METHOD("set_under_texture", "tex:Texture"), &TextureProgress::set_under_texture);
+ ClassDB::bind_method(D_METHOD("get_under_texture:Texture"), &TextureProgress::get_under_texture);
- ClassDB::bind_method(D_METHOD("set_progress_texture", "tex"), &TextureProgress::set_progress_texture);
- ClassDB::bind_method(D_METHOD("get_progress_texture"), &TextureProgress::get_progress_texture);
+ ClassDB::bind_method(D_METHOD("set_progress_texture", "tex:Texture"), &TextureProgress::set_progress_texture);
+ ClassDB::bind_method(D_METHOD("get_progress_texture:Texture"), &TextureProgress::get_progress_texture);
- ClassDB::bind_method(D_METHOD("set_over_texture", "tex"), &TextureProgress::set_over_texture);
- ClassDB::bind_method(D_METHOD("get_over_texture"), &TextureProgress::get_over_texture);
+ ClassDB::bind_method(D_METHOD("set_over_texture", "tex:Texture"), &TextureProgress::set_over_texture);
+ ClassDB::bind_method(D_METHOD("get_over_texture:Texture"), &TextureProgress::get_over_texture);
ClassDB::bind_method(D_METHOD("set_fill_mode", "mode"), &TextureProgress::set_fill_mode);
ClassDB::bind_method(D_METHOD("get_fill_mode"), &TextureProgress::get_fill_mode);
diff --git a/scene/gui/texture_rect.cpp b/scene/gui/texture_rect.cpp
index 92a3db6a74..9459002bc0 100644
--- a/scene/gui/texture_rect.cpp
+++ b/scene/gui/texture_rect.cpp
@@ -101,8 +101,8 @@ Size2 TextureRect::get_minimum_size() const {
}
void TextureRect::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_texture", "texture"), &TextureRect::set_texture);
- ClassDB::bind_method(D_METHOD("get_texture"), &TextureRect::get_texture);
+ ClassDB::bind_method(D_METHOD("set_texture", "texture:Texture"), &TextureRect::set_texture);
+ ClassDB::bind_method(D_METHOD("get_texture:Texture"), &TextureRect::get_texture);
ClassDB::bind_method(D_METHOD("set_expand", "enable"), &TextureRect::set_expand);
ClassDB::bind_method(D_METHOD("has_expand"), &TextureRect::has_expand);
ClassDB::bind_method(D_METHOD("set_stretch_mode", "stretch_mode"), &TextureRect::set_stretch_mode);
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index d8788b4eca..1456ab51c0 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -28,11 +28,11 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "tree.h"
-#include "global_config.h"
#include "os/input.h"
#include "os/keyboard.h"
#include "os/os.h"
#include "print_string.h"
+#include "project_settings.h"
#include "scene/main/viewport.h"
void TreeItem::move_to_top() {
@@ -70,7 +70,7 @@ Size2 TreeItem::Cell::get_icon_size() const {
return icon_region.size;
}
-void TreeItem::Cell::draw_icon(const RID &p_where, const Point2 &p_pos, const Size2 &p_size) const {
+void TreeItem::Cell::draw_icon(const RID &p_where, const Point2 &p_pos, const Size2 &p_size, const Color &p_color) const {
if (icon.is_null())
return;
@@ -79,10 +79,10 @@ void TreeItem::Cell::draw_icon(const RID &p_where, const Point2 &p_pos, const Si
if (icon_region == Rect2i()) {
- icon->draw_rect_region(p_where, Rect2(p_pos, dsize), Rect2(Point2(), icon->get_size()));
+ icon->draw_rect_region(p_where, Rect2(p_pos, dsize), Rect2(Point2(), icon->get_size()), p_color);
} else {
- icon->draw_rect_region(p_where, Rect2(p_pos, dsize), icon_region);
+ icon->draw_rect_region(p_where, Rect2(p_pos, dsize), icon_region, p_color);
}
}
@@ -203,6 +203,19 @@ Rect2 TreeItem::get_icon_region(int p_column) const {
return cells[p_column].icon_region;
}
+void TreeItem::set_icon_color(int p_column, const Color &p_icon_color) {
+
+ ERR_FAIL_INDEX(p_column, cells.size());
+ cells[p_column].icon_color = p_icon_color;
+ _changed_notify(p_column);
+}
+
+Color TreeItem::get_icon_color(int p_column) const {
+
+ ERR_FAIL_INDEX_V(p_column, cells.size(), Color());
+ return cells[p_column].icon_color;
+}
+
void TreeItem::set_icon_max_width(int p_column, int p_max) {
ERR_FAIL_INDEX(p_column, cells.size());
@@ -697,7 +710,7 @@ void TreeItem::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_next_visible:TreeItem"), &TreeItem::get_next_visible);
ClassDB::bind_method(D_METHOD("get_prev_visible:TreeItem"), &TreeItem::get_prev_visible);
- ClassDB::bind_method(D_METHOD("remove_child:TreeItem", "child"), &TreeItem::_remove_child);
+ ClassDB::bind_method(D_METHOD("remove_child", "child"), &TreeItem::_remove_child);
ClassDB::bind_method(D_METHOD("set_selectable", "column", "selectable"), &TreeItem::set_selectable);
ClassDB::bind_method(D_METHOD("is_selectable", "column"), &TreeItem::is_selectable);
@@ -933,7 +946,7 @@ int Tree::get_item_height(TreeItem *p_item) const {
return height;
}
-void Tree::draw_item_rect(const TreeItem::Cell &p_cell, const Rect2i &p_rect, const Color &p_color) {
+void Tree::draw_item_rect(const TreeItem::Cell &p_cell, const Rect2i &p_rect, const Color &p_color, const Color &p_icon_color) {
Rect2i rect = p_rect;
Ref<Font> font = cache.font;
@@ -972,7 +985,7 @@ void Tree::draw_item_rect(const TreeItem::Cell &p_cell, const Rect2i &p_rect, co
bmsize.width = p_cell.icon_max_w;
}
- p_cell.draw_icon(ci, rect.position + Size2i(0, Math::floor((real_t)(rect.size.y - bmsize.y) / 2)), bmsize);
+ p_cell.draw_icon(ci, rect.position + Size2i(0, Math::floor((real_t)(rect.size.y - bmsize.y) / 2)), bmsize, p_icon_color);
rect.position.x += bmsize.x + cache.hseparation;
rect.size.x -= bmsize.x + cache.hseparation;
}
@@ -1176,6 +1189,7 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
}
Color col = p_item->cells[i].custom_color ? p_item->cells[i].color : get_color(p_item->cells[i].selected ? "font_color_selected" : "font_color");
+ Color icon_col = p_item->cells[i].icon_color;
Point2i text_pos = item_rect.position;
text_pos.y += Math::floor((item_rect.size.y - font->get_height()) / 2) + font_ascent;
@@ -1184,7 +1198,7 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
case TreeItem::CELL_MODE_STRING: {
- draw_item_rect(p_item->cells[i], item_rect, col);
+ draw_item_rect(p_item->cells[i], item_rect, col, icon_col);
} break;
case TreeItem::CELL_MODE_CHECK: {
@@ -1195,9 +1209,9 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
if (p_item->cells[i].checked) {
- checked->draw(ci, check_ofs);
+ checked->draw(ci, check_ofs, icon_col);
} else {
- unchecked->draw(ci, check_ofs);
+ unchecked->draw(ci, check_ofs, icon_col);
}
int check_w = checked->get_width() + cache.hseparation;
@@ -1207,7 +1221,7 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
item_rect.size.x -= check_w;
item_rect.position.x += check_w;
- draw_item_rect(p_item->cells[i], item_rect, col);
+ draw_item_rect(p_item->cells[i], item_rect, col, icon_col);
//font->draw( ci, text_pos, p_item->cells[i].text, col,item_rect.size.x-check_w );
@@ -1237,7 +1251,7 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
arrow_pos.x += item_rect.size.x - downarrow->get_width();
arrow_pos.y += Math::floor(((item_rect.size.y - downarrow->get_height())) / 2.0);
- downarrow->draw(ci, arrow_pos);
+ downarrow->draw(ci, arrow_pos, icon_col);
} else {
Ref<Texture> updown = cache.updown;
@@ -1257,7 +1271,7 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
updown_pos.x += item_rect.size.x - updown->get_width();
updown_pos.y += Math::floor(((item_rect.size.y - updown->get_height())) / 2.0);
- updown->draw(ci, updown_pos);
+ updown->draw(ci, updown_pos, icon_col);
}
} break;
@@ -1274,7 +1288,7 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
Point2i icon_ofs = (item_rect.size - icon_size) / 2;
icon_ofs += item_rect.position;
- draw_texture_rect(p_item->cells[i].icon, Rect2(icon_ofs, icon_size));
+ draw_texture_rect(p_item->cells[i].icon, Rect2(icon_ofs, icon_size), false, icon_col);
//p_item->cells[i].icon->draw(ci, icon_ofs);
} break;
@@ -1291,7 +1305,7 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
if (!p_item->cells[i].editable) {
- draw_item_rect(p_item->cells[i], item_rect, col);
+ draw_item_rect(p_item->cells[i], item_rect, col, icon_col);
break;
}
@@ -1319,7 +1333,7 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
ir.position += cache.custom_button->get_offset();
}
- draw_item_rect(p_item->cells[i], ir, col);
+ draw_item_rect(p_item->cells[i], ir, col, icon_col);
downarrow->draw(ci, arrow_pos);
@@ -1953,6 +1967,14 @@ void Tree::text_editor_enter(String p_text) {
c.val = evaluator->eval(p_text);
else
c.val = p_text.to_double();
+
+ if (c.step > 0)
+ c.val = Math::stepify(c.val, c.step);
+ if (c.val < c.min)
+ c.val = c.min;
+ else if (c.val > c.max)
+ c.val = c.max;
+
} break;
default: { ERR_FAIL(); }
}
diff --git a/scene/gui/tree.h b/scene/gui/tree.h
index 59e35bb230..694f91f9a6 100644
--- a/scene/gui/tree.h
+++ b/scene/gui/tree.h
@@ -89,6 +89,7 @@ private:
Color bg_color;
bool custom_button;
bool expand_right;
+ Color icon_color;
TextAlign text_align;
@@ -133,10 +134,11 @@ private:
icon_max_w = 0;
text_align = ALIGN_LEFT;
expand_right = false;
+ icon_color = Color(1, 1, 1);
}
Size2 get_icon_size() const;
- void draw_icon(const RID &p_where, const Point2 &p_pos, const Size2 &p_size = Size2()) const;
+ void draw_icon(const RID &p_where, const Point2 &p_pos, const Size2 &p_size = Size2(), const Color &p_color = Color()) const;
};
Vector<Cell> cells;
@@ -193,6 +195,9 @@ public:
void set_icon_region(int p_column, const Rect2 &p_icon_region);
Rect2 get_icon_region(int p_column) const;
+ void set_icon_color(int p_column, const Color &p_icon_color);
+ Color get_icon_color(int p_column) const;
+
void set_icon_max_width(int p_column, int p_max);
int get_icon_max_width(int p_column) const;
@@ -361,7 +366,7 @@ private:
int compute_item_height(TreeItem *p_item) const;
int get_item_height(TreeItem *p_item) const;
//void draw_item_text(String p_text,const Ref<Texture>& p_icon,int p_icon_max_w,bool p_tool,Rect2i p_rect,const Color& p_color);
- void draw_item_rect(const TreeItem::Cell &p_cell, const Rect2i &p_rect, const Color &p_color);
+ void draw_item_rect(const TreeItem::Cell &p_cell, const Rect2i &p_rect, const Color &p_color, const Color &p_icon_color);
int draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2 &p_draw_size, TreeItem *p_item);
void select_single_item(TreeItem *p_selected, TreeItem *p_current, int p_col, TreeItem *p_prev = NULL, bool *r_in_range = NULL, bool p_force_deselect = false);
int propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool p_doubleclick, TreeItem *p_item, int p_button, const Ref<InputEventWithModifiers> &p_mod);
diff --git a/scene/io/resource_format_image.cpp b/scene/io/resource_format_image.cpp
index 6c0a6128d2..04b6177c3c 100644
--- a/scene/io/resource_format_image.cpp
+++ b/scene/io/resource_format_image.cpp
@@ -30,9 +30,9 @@
#include "resource_format_image.h"
#if 0
-#include "global_config.h"
#include "io/image_loader.h"
#include "os/os.h"
+#include "project_settings.h"
#include "scene/resources/texture.h"
RES ResourceFormatLoaderImage::load(const String &p_path, const String& p_original_path, Error *r_error) {
@@ -128,7 +128,7 @@ RES ResourceFormatLoaderImage::load(const String &p_path, const String& p_origin
if (max_texture_size && (image.get_width() > max_texture_size || image.get_height() > max_texture_size)) {
- if (bool(GlobalConfig::get_singleton()->get("debug/image_loader/max_texture_size_alert"))) {
+ if (bool(ProjectSettings::get_singleton()->get("debug/image_loader/max_texture_size_alert"))) {
OS::get_singleton()->alert("Texture is too large: '"+p_path+"', at "+itos(image.get_width())+"x"+itos(image.get_height())+". Max allowed size is: "+itos(max_texture_size)+"x"+itos(max_texture_size)+".","BAD ARTIST, NO COOKIE!");
}
diff --git a/scene/main/node.cpp b/scene/main/node.cpp
index 0c65c44392..c3849f79df 100755
--- a/scene/main/node.cpp
+++ b/scene/main/node.cpp
@@ -37,7 +37,6 @@
#include "viewport.h"
VARIANT_ENUM_CAST(Node::PauseMode);
-VARIANT_ENUM_CAST(Node::NetworkMode);
VARIANT_ENUM_CAST(Node::RPCMode);
void Node::_notification(int p_notification) {
@@ -77,16 +76,6 @@ void Node::_notification(int p_notification) {
data.pause_owner = this;
}
- if (data.network_mode == NETWORK_MODE_INHERIT) {
-
- if (data.parent)
- data.network_owner = data.parent->data.network_owner;
- else
- data.network_owner = NULL;
- } else {
- data.network_owner = this;
- }
-
if (data.input)
add_to_group("_vp_input" + itos(get_viewport()->get_instance_ID()));
if (data.unhandled_input)
@@ -108,7 +97,6 @@ void Node::_notification(int p_notification) {
remove_from_group("_vp_unhandled_key_input" + itos(get_viewport()->get_instance_ID()));
data.pause_owner = NULL;
- data.network_owner = NULL;
if (data.path_cache) {
memdelete(data.path_cache);
data.path_cache = NULL;
@@ -323,6 +311,11 @@ void Node::move_child(Node *p_child, int p_pos) {
ERR_FAIL_COND(data.blocked > 0);
}
+ // Specifying one place beyond the end
+ // means the same as moving to the last position
+ if (p_pos == data.children.size())
+ p_pos--;
+
if (p_child->data.pos == p_pos)
return; //do nothing
@@ -472,69 +465,28 @@ void Node::_propagate_pause_owner(Node *p_owner) {
}
}
-void Node::set_network_mode(NetworkMode p_mode) {
+void Node::set_network_master(int p_peer_id, bool p_recursive) {
- if (data.network_mode == p_mode)
- return;
+ data.network_master = p_peer_id;
- bool prev_inherits = data.network_mode == NETWORK_MODE_INHERIT;
- data.network_mode = p_mode;
- if (!is_inside_tree())
- return; //pointless
- if ((data.network_mode == NETWORK_MODE_INHERIT) == prev_inherits)
- return; ///nothing changed
-
- Node *owner = NULL;
-
- if (data.network_mode == NETWORK_MODE_INHERIT) {
+ if (p_recursive) {
+ for (int i = 0; i < data.children.size(); i++) {
- if (data.parent)
- owner = data.parent->data.network_owner;
- } else {
- owner = this;
+ data.children[i]->set_network_master(p_peer_id, true);
+ }
}
-
- _propagate_network_owner(owner);
}
-Node::NetworkMode Node::get_network_mode() const {
+int Node::get_network_master() const {
- return data.network_mode;
+ return data.network_master;
}
bool Node::is_network_master() const {
ERR_FAIL_COND_V(!is_inside_tree(), false);
- switch (data.network_mode) {
- case NETWORK_MODE_INHERIT: {
-
- if (data.network_owner)
- return data.network_owner->is_network_master();
- else
- return get_tree()->is_network_server();
- } break;
- case NETWORK_MODE_MASTER: {
-
- return true;
- } break;
- case NETWORK_MODE_SLAVE: {
- return false;
- } break;
- }
-
- return false;
-}
-
-void Node::_propagate_network_owner(Node *p_owner) {
-
- if (data.network_mode != NETWORK_MODE_INHERIT)
- return;
- data.network_owner = p_owner;
- for (int i = 0; i < data.children.size(); i++) {
-
- data.children[i]->_propagate_network_owner(p_owner);
- }
+ return get_tree()->get_network_unique_id() == data.network_master;
}
/***** RPC CONFIG ********/
@@ -962,7 +914,7 @@ void Node::rset_unreliable_id(int p_peer_id, const StringName &p_property, const
//////////// end of rpc
-bool Node::can_call_rpc(const StringName &p_method) const {
+bool Node::can_call_rpc(const StringName &p_method, int p_from) const {
const Map<StringName, RPCMode>::Element *E = data.rpc_methods.find(p_method);
if (E) {
@@ -982,7 +934,7 @@ bool Node::can_call_rpc(const StringName &p_method) const {
return is_network_master();
} break;
case RPC_MODE_SLAVE: {
- return !is_network_master();
+ return !is_network_master() && p_from == get_network_master();
} break;
}
}
@@ -1006,16 +958,16 @@ bool Node::can_call_rpc(const StringName &p_method) const {
return is_network_master();
} break;
case ScriptInstance::RPC_MODE_SLAVE: {
- return !is_network_master();
+ return !is_network_master() && p_from == get_network_master();
} break;
}
}
- ERR_PRINTS("RPC on unauthorized method attempted: " + String(p_method) + " on base: " + String(Variant(this)));
+ ERR_PRINTS("RPC from " + itos(p_from) + " on unauthorized method attempted: " + String(p_method) + " on base: " + String(Variant(this)));
return false;
}
-bool Node::can_call_rset(const StringName &p_property) const {
+bool Node::can_call_rset(const StringName &p_property, int p_from) const {
const Map<StringName, RPCMode>::Element *E = data.rpc_properties.find(p_property);
if (E) {
@@ -1035,7 +987,7 @@ bool Node::can_call_rset(const StringName &p_property) const {
return is_network_master();
} break;
case RPC_MODE_SLAVE: {
- return !is_network_master();
+ return !is_network_master() && p_from == get_network_master();
} break;
}
}
@@ -1059,12 +1011,12 @@ bool Node::can_call_rset(const StringName &p_property) const {
return is_network_master();
} break;
case ScriptInstance::RPC_MODE_SLAVE: {
- return !is_network_master();
+ return !is_network_master() && p_from == get_network_master();
} break;
}
}
- ERR_PRINTS("RSET on unauthorized property attempted: " + String(p_property) + " on base: " + String(Variant(this)));
+ ERR_PRINTS("RSET from " + itos(p_from) + " on unauthorized property attempted: " + String(p_property) + " on base: " + String(Variant(this)));
return false;
}
@@ -1311,7 +1263,7 @@ String Node::_generate_serial_child_name(Node *p_child) {
name = p_child->get_class();
// Adjust casing according to project setting. The current type name is expected to be in PascalCase.
- switch (GlobalConfig::get_singleton()->get("node/name_casing").operator int()) {
+ switch (ProjectSettings::get_singleton()->get("node/name_casing").operator int()) {
case NAME_CASING_PASCAL_CASE:
break;
case NAME_CASING_CAMEL_CASE:
@@ -2765,9 +2717,9 @@ void Node::request_ready() {
void Node::_bind_methods() {
GLOBAL_DEF("node/name_num_separator", 0);
- GlobalConfig::get_singleton()->set_custom_property_info("node/name_num_separator", PropertyInfo(Variant::INT, "node/name_num_separator", PROPERTY_HINT_ENUM, "None,Space,Underscore,Dash"));
+ ProjectSettings::get_singleton()->set_custom_property_info("node/name_num_separator", PropertyInfo(Variant::INT, "node/name_num_separator", PROPERTY_HINT_ENUM, "None,Space,Underscore,Dash"));
GLOBAL_DEF("node/name_casing", NAME_CASING_PASCAL_CASE);
- GlobalConfig::get_singleton()->set_custom_property_info("node/name_casing", PropertyInfo(Variant::INT, "node/name_casing", PROPERTY_HINT_ENUM, "PascalCase,camelCase,snake_case"));
+ ProjectSettings::get_singleton()->set_custom_property_info("node/name_casing", PropertyInfo(Variant::INT, "node/name_casing", PROPERTY_HINT_ENUM, "PascalCase,camelCase,snake_case"));
ClassDB::bind_method(D_METHOD("_add_child_below_node", "node:Node", "child_node:Node", "legible_unique_name"), &Node::add_child_below_node, DEFVAL(false));
@@ -2839,14 +2791,14 @@ void Node::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_scene_instance_load_placeholder", "load_placeholder"), &Node::set_scene_instance_load_placeholder);
ClassDB::bind_method(D_METHOD("get_scene_instance_load_placeholder"), &Node::get_scene_instance_load_placeholder);
- ClassDB::bind_method(D_METHOD("get_viewport"), &Node::get_viewport);
+ ClassDB::bind_method(D_METHOD("get_viewport:Viewport"), &Node::get_viewport);
ClassDB::bind_method(D_METHOD("queue_free"), &Node::queue_delete);
ClassDB::bind_method(D_METHOD("request_ready"), &Node::request_ready);
- ClassDB::bind_method(D_METHOD("set_network_mode", "mode"), &Node::set_network_mode);
- ClassDB::bind_method(D_METHOD("get_network_mode"), &Node::get_network_mode);
+ ClassDB::bind_method(D_METHOD("set_network_master", "id", "recursive"), &Node::set_network_master, DEFVAL(true));
+ ClassDB::bind_method(D_METHOD("get_network_master"), &Node::get_network_master);
ClassDB::bind_method(D_METHOD("is_network_master"), &Node::is_network_master);
@@ -2902,10 +2854,6 @@ void Node::_bind_methods() {
BIND_CONSTANT(NOTIFICATION_INTERNAL_PROCESS);
BIND_CONSTANT(NOTIFICATION_INTERNAL_FIXED_PROCESS);
- BIND_CONSTANT(NETWORK_MODE_INHERIT);
- BIND_CONSTANT(NETWORK_MODE_MASTER);
- BIND_CONSTANT(NETWORK_MODE_SLAVE);
-
BIND_CONSTANT(RPC_MODE_DISABLED);
BIND_CONSTANT(RPC_MODE_REMOTE);
BIND_CONSTANT(RPC_MODE_SYNC);
@@ -2947,7 +2895,7 @@ void Node::_bind_methods() {
}
String Node::_get_name_num_separator() {
- switch (GlobalConfig::get_singleton()->get("node/name_num_separator").operator int()) {
+ switch (ProjectSettings::get_singleton()->get("node/name_num_separator").operator int()) {
case 0: return "";
case 1: return " ";
case 2: return "_";
@@ -2977,8 +2925,7 @@ Node::Node() {
data.unhandled_key_input = false;
data.pause_mode = PAUSE_MODE_INHERIT;
data.pause_owner = NULL;
- data.network_mode = NETWORK_MODE_INHERIT;
- data.network_owner = NULL;
+ data.network_master = 1; //server by default
data.path_cache = NULL;
data.parent_owned = false;
data.in_constructor = true;
diff --git a/scene/main/node.h b/scene/main/node.h
index ffd2b7ce5f..1794cce9f6 100644
--- a/scene/main/node.h
+++ b/scene/main/node.h
@@ -31,10 +31,10 @@
#define NODE_H
#include "class_db.h"
-#include "global_config.h"
#include "map.h"
#include "object.h"
#include "path_db.h"
+#include "project_settings.h"
#include "scene/main/scene_tree.h"
#include "script_language.h"
@@ -61,13 +61,6 @@ public:
DUPLICATE_USE_INSTANCING = 8
};
- enum NetworkMode {
-
- NETWORK_MODE_INHERIT,
- NETWORK_MODE_MASTER,
- NETWORK_MODE_SLAVE
- };
-
enum RPCMode {
RPC_MODE_DISABLED, //no rpc for this method, calls to this will be blocked (default)
@@ -122,8 +115,7 @@ private:
PauseMode pause_mode;
Node *pause_owner;
- NetworkMode network_mode;
- Node *network_owner;
+ int network_master;
Map<StringName, RPCMode> rpc_methods;
Map<StringName, RPCMode> rpc_properties;
@@ -173,7 +165,6 @@ private:
void _propagate_validate_owner();
void _print_stray_nodes();
void _propagate_pause_owner(Node *p_owner);
- void _propagate_network_owner(Node *p_owner);
Array _get_node_and_resource(const NodePath &p_path);
void _duplicate_signals(const Node *p_original, Node *p_copy) const;
@@ -393,8 +384,8 @@ public:
bool is_displayed_folded() const;
/* NETWORK */
- void set_network_mode(NetworkMode p_mode);
- NetworkMode get_network_mode() const;
+ void set_network_master(int p_peer_id, bool p_recursive = true);
+ int get_network_master() const;
bool is_network_master() const;
void rpc_config(const StringName &p_method, RPCMode p_mode); // config a local method for RPC
@@ -414,8 +405,8 @@ public:
void rsetp(int p_peer_id, bool p_unreliable, const StringName &p_property, const Variant &p_value);
- bool can_call_rpc(const StringName &p_method) const;
- bool can_call_rset(const StringName &p_property) const;
+ bool can_call_rpc(const StringName &p_method, int p_from) const;
+ bool can_call_rset(const StringName &p_property, int p_from) const;
Node();
~Node();
diff --git a/scene/main/resource_preloader.cpp b/scene/main/resource_preloader.cpp
index ae323ba021..febb95a181 100644
--- a/scene/main/resource_preloader.cpp
+++ b/scene/main/resource_preloader.cpp
@@ -153,11 +153,11 @@ void ResourcePreloader::_bind_methods() {
ClassDB::bind_method(D_METHOD("_set_resources"), &ResourcePreloader::_set_resources);
ClassDB::bind_method(D_METHOD("_get_resources"), &ResourcePreloader::_get_resources);
- ClassDB::bind_method(D_METHOD("add_resource", "name", "resource"), &ResourcePreloader::add_resource);
+ ClassDB::bind_method(D_METHOD("add_resource", "name", "resource:Resource"), &ResourcePreloader::add_resource);
ClassDB::bind_method(D_METHOD("remove_resource", "name"), &ResourcePreloader::remove_resource);
ClassDB::bind_method(D_METHOD("rename_resource", "name", "newname"), &ResourcePreloader::rename_resource);
ClassDB::bind_method(D_METHOD("has_resource", "name"), &ResourcePreloader::has_resource);
- ClassDB::bind_method(D_METHOD("get_resource", "name"), &ResourcePreloader::get_resource);
+ ClassDB::bind_method(D_METHOD("get_resource:Resource", "name"), &ResourcePreloader::get_resource);
ClassDB::bind_method(D_METHOD("get_resource_list"), &ResourcePreloader::_get_resource_list);
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "resources", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "_set_resources", "_get_resources");
diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp
index 479abccda6..48e6a44745 100644
--- a/scene/main/scene_tree.cpp
+++ b/scene/main/scene_tree.cpp
@@ -29,12 +29,12 @@
/*************************************************************************/
#include "scene_tree.h"
-#include "global_config.h"
#include "message_queue.h"
#include "node.h"
#include "os/keyboard.h"
#include "os/os.h"
#include "print_string.h"
+#include "project_settings.h"
#include <stdio.h>
//#include "servers/spatial_sound_2d_server.h"
@@ -614,7 +614,7 @@ bool SceneTree::idle(float p_time) {
if (is_editor_hint()) {
//simple hack to reload fallback environment if it changed from editor
- String env_path = GlobalConfig::get_singleton()->get("rendering/viewport/default_environment");
+ String env_path = ProjectSettings::get_singleton()->get("rendering/environment/default_environment");
env_path = env_path.strip_edges(); //user may have added a space or two
String cpath;
Ref<Environment> fallback = get_root()->get_world()->get_fallback_environment();
@@ -1153,7 +1153,7 @@ void SceneTree::_update_root_rect() {
if (stretch_mode == STRETCH_MODE_DISABLED) {
- root->set_size(last_screen_size);
+ root->set_size((last_screen_size / stretch_shrink).floor());
root->set_attach_to_screen_rect(Rect2(Point2(), last_screen_size));
root->set_size_override_stretch(false);
root->set_size_override(false, Size2());
@@ -1231,15 +1231,15 @@ void SceneTree::_update_root_rect() {
switch (stretch_mode) {
case STRETCH_MODE_2D: {
- root->set_size(screen_size);
+ root->set_size((screen_size / stretch_shrink).floor());
root->set_attach_to_screen_rect(Rect2(margin, screen_size));
root->set_size_override_stretch(true);
- root->set_size_override(true, viewport_size);
+ root->set_size_override(true, (viewport_size / stretch_shrink).floor());
} break;
case STRETCH_MODE_VIEWPORT: {
- root->set_size(viewport_size);
+ root->set_size((viewport_size / stretch_shrink).floor());
root->set_attach_to_screen_rect(Rect2(margin, screen_size));
root->set_size_override_stretch(false);
root->set_size_override(false, Size2());
@@ -1248,11 +1248,12 @@ void SceneTree::_update_root_rect() {
}
}
-void SceneTree::set_screen_stretch(StretchMode p_mode, StretchAspect p_aspect, const Size2 p_minsize) {
+void SceneTree::set_screen_stretch(StretchMode p_mode, StretchAspect p_aspect, const Size2 p_minsize, int p_shrink) {
stretch_mode = p_mode;
stretch_aspect = p_aspect;
stretch_min = p_minsize;
+ stretch_shrink = p_shrink;
_update_root_rect();
}
@@ -1763,6 +1764,16 @@ int SceneTree::get_network_unique_id() const {
return network_peer->get_unique_id();
}
+Vector<int> SceneTree::get_network_connected_peers() const {
+ ERR_FAIL_COND_V(!network_peer.is_valid(), Vector<int>());
+
+ Vector<int> ret;
+ for (Set<int>::Element *E = connected_peers.front(); E; E = E->next()) {
+ ret.push_back(E->get());
+ }
+
+ return ret;
+}
void SceneTree::set_refuse_new_network_connections(bool p_refuse) {
ERR_FAIL_COND(!network_peer.is_valid());
network_peer->set_refuse_new_connections(p_refuse);
@@ -1973,6 +1984,7 @@ void SceneTree::_network_process_packet(int p_from, const uint8_t *p_packet, int
Node *node = NULL;
if (target & 0x80000000) {
+ //use full path (not cached yet)
int ofs = target & 0x7FFFFFFF;
ERR_FAIL_COND(ofs >= p_packet_len);
@@ -1988,7 +2000,7 @@ void SceneTree::_network_process_packet(int p_from, const uint8_t *p_packet, int
ERR_FAIL_COND(node == NULL);
}
} else {
-
+ //use cached path
int id = target;
Map<int, PathGetCache>::Element *E = path_get_cache.find(p_from);
@@ -2023,7 +2035,7 @@ void SceneTree::_network_process_packet(int p_from, const uint8_t *p_packet, int
if (packet_type == NETWORK_COMMAND_REMOTE_CALL) {
- if (!node->can_call_rpc(name))
+ if (!node->can_call_rpc(name, p_from))
return;
int ofs = len_end + 1;
@@ -2060,7 +2072,7 @@ void SceneTree::_network_process_packet(int p_from, const uint8_t *p_packet, int
} else {
- if (!node->can_call_rset(name))
+ if (!node->can_call_rset(name, p_from))
return;
int ofs = len_end + 1;
@@ -2181,8 +2193,8 @@ void SceneTree::_bind_methods() {
ClassDB::bind_method(D_METHOD("is_debugging_navigation_hint"), &SceneTree::is_debugging_navigation_hint);
#ifdef TOOLS_ENABLED
- ClassDB::bind_method(D_METHOD("set_edited_scene_root", "scene"), &SceneTree::set_edited_scene_root);
- ClassDB::bind_method(D_METHOD("get_edited_scene_root"), &SceneTree::get_edited_scene_root);
+ ClassDB::bind_method(D_METHOD("set_edited_scene_root", "scene:Node"), &SceneTree::set_edited_scene_root);
+ ClassDB::bind_method(D_METHOD("get_edited_scene_root:Node"), &SceneTree::get_edited_scene_root);
#endif
ClassDB::bind_method(D_METHOD("set_pause", "enable"), &SceneTree::set_pause);
@@ -2196,7 +2208,7 @@ void SceneTree::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_frame"), &SceneTree::get_frame);
ClassDB::bind_method(D_METHOD("quit"), &SceneTree::quit);
- ClassDB::bind_method(D_METHOD("set_screen_stretch", "mode", "aspect", "minsize"), &SceneTree::set_screen_stretch);
+ ClassDB::bind_method(D_METHOD("set_screen_stretch", "mode", "aspect", "minsize", "shrink"), &SceneTree::set_screen_stretch, DEFVAL(1));
ClassDB::bind_method(D_METHOD("queue_delete", "obj"), &SceneTree::queue_delete);
@@ -2236,6 +2248,7 @@ void SceneTree::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_network_peer", "peer:NetworkedMultiplayerPeer"), &SceneTree::set_network_peer);
ClassDB::bind_method(D_METHOD("is_network_server"), &SceneTree::is_network_server);
ClassDB::bind_method(D_METHOD("has_network_peer"), &SceneTree::has_network_peer);
+ ClassDB::bind_method(D_METHOD("get_network_connected_peers"), &SceneTree::get_network_connected_peers);
ClassDB::bind_method(D_METHOD("get_network_unique_id"), &SceneTree::get_network_unique_id);
ClassDB::bind_method(D_METHOD("set_refuse_new_network_connections", "refuse"), &SceneTree::set_refuse_new_network_connections);
ClassDB::bind_method(D_METHOD("is_refusing_new_network_connections"), &SceneTree::is_refusing_new_network_connections);
@@ -2305,11 +2318,11 @@ SceneTree::SceneTree() {
debug_collisions_hint = false;
debug_navigation_hint = false;
#endif
- debug_collisions_color = GLOBAL_DEF("debug/collision/shape_color", Color(0.0, 0.6, 0.7, 0.5));
- debug_collision_contact_color = GLOBAL_DEF("debug/collision/contact_color", Color(1.0, 0.2, 0.1, 0.8));
- debug_navigation_color = GLOBAL_DEF("debug/navigation/geometry_color", Color(0.1, 1.0, 0.7, 0.4));
- debug_navigation_disabled_color = GLOBAL_DEF("debug/navigation/disabled_geometry_color", Color(1.0, 0.7, 0.1, 0.4));
- collision_debug_contacts = GLOBAL_DEF("debug/collision/max_contacts_displayed", 10000);
+ debug_collisions_color = GLOBAL_DEF("debug/shapes/collision/shape_color", Color(0.0, 0.6, 0.7, 0.5));
+ debug_collision_contact_color = GLOBAL_DEF("debug/shapes/collision/contact_color", Color(1.0, 0.2, 0.1, 0.8));
+ debug_navigation_color = GLOBAL_DEF("debug/shapes/navigation/geometry_color", Color(0.1, 1.0, 0.7, 0.4));
+ debug_navigation_disabled_color = GLOBAL_DEF("debug/shapes/navigation/disabled_geometry_color", Color(1.0, 0.7, 0.1, 0.4));
+ collision_debug_contacts = GLOBAL_DEF("debug/shapes/collision/max_contacts_displayed", 10000);
tree_version = 1;
fixed_process_time = 1;
@@ -2336,12 +2349,16 @@ SceneTree::SceneTree() {
root->set_as_audio_listener_2d(true);
current_scene = NULL;
- int ref_atlas_size = GLOBAL_DEF("rendering/reflections/atlas_size", 2048);
- int ref_atlas_subdiv = GLOBAL_DEF("rendering/reflections/atlas_subdiv", 8);
- int msaa_mode = GLOBAL_DEF("rendering/quality/msaa", 0);
- GlobalConfig::get_singleton()->set_custom_property_info("rendering/quality/msaa", PropertyInfo(Variant::INT, "rendering/quality/msaa", PROPERTY_HINT_ENUM, "Disabled,2x,4x,8x,16x"));
+ int ref_atlas_size = GLOBAL_DEF("rendering/quality/reflections/atlas_size", 2048);
+ int ref_atlas_subdiv = GLOBAL_DEF("rendering/quality/reflections/atlas_subdiv", 8);
+ int msaa_mode = GLOBAL_DEF("rendering/quality/filters/msaa", 0);
+ ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/filters/msaa", PropertyInfo(Variant::INT, "rendering/quality/filters/msaa", PROPERTY_HINT_ENUM, "Disabled,2x,4x,8x,16x"));
root->set_msaa(Viewport::MSAA(msaa_mode));
- bool hdr = GLOBAL_DEF("rendering/quality/hdr", true);
+
+ GLOBAL_DEF("rendering/quality/depth/hdr", true);
+ GLOBAL_DEF("rendering/quality/depth/hdr.mobile", false);
+
+ bool hdr = GLOBAL_GET("rendering/quality/depth/hdr");
root->set_hdr(hdr);
VS::get_singleton()->scenario_set_reflection_atlas_size(root->get_world()->get_scenario(), ref_atlas_size, ref_atlas_subdiv);
@@ -2357,9 +2374,9 @@ SceneTree::SceneTree() {
ext_hint += "*." + E->get();
}
//get path
- String env_path = GLOBAL_DEF("rendering/viewport/default_environment", "");
+ String env_path = GLOBAL_DEF("rendering/environment/default_environment", "");
//setup property
- GlobalConfig::get_singleton()->set_custom_property_info("rendering/viewport/default_environment", PropertyInfo(Variant::STRING, "rendering/viewport/default_environment", PROPERTY_HINT_FILE, ext_hint));
+ ProjectSettings::get_singleton()->set_custom_property_info("rendering/environment/default_environment", PropertyInfo(Variant::STRING, "rendering/viewport/default_environment", PROPERTY_HINT_FILE, ext_hint));
env_path = env_path.strip_edges();
if (env_path != String()) {
Ref<Environment> env = ResourceLoader::load(env_path);
@@ -2368,7 +2385,7 @@ SceneTree::SceneTree() {
} else {
if (is_editor_hint()) {
//file was erased, clear the field.
- GlobalConfig::get_singleton()->set("rendering/viewport/default_environment", "");
+ ProjectSettings::get_singleton()->set("rendering/environment/default_environment", "");
} else {
//file was erased, notify user.
ERR_PRINTS(RTR("Default Environment as specified in Project Setings (Rendering -> Viewport -> Default Environment) could not be loaded."));
@@ -2379,6 +2396,7 @@ SceneTree::SceneTree() {
stretch_mode = STRETCH_MODE_DISABLED;
stretch_aspect = STRETCH_ASPECT_IGNORE;
+ stretch_shrink = 1;
last_screen_size = Size2(OS::get_singleton()->get_video_mode().width, OS::get_singleton()->get_video_mode().height);
_update_root_rect();
diff --git a/scene/main/scene_tree.h b/scene/main/scene_tree.h
index 2ea79bf945..90d42ef01b 100644
--- a/scene/main/scene_tree.h
+++ b/scene/main/scene_tree.h
@@ -149,6 +149,7 @@ private:
StretchMode stretch_mode;
StretchAspect stretch_aspect;
Size2i stretch_min;
+ int stretch_shrink;
void _update_root_rect();
@@ -420,7 +421,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);
+ void set_screen_stretch(StretchMode p_mode, StretchAspect p_aspect, const Size2 p_minsize, int p_shrink = 1);
//void change_scene(const String& p_path);
//Node *get_loaded_scene();
@@ -451,6 +452,7 @@ public:
bool is_network_server() const;
bool has_network_peer() const;
int get_network_unique_id() const;
+ Vector<int> get_network_connected_peers() const;
void set_refuse_new_network_connections(bool p_refuse);
bool is_refusing_new_network_connections() const;
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index 3a9968d126..76b281ebac 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -48,7 +48,7 @@
#include "scene/main/timer.h"
#include "scene/scene_string_names.h"
-#include "global_config.h"
+#include "project_settings.h"
#include "scene/3d/scenario_fx.h"
void ViewportTexture::setup_local_to_scene() {
@@ -701,6 +701,16 @@ RID Viewport::get_viewport_rid() const {
return viewport;
}
+void Viewport::set_use_arvr(bool p_use_arvr) {
+ arvr = p_use_arvr;
+
+ VS::get_singleton()->viewport_set_use_arvr(viewport, arvr);
+}
+
+bool Viewport::use_arvr() {
+ return arvr;
+}
+
void Viewport::set_size(const Size2 &p_size) {
if (size == p_size.floor())
@@ -2057,6 +2067,10 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
//keyboard focus
//if (from && p_event->is_pressed() && !p_event->get_alt() && !p_event->get_metakey() && !p_event->key->get_command()) {
+ Ref<InputEventKey> k = p_event;
+ //need to check for mods, otherwise any combination of alt/ctrl/shift+<up/down/left/righ/etc> is handled here when it shouldn't be.
+ bool mods = k.is_valid() && (k->get_control() || k->get_alt() || k->get_shift() || k->get_metakey());
+
if (from && p_event->is_pressed()) {
Control *next = NULL;
@@ -2070,22 +2084,22 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
next = from->find_prev_valid_focus();
}
- if (p_event->is_action("ui_up")) {
+ if (!mods && p_event->is_action("ui_up")) {
next = from->_get_focus_neighbour(MARGIN_TOP);
}
- if (p_event->is_action("ui_left")) {
+ if (!mods && p_event->is_action("ui_left")) {
next = from->_get_focus_neighbour(MARGIN_LEFT);
}
- if (p_event->is_action("ui_right")) {
+ if (!mods && p_event->is_action("ui_right")) {
next = from->_get_focus_neighbour(MARGIN_RIGHT);
}
- if (p_event->is_action("ui_down")) {
+ if (!mods && p_event->is_action("ui_down")) {
next = from->_get_focus_neighbour(MARGIN_BOTTOM);
}
@@ -2352,7 +2366,7 @@ void Viewport::unhandled_input(const Ref<InputEvent> &p_event) {
if (physics_object_picking && !get_tree()->input_handled) {
- if (p_event->cast_to<InputEventMouseButton>() || p_event->cast_to<InputEventMouseMotion>() || p_event->cast_to<InputEventScreenDrag>() || p_event->cast_to<InputEventScreenTouch>()) {
+ if (Input::get_singleton()->get_mouse_mode() != Input::MOUSE_MODE_CAPTURED && (p_event->cast_to<InputEventMouseButton>() || p_event->cast_to<InputEventMouseMotion>() || p_event->cast_to<InputEventScreenDrag>() || p_event->cast_to<InputEventScreenTouch>())) {
physics_picking_events.push_back(p_event);
}
}
@@ -2539,6 +2553,9 @@ int Viewport::get_render_info(RenderInfo p_info) {
void Viewport::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("set_use_arvr", "use"), &Viewport::set_use_arvr);
+ ClassDB::bind_method(D_METHOD("use_arvr"), &Viewport::use_arvr);
+
ClassDB::bind_method(D_METHOD("set_size", "size"), &Viewport::set_size);
ClassDB::bind_method(D_METHOD("get_size"), &Viewport::get_size);
ClassDB::bind_method(D_METHOD("set_world_2d", "world_2d:World2D"), &Viewport::set_world_2d);
@@ -2602,8 +2619,8 @@ void Viewport::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_physics_object_picking"), &Viewport::get_physics_object_picking);
ClassDB::bind_method(D_METHOD("get_viewport_rid"), &Viewport::get_viewport_rid);
- ClassDB::bind_method(D_METHOD("input", "local_event"), &Viewport::input);
- ClassDB::bind_method(D_METHOD("unhandled_input", "local_event"), &Viewport::unhandled_input);
+ ClassDB::bind_method(D_METHOD("input", "local_event:InputEvent"), &Viewport::input);
+ ClassDB::bind_method(D_METHOD("unhandled_input", "local_event:InputEvent"), &Viewport::unhandled_input);
ClassDB::bind_method(D_METHOD("update_worlds"), &Viewport::update_worlds);
@@ -2640,6 +2657,8 @@ void Viewport::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_shadow_atlas_quadrant_subdiv", "quadrant", "subdiv"), &Viewport::set_shadow_atlas_quadrant_subdiv);
ClassDB::bind_method(D_METHOD("get_shadow_atlas_quadrant_subdiv", "quadrant"), &Viewport::get_shadow_atlas_quadrant_subdiv);
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "arvr"), "set_use_arvr", "use_arvr");
+
ADD_PROPERTY(PropertyInfo(Variant::RECT2, "size"), "set_size", "get_size");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "own_world"), "set_use_own_world", "is_using_own_world");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "world", PROPERTY_HINT_RESOURCE_TYPE, "World"), "set_world", "get_world");
@@ -2725,6 +2744,7 @@ Viewport::Viewport() {
parent = NULL;
listener = NULL;
camera = NULL;
+ arvr = false;
size_override = false;
size_override_stretch = false;
size_override_size = Size2(1, 1);
diff --git a/scene/main/viewport.h b/scene/main/viewport.h
index bd9747d878..83c989db54 100644
--- a/scene/main/viewport.h
+++ b/scene/main/viewport.h
@@ -148,6 +148,8 @@ private:
Listener *listener;
Set<Listener *> listeners;
+ bool arvr;
+
Camera *camera;
Set<Camera *> cameras;
@@ -349,6 +351,9 @@ public:
Listener *get_listener() const;
Camera *get_camera() const;
+ void set_use_arvr(bool p_use_arvr);
+ bool use_arvr();
+
void set_as_audio_listener(bool p_enable);
bool is_audio_listener() const;
diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp
index 76e07db93d..f286bfb81a 100644
--- a/scene/register_scene_types.cpp
+++ b/scene/register_scene_types.cpp
@@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "register_scene_types.h"
-#include "global_config.h"
#include "os/os.h"
+#include "project_settings.h"
#include "scene/io/resource_format_image.h"
#include "scene/io/resource_format_wav.h"
@@ -164,7 +164,7 @@
#include "scene/resources/polygon_path_finder.h"
//#include "scene/resources/sample.h"
-//#include "scene/audio/sample_player.h"
+#include "scene/3d/audio_stream_player_3d.h"
#include "scene/resources/material.h"
#include "scene/resources/mesh.h"
#include "scene/resources/room.h"
@@ -199,6 +199,8 @@
#include "scene/3d/camera.h"
#include "scene/3d/listener.h"
+#include "scene/3d/arvr_nodes.h"
+
#include "scene/3d/gi_probe.h"
#include "scene/3d/interpolated_camera.h"
#include "scene/3d/light.h"
@@ -212,7 +214,7 @@
#include "scene/3d/area.h"
-#include "scene/3d/body_shape.h"
+#include "scene/3d/collision_shape.h"
#include "scene/3d/immediate_geometry.h"
#include "scene/3d/multimesh_instance.h"
#include "scene/3d/physics_joint.h"
@@ -271,11 +273,11 @@ void register_scene_types() {
ResourceLoader::add_resource_format_loader(resource_loader_theme);
bool default_theme_hidpi = GLOBAL_DEF("gui/theme/use_hidpi", false);
- GlobalConfig::get_singleton()->set_custom_property_info("gui/theme/use_hidpi", PropertyInfo(Variant::BOOL, "gui/theme/use_hidpi", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED));
+ ProjectSettings::get_singleton()->set_custom_property_info("gui/theme/use_hidpi", PropertyInfo(Variant::BOOL, "gui/theme/use_hidpi", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED));
String theme_path = GLOBAL_DEF("gui/theme/custom", "");
- GlobalConfig::get_singleton()->set_custom_property_info("gui/theme/custom", PropertyInfo(Variant::STRING, "gui/theme/custom", PROPERTY_HINT_FILE, "*.tres,*.res", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED));
+ ProjectSettings::get_singleton()->set_custom_property_info("gui/theme/custom", PropertyInfo(Variant::STRING, "gui/theme/custom", PROPERTY_HINT_FILE, "*.tres,*.res", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED));
String font_path = GLOBAL_DEF("gui/theme/custom_font", "");
- GlobalConfig::get_singleton()->set_custom_property_info("gui/theme/custom_font", PropertyInfo(Variant::STRING, "gui/theme/custom_font", PROPERTY_HINT_FILE, "*.tres,*.res,*.font", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED));
+ ProjectSettings::get_singleton()->set_custom_property_info("gui/theme/custom_font", PropertyInfo(Variant::STRING, "gui/theme/custom_font", PROPERTY_HINT_FILE, "*.tres,*.res,*.font", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED));
if (theme_path != String()) {
Ref<Theme> theme = ResourceLoader::load(theme_path);
@@ -405,6 +407,9 @@ void register_scene_types() {
ClassDB::register_virtual_class<VisualInstance>();
ClassDB::register_class<Camera>();
ClassDB::register_class<Listener>();
+ ClassDB::register_class<ARVRCamera>();
+ ClassDB::register_class<ARVRController>();
+ ClassDB::register_class<ARVROrigin>();
ClassDB::register_class<InterpolatedCamera>();
ClassDB::register_class<MeshInstance>();
ClassDB::register_class<ImmediateGeometry>();
@@ -532,8 +537,6 @@ void register_scene_types() {
ClassDB::register_class<SphereMesh>();
ClassDB::register_virtual_class<Material>();
ClassDB::register_class<SpatialMaterial>();
- ClassDB::add_compatibility_class("FixedSpatialMaterial", "SpatialMaterial");
- ClassDB::add_compatibility_class("Mesh", "ArrayMesh");
SceneTree::add_idle_callback(SpatialMaterial::flush_changes);
SpatialMaterial::init_shaders();
@@ -562,6 +565,7 @@ void register_scene_types() {
OS::get_singleton()->yield(); //may take time to init
+ ClassDB::register_class<SpatialVelocityTracker>();
#endif
ClassDB::register_class<World>();
ClassDB::register_class<Environment>();
@@ -598,6 +602,7 @@ void register_scene_types() {
ClassDB::register_class<AudioStreamPlayer>();
ClassDB::register_class<AudioStreamPlayer2D>();
+ ClassDB::register_class<AudioStreamPlayer3D>();
ClassDB::register_virtual_class<VideoStream>();
ClassDB::register_class<AudioStreamSample>();
@@ -628,6 +633,13 @@ void register_scene_types() {
ClassDB::register_class<SceneTree>();
ClassDB::register_virtual_class<SceneTreeTimer>(); //sorry, you can't create it
+#ifndef DISABLE_DEPRECATED
+ ClassDB::add_compatibility_class("ImageSkyBox", "PanoramaSky");
+ ClassDB::add_compatibility_class("FixedSpatialMaterial", "SpatialMaterial");
+ ClassDB::add_compatibility_class("Mesh", "ArrayMesh");
+
+#endif
+
OS::get_singleton()->yield(); //may take time to init
resource_saver_text = memnew(ResourceFormatSaverText);
diff --git a/scene/resources/audio_stream_resampled.cpp b/scene/resources/audio_stream_resampled.cpp
index 213ac4400b..1b1d6f8587 100644
--- a/scene/resources/audio_stream_resampled.cpp
+++ b/scene/resources/audio_stream_resampled.cpp
@@ -28,7 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "audio_stream_resampled.h"
-#include "global_config.h"
+#include "project_settings.h"
#if 0
int AudioStreamResampled::get_channel_count() const {
diff --git a/scene/resources/audio_stream_sample.cpp b/scene/resources/audio_stream_sample.cpp
index f12e231074..c8f6007e60 100644
--- a/scene/resources/audio_stream_sample.cpp
+++ b/scene/resources/audio_stream_sample.cpp
@@ -231,7 +231,7 @@ void AudioStreamPlaybackSample::mix(AudioFrame *p_buffer, float p_rate_scale, in
/* some 64-bit fixed point precaches */
- int64_t loop_begin_fp = ((int64_t)len << MIX_FRAC_BITS);
+ int64_t loop_begin_fp = ((int64_t)base->loop_begin << MIX_FRAC_BITS);
int64_t loop_end_fp = ((int64_t)base->loop_end << MIX_FRAC_BITS);
int64_t length_fp = ((int64_t)len << MIX_FRAC_BITS);
int64_t begin_limit = (base->loop_mode != AudioStreamSample::LOOP_DISABLED) ? loop_begin_fp : 0;
diff --git a/scene/resources/bit_mask.cpp b/scene/resources/bit_mask.cpp
index a473067937..73a759278b 100644
--- a/scene/resources/bit_mask.cpp
+++ b/scene/resources/bit_mask.cpp
@@ -170,7 +170,7 @@ Dictionary BitMap::_get_data() const {
void BitMap::_bind_methods() {
ClassDB::bind_method(D_METHOD("create", "size"), &BitMap::create);
- ClassDB::bind_method(D_METHOD("create_from_image_alpha", "image"), &BitMap::create_from_image_alpha);
+ ClassDB::bind_method(D_METHOD("create_from_image_alpha", "image:Image"), &BitMap::create_from_image_alpha);
ClassDB::bind_method(D_METHOD("set_bit", "pos", "bit"), &BitMap::set_bit);
ClassDB::bind_method(D_METHOD("get_bit", "pos"), &BitMap::get_bit);
diff --git a/scene/resources/curve.cpp b/scene/resources/curve.cpp
index 338311b87b..fe0759fcba 100644
--- a/scene/resources/curve.cpp
+++ b/scene/resources/curve.cpp
@@ -1188,7 +1188,7 @@ void Curve2D::_set_data(const Dictionary &p_data) {
baked_cache_dirty = true;
}
-PoolVector2Array Curve2D::tesselate(int p_max_stages, float p_tolerance) const {
+PoolVector2Array Curve2D::tessellate(int p_max_stages, float p_tolerance) const {
PoolVector2Array tess;
@@ -1250,7 +1250,7 @@ void Curve2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_baked_length"), &Curve2D::get_baked_length);
ClassDB::bind_method(D_METHOD("interpolate_baked", "offset", "cubic"), &Curve2D::interpolate_baked, DEFVAL(false));
ClassDB::bind_method(D_METHOD("get_baked_points"), &Curve2D::get_baked_points);
- ClassDB::bind_method(D_METHOD("tesselate", "max_stages", "tolerance_degrees"), &Curve2D::tesselate, DEFVAL(5), DEFVAL(4));
+ ClassDB::bind_method(D_METHOD("tessellate", "max_stages", "tolerance_degrees"), &Curve2D::tessellate, DEFVAL(5), DEFVAL(4));
ClassDB::bind_method(D_METHOD("_get_data"), &Curve2D::_get_data);
ClassDB::bind_method(D_METHOD("_set_data"), &Curve2D::_set_data);
@@ -1683,7 +1683,7 @@ void Curve3D::_set_data(const Dictionary &p_data) {
baked_cache_dirty = true;
}
-PoolVector3Array Curve3D::tesselate(int p_max_stages, float p_tolerance) const {
+PoolVector3Array Curve3D::tessellate(int p_max_stages, float p_tolerance) const {
PoolVector3Array tess;
@@ -1748,7 +1748,7 @@ void Curve3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("interpolate_baked", "offset", "cubic"), &Curve3D::interpolate_baked, DEFVAL(false));
ClassDB::bind_method(D_METHOD("get_baked_points"), &Curve3D::get_baked_points);
ClassDB::bind_method(D_METHOD("get_baked_tilts"), &Curve3D::get_baked_tilts);
- ClassDB::bind_method(D_METHOD("tesselate", "max_stages", "tolerance_degrees"), &Curve3D::tesselate, DEFVAL(5), DEFVAL(4));
+ ClassDB::bind_method(D_METHOD("tessellate", "max_stages", "tolerance_degrees"), &Curve3D::tessellate, DEFVAL(5), DEFVAL(4));
ClassDB::bind_method(D_METHOD("_get_data"), &Curve3D::_get_data);
ClassDB::bind_method(D_METHOD("_set_data"), &Curve3D::_set_data);
diff --git a/scene/resources/curve.h b/scene/resources/curve.h
index 83a4357bfb..2815c12c4b 100644
--- a/scene/resources/curve.h
+++ b/scene/resources/curve.h
@@ -249,7 +249,7 @@ public:
Vector2 interpolate_baked(float p_offset, bool p_cubic = false) const;
PoolVector2Array get_baked_points() const; //useful for going through
- PoolVector2Array tesselate(int p_max_stages = 5, float p_tolerance = 4) const; //useful for display
+ PoolVector2Array tessellate(int p_max_stages = 5, float p_tolerance = 4) const; //useful for display
Curve2D();
};
@@ -318,7 +318,7 @@ public:
PoolVector3Array get_baked_points() const; //useful for going through
PoolRealArray get_baked_tilts() const; //useful for going through
- PoolVector3Array tesselate(int p_max_stages = 5, float p_tolerance = 4) const; //useful for display
+ PoolVector3Array tessellate(int p_max_stages = 5, float p_tolerance = 4) const; //useful for display
Curve3D();
};
diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp
index 668a8ff66f..3e612c745f 100644
--- a/scene/resources/default_theme/default_theme.cpp
+++ b/scene/resources/default_theme/default_theme.cpp
@@ -510,20 +510,24 @@ void fill_default_theme(Ref<Theme> &t, const Ref<Font> &default_font, const Ref<
t->set_stylebox("slider", "HSlider", make_stylebox(hslider_bg_png, 4, 4, 4, 4));
t->set_stylebox("grabber_highlight", "HSlider", make_stylebox(hslider_grabber_hl_png, 6, 6, 6, 6));
+ t->set_stylebox("grabber_disabled", "HSlider", make_stylebox(hslider_grabber_disabled_png, 6, 6, 6, 6));
t->set_stylebox("focus", "HSlider", focus);
t->set_icon("grabber", "HSlider", make_icon(hslider_grabber_png));
t->set_icon("grabber_highlight", "HSlider", make_icon(hslider_grabber_hl_png));
+ t->set_icon("grabber_disabled", "HSlider", make_icon(hslider_grabber_disabled_png));
t->set_icon("tick", "HSlider", make_icon(hslider_tick_png));
// VSlider
t->set_stylebox("slider", "VSlider", make_stylebox(vslider_bg_png, 4, 4, 4, 4));
t->set_stylebox("grabber_highlight", "VSlider", make_stylebox(vslider_grabber_hl_png, 6, 6, 6, 6));
+ t->set_stylebox("grabber_disabled", "VSlider", make_stylebox(vslider_grabber_disabled_png, 6, 6, 6, 6));
t->set_stylebox("focus", "HSlider", focus);
t->set_icon("grabber", "VSlider", make_icon(vslider_grabber_png));
t->set_icon("grabber_highlight", "VSlider", make_icon(vslider_grabber_hl_png));
+ t->set_icon("grabber_disabled", "VSlider", make_icon(vslider_grabber_disabled_png));
t->set_icon("tick", "VSlider", make_icon(vslider_tick_png));
// SpinBox
@@ -757,11 +761,11 @@ void fill_default_theme(Ref<Theme> &t, const Ref<Font> &default_font, const Ref<
// colorPicker
- t->set_constant("value_height", "ColorPicker", 23 * scale);
- t->set_constant("value_width", "ColorPicker", 50 * scale);
- t->set_constant("color_width", "ColorPicker", 100 * scale);
- t->set_constant("label_width", "ColorPicker", 20 * scale);
- t->set_constant("hseparator", "ColorPicker", 4 * scale);
+ t->set_constant("margin", "ColorPicker", 4 * scale);
+ t->set_constant("sv_width", "ColorPicker", 256 * scale);
+ t->set_constant("sv_height", "ColorPicker", 256 * scale);
+ t->set_constant("h_width", "ColorPicker", 30 * scale);
+ t->set_constant("label_width", "ColorPicker", 10 * scale);
t->set_icon("screen_picker", "ColorPicker", make_icon(icon_color_pick_png));
t->set_icon("add_preset", "ColorPicker", make_icon(icon_add_png));
diff --git a/scene/resources/default_theme/hslider_grabber_disabled.png b/scene/resources/default_theme/hslider_grabber_disabled.png
new file mode 100644
index 0000000000..0d75182b8f
--- /dev/null
+++ b/scene/resources/default_theme/hslider_grabber_disabled.png
Binary files differ
diff --git a/scene/resources/default_theme/theme_data.h b/scene/resources/default_theme/theme_data.h
index b9c401525a..70a8ad12cb 100644
--- a/scene/resources/default_theme/theme_data.h
+++ b/scene/resources/default_theme/theme_data.h
@@ -138,6 +138,10 @@ static const unsigned char hslider_grabber_png[] = {
0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x8, 0x4, 0x0, 0x0, 0x0, 0xb5, 0xfa, 0x37, 0xea, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x2, 0x62, 0x4b, 0x47, 0x44, 0x0, 0xff, 0x87, 0x8f, 0xcc, 0xbf, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x1, 0x1d, 0x49, 0x44, 0x41, 0x54, 0x28, 0xcf, 0x85, 0xd1, 0x3f, 0x4b, 0xc3, 0x40, 0x18, 0xc7, 0xf1, 0xef, 0x25, 0xad, 0x89, 0xa9, 0x70, 0x83, 0x43, 0x5d, 0xc4, 0x21, 0x6e, 0x4a, 0x7, 0x47, 0xdf, 0x83, 0x53, 0x16, 0x17, 0xd7, 0x4e, 0xbe, 0x2, 0x5f, 0x85, 0x83, 0xa0, 0xb8, 0x38, 0xb8, 0x88, 0xd0, 0x51, 0x5d, 0x1c, 0x1c, 0x1c, 0x1c, 0x2a, 0xa2, 0xe8, 0x22, 0x2d, 0x82, 0x2d, 0x88, 0x54, 0xed, 0x3f, 0x1b, 0x9a, 0x78, 0x49, 0x1c, 0x9a, 0x54, 0x4f, 0x5, 0x6f, 0x3a, 0xee, 0xf9, 0xf0, 0x3c, 0x3f, 0x9e, 0x83, 0x7f, 0x8e, 0x18, 0xdf, 0x4c, 0x1c, 0x24, 0x5, 0x60, 0x40, 0x17, 0x9f, 0x48, 0x7, 0x26, 0xd3, 0xe5, 0x55, 0xd7, 0x93, 0x25, 0xe8, 0xde, 0xd4, 0x2b, 0xbb, 0x7, 0xbc, 0x8e, 0x88, 0x99, 0x82, 0xa9, 0xf2, 0xda, 0xe2, 0x86, 0x58, 0x78, 0xb7, 0x87, 0xf6, 0xc4, 0xdc, 0xcc, 0xd2, 0x6c, 0xfb, 0xf2, 0x8e, 0x10, 0xc0, 0x48, 0x81, 0x74, 0x3d, 0x55, 0xf4, 0x51, 0x28, 0x7c, 0x54, 0xd1, 0xf5, 0x90, 0xa3, 0x42, 0x6, 0xa, 0xb2, 0x14, 0x90, 0x0, 0x90, 0x10, 0x20, 0x4b, 0x14, 0x74, 0x20, 0x62, 0xf1, 0x3d, 0x7b, 0x24, 0xb2, 0x74, 0x19, 0x8, 0x83, 0x96, 0x39, 0x2e, 0xb, 0x82, 0x37, 0x94, 0xe, 0x6, 0xbd, 0xdb, 0xfc, 0x18, 0xe4, 0x49, 0x9e, 0xf0, 0x75, 0xd0, 0xbf, 0x3e, 0xb6, 0x22, 0x23, 0x7d, 0x9a, 0x4c, 0xce, 0xf6, 0xe8, 0xe9, 0x20, 0xb8, 0xaa, 0x6, 0xcd, 0x1c, 0x0, 0x39, 0x3e, 0x1e, 0x4f, 0xce, 0x7f, 0x76, 0x88, 0x1f, 0x1a, 0xcf, 0xa7, 0xe, 0x6, 0x6, 0xe, 0x8d, 0x23, 0xd5, 0x22, 0xd6, 0x41, 0x42, 0x77, 0x6b, 0x33, 0xaa, 0x59, 0x58, 0xc4, 0xf5, 0x9d, 0xed, 0x6c, 0xc0, 0xd7, 0x26, 0x21, 0xe, 0x7, 0x9d, 0xda, 0xf2, 0x8a, 0x1d, 0x1f, 0xae, 0xdf, 0x57, 0x19, 0xfe, 0x6, 0xa0, 0x9a, 0x2f, 0xf3, 0xed, 0xfe, 0xc5, 0x7e, 0x85, 0xce, 0x5f, 0xbf, 0x39, 0xca, 0x67, 0x21, 0x18, 0x66, 0x3b, 0x0, 0xf8, 0x4, 0x7e, 0x5c, 0x62, 0x33, 0x51, 0xf0, 0xbb, 0xff, 0x0, 0x0, 0x0, 0x19, 0x74, 0x45, 0x58, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x0, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x47, 0x49, 0x4d, 0x50, 0x57, 0x81, 0xe, 0x17, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
+static const unsigned char hslider_grabber_disabled_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x8, 0x4, 0x0, 0x0, 0x0, 0xb5, 0xfa, 0x37, 0xea, 0x0, 0x0, 0x0, 0x2, 0x62, 0x4b, 0x47, 0x44, 0x0, 0xff, 0x87, 0x8f, 0xcc, 0xbf, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe1, 0x7, 0xa, 0x13, 0x2f, 0x7, 0x5e, 0x49, 0xee, 0x14, 0x0, 0x0, 0x0, 0x1d, 0x69, 0x54, 0x58, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x0, 0x0, 0x0, 0x0, 0x0, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x47, 0x49, 0x4d, 0x50, 0x64, 0x2e, 0x65, 0x7, 0x0, 0x0, 0x0, 0xea, 0x49, 0x44, 0x41, 0x54, 0x28, 0xcf, 0x63, 0x60, 0x20, 0x1a, 0x30, 0x33, 0xf0, 0x32, 0xc8, 0x30, 0xa8, 0x3, 0xa1, 0xc, 0x90, 0xc5, 0x8c, 0x29, 0x2d, 0x66, 0x9c, 0xe7, 0x7a, 0xd0, 0xe7, 0xbd, 0xcf, 0x7b, 0xd7, 0x83, 0xc6, 0x79, 0xc, 0x62, 0xe8, 0x4a, 0x78, 0x8d, 0xf3, 0x3c, 0x5f, 0xb8, 0xff, 0x77, 0x1, 0x42, 0xf7, 0xff, 0x9e, 0x2f, 0x80, 0x4a, 0x78, 0x51, 0x15, 0xc8, 0xb8, 0x1e, 0x74, 0xff, 0xef, 0x4, 0x85, 0xee, 0xff, 0x5d, 0xf, 0x2, 0x2d, 0x42, 0x1, 0xea, 0x3e, 0xef, 0x5d, 0xe0, 0xa, 0x5c, 0xfe, 0xfb, 0xbc, 0x7, 0xba, 0x5, 0x5, 0x68, 0x78, 0x7f, 0x40, 0x56, 0xe0, 0xfd, 0x81, 0x41, 0x3, 0x55, 0x81, 0x92, 0xc7, 0x6d, 0x57, 0x24, 0x5, 0xee, 0xf7, 0x18, 0x54, 0x50, 0x15, 0x88, 0x3b, 0xae, 0xf7, 0x40, 0x72, 0x83, 0xfb, 0x51, 0x6, 0x29, 0x54, 0x5, 0x5c, 0x9a, 0xa9, 0xde, 0x7f, 0x9c, 0xc1, 0xd2, 0xce, 0xff, 0xbd, 0xff, 0xa9, 0xa7, 0x30, 0xf0, 0xa0, 0x85, 0x83, 0xa0, 0xa1, 0xc7, 0x3, 0x88, 0x25, 0xae, 0xff, 0x3d, 0x1f, 0x30, 0x69, 0x30, 0x30, 0xa1, 0x2a, 0x60, 0x64, 0x10, 0xb1, 0x99, 0xe3, 0x5, 0xd4, 0xed, 0xfc, 0xdf, 0xeb, 0xbf, 0xd5, 0x54, 0x6, 0x61, 0xcc, 0xa0, 0x66, 0x65, 0xd3, 0xf1, 0xb8, 0xed, 0xf6, 0xdf, 0xed, 0xbf, 0xe7, 0x1d, 0x36, 0x1d, 0x6, 0x56, 0x6c, 0xb1, 0xc1, 0x2d, 0xe3, 0xef, 0xf7, 0xc5, 0xef, 0xbb, 0x42, 0x28, 0xba, 0xfd, 0x48, 0xd6, 0x58, 0x16, 0xdb, 0xd6, 0x2, 0xe3, 0x81, 0x11, 0x57, 0x8c, 0xb2, 0x30, 0x70, 0x3, 0x75, 0xb3, 0x20, 0xb, 0x1, 0x0, 0x4, 0x5c, 0x63, 0x9b, 0x17, 0x86, 0x76, 0xe0, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
+};
+
static const unsigned char hslider_grabber_hl_png[] = {
0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x8, 0x3, 0x0, 0x0, 0x0, 0x28, 0x2d, 0xf, 0x53, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0xc6, 0x50, 0x4c, 0x54, 0x45, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x48, 0x83, 0x83, 0x60, 0xaf, 0xb1, 0x65, 0xbb, 0xca, 0x61, 0xb3, 0xc2, 0x0, 0x0, 0x0, 0x63, 0xb7, 0xc8, 0x63, 0xb7, 0xc7, 0x0, 0x0, 0x0, 0x61, 0xb3, 0xbc, 0x60, 0xb1, 0xbc, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5b, 0xa6, 0xa5, 0x63, 0xb4, 0xb6, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3a, 0x69, 0x69, 0x5e, 0xb1, 0xcd, 0x5e, 0xb0, 0xcd, 0x36, 0x63, 0x63, 0x0, 0x0, 0x0, 0x17, 0x2a, 0x29, 0x60, 0xb2, 0xbd, 0x62, 0xb3, 0xbf, 0x3, 0x5, 0x5, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x55, 0x9b, 0x9a, 0x52, 0x96, 0x95, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8, 0xf, 0xf, 0x62, 0xb4, 0xbd, 0x63, 0xb7, 0xbf, 0x0, 0x0, 0x0, 0x27, 0x48, 0x47, 0x68, 0xc0, 0xcf, 0x68, 0xc1, 0xcf, 0x2d, 0x52, 0x52, 0x51, 0x93, 0x92, 0x56, 0x9d, 0x9c, 0x0, 0x0, 0x0, 0x54, 0xa2, 0xc8, 0x4c, 0x94, 0xc2, 0x48, 0x8e, 0xc0, 0x47, 0x8c, 0xbf, 0x4b, 0x93, 0xc2, 0x4b, 0x92, 0xc2, 0x4f, 0x98, 0xc4, 0x4d, 0x96, 0xc3, 0x55, 0xa3, 0xc8, 0x53, 0x9f, 0xc7, 0x49, 0x8f, 0xc0, 0x4e, 0x97, 0xc4, 0x5a, 0xab, 0xcb, 0x5a, 0xac, 0xcc, 0x52, 0x9e, 0xc6, 0x51, 0x9d, 0xc6, 0xff, 0xff, 0xff, 0x6b, 0x1e, 0xb5, 0x61, 0x0, 0x0, 0x0, 0x31, 0x74, 0x52, 0x4e, 0x53, 0x0, 0x3, 0xd, 0x1c, 0x27, 0x16, 0x6e, 0xc1, 0xef, 0xe8, 0x28, 0xf0, 0xf0, 0x22, 0xdb, 0xde, 0x24, 0x17, 0xaf, 0xc5, 0x1a, 0xa, 0x65, 0xfc, 0xfe, 0x64, 0xc, 0x31, 0xe0, 0xe0, 0x28, 0x2, 0x1, 0x14, 0x9c, 0x95, 0x13, 0x5, 0x2c, 0xdb, 0xdc, 0xb, 0x4f, 0xf4, 0xf7, 0x55, 0x73, 0x7d, 0x4, 0x28, 0xf1, 0xfd, 0xa1, 0x0, 0x0, 0x0, 0x1, 0x62, 0x4b, 0x47, 0x44, 0x41, 0x89, 0xde, 0x6c, 0x4e, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x4, 0x4e, 0x1d, 0x2, 0xaf, 0x0, 0x0, 0x0, 0x9e, 0x49, 0x44, 0x41, 0x54, 0x18, 0xd3, 0x6d, 0xcf, 0xd7, 0x12, 0x82, 0x30, 0x10, 0x5, 0x50, 0x48, 0x42, 0x12, 0xb0, 0x77, 0x8d, 0xd, 0xb, 0x28, 0x56, 0x12, 0x62, 0xd, 0x96, 0xff, 0xff, 0x2a, 0x61, 0xc, 0xe0, 0x83, 0xfb, 0xb4, 0xf7, 0xcc, 0xec, 0xcc, 0x5d, 0xc3, 0xf8, 0x37, 0x26, 0x80, 0x8, 0x41, 0x60, 0xe6, 0xd9, 0xc2, 0x84, 0x52, 0x82, 0xad, 0x4c, 0x0, 0xb6, 0xb9, 0x10, 0xdc, 0xc6, 0x40, 0x3, 0x24, 0x3c, 0x92, 0x32, 0xe2, 0x4, 0x6a, 0x40, 0x54, 0xc8, 0x64, 0x4, 0x45, 0x1a, 0x9c, 0xd2, 0x29, 0x85, 0x73, 0xd9, 0xd1, 0x50, 0xa9, 0x5e, 0x52, 0xb8, 0xd6, 0xea, 0x1a, 0x1a, 0xcd, 0x5b, 0xa, 0xf7, 0x56, 0x5b, 0x43, 0xa7, 0xdb, 0x53, 0x52, 0xaa, 0xfe, 0x80, 0x65, 0x3d, 0x86, 0xa3, 0x58, 0xca, 0x78, 0x3c, 0x99, 0x6a, 0x70, 0x67, 0xf3, 0x87, 0x52, 0xcf, 0xc5, 0x32, 0xaf, 0xee, 0xf9, 0xab, 0xd7, 0x7b, 0xed, 0x7b, 0xc5, 0x33, 0xc1, 0x66, 0xbb, 0xdb, 0xb3, 0x22, 0x27, 0x47, 0x87, 0xa3, 0xe5, 0xfe, 0xfe, 0x1b, 0x6, 0x2c, 0xfc, 0x6e, 0x1f, 0x93, 0x2a, 0x10, 0x62, 0x3, 0x21, 0x32, 0x75, 0x0, 0x0, 0x0, 0x19, 0x74, 0x45, 0x58, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x0, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x47, 0x49, 0x4d, 0x50, 0x57, 0x81, 0xe, 0x17, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
@@ -434,6 +438,10 @@ static const unsigned char vslider_grabber_png[] = {
0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x8, 0x4, 0x0, 0x0, 0x0, 0xb5, 0xfa, 0x37, 0xea, 0x0, 0x0, 0x0, 0x2, 0x62, 0x4b, 0x47, 0x44, 0x0, 0xb7, 0xff, 0x88, 0x5, 0x1d, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe1, 0x1, 0x12, 0x1, 0x36, 0x8, 0x50, 0xb9, 0xa7, 0x53, 0x0, 0x0, 0x0, 0x19, 0x74, 0x45, 0x58, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x0, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x47, 0x49, 0x4d, 0x50, 0x57, 0x81, 0xe, 0x17, 0x0, 0x0, 0x0, 0xf6, 0x49, 0x44, 0x41, 0x54, 0x28, 0xcf, 0xbd, 0x90, 0xb1, 0x4a, 0x42, 0x51, 0x0, 0x86, 0xbf, 0x73, 0x8e, 0x71, 0xe5, 0x9a, 0x5c, 0x41, 0xd0, 0x66, 0x6b, 0x33, 0x1c, 0x7c, 0x80, 0xa0, 0xa5, 0x17, 0x8, 0xa2, 0x2d, 0x84, 0xf0, 0x1, 0xa2, 0x25, 0xf1, 0x9, 0x9a, 0x1c, 0xda, 0x5b, 0xb2, 0x47, 0xa8, 0xa5, 0xc1, 0xa0, 0x51, 0x88, 0xa2, 0x29, 0xa, 0xc1, 0x84, 0x8, 0x43, 0xf4, 0x96, 0x17, 0xcf, 0xed, 0xde, 0x73, 0x9c, 0xcc, 0x5c, 0xda, 0xea, 0x9f, 0x3f, 0xfe, 0x9f, 0xef, 0x87, 0x3f, 0x8f, 0x0, 0x40, 0xe1, 0xe2, 0x91, 0x42, 0x10, 0x32, 0xe6, 0x3, 0x8d, 0xc1, 0xce, 0x1, 0x45, 0xb6, 0xba, 0xbb, 0xba, 0xed, 0x95, 0x8c, 0xd0, 0x7d, 0xff, 0xe1, 0xee, 0xe2, 0xb6, 0xdd, 0x79, 0x61, 0xc4, 0xd7, 0xc, 0x48, 0x57, 0x2b, 0xeb, 0xb5, 0x28, 0xaf, 0x1, 0xc5, 0x12, 0x4e, 0xac, 0x7b, 0x6f, 0x57, 0x27, 0x8d, 0xcf, 0xe, 0x1, 0x56, 0x1, 0xb9, 0x9d, 0xba, 0x28, 0x6, 0x18, 0xc, 0x31, 0x21, 0x5a, 0xda, 0x4c, 0xb6, 0xbc, 0xb9, 0x35, 0x7c, 0xea, 0xbd, 0x13, 0x4a, 0x20, 0xe5, 0x95, 0xf4, 0x6c, 0x12, 0x30, 0x84, 0xf8, 0x44, 0x6b, 0xfb, 0xcd, 0x83, 0x3d, 0x1c, 0xf9, 0x8b, 0x80, 0x4a, 0xba, 0x88, 0x4, 0x30, 0x1e, 0xdd, 0x3b, 0x1b, 0xf1, 0x77, 0x87, 0x24, 0x81, 0x8b, 0x79, 0x3e, 0x3b, 0x6a, 0x5d, 0x33, 0x51, 0x80, 0x2d, 0x38, 0x2b, 0x65, 0xb5, 0x6c, 0x91, 0x28, 0x92, 0xa4, 0xad, 0xec, 0x76, 0xcf, 0x8f, 0xf, 0x1f, 0xdb, 0xc, 0x31, 0xb, 0x9a, 0xb1, 0xd0, 0x3, 0xfb, 0xda, 0x3a, 0xbd, 0xbc, 0x89, 0xfa, 0xf8, 0x73, 0xcd, 0x9f, 0x47, 0x45, 0x4, 0xf8, 0x4, 0x18, 0xfe, 0x2f, 0x53, 0x8, 0x62, 0x5c, 0xcf, 0x1f, 0x5f, 0xcb, 0x2c, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
+static const unsigned char vslider_grabber_disabled_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x8, 0x4, 0x0, 0x0, 0x0, 0xb5, 0xfa, 0x37, 0xea, 0x0, 0x0, 0x0, 0x2, 0x62, 0x4b, 0x47, 0x44, 0x0, 0xff, 0x87, 0x8f, 0xcc, 0xbf, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe1, 0x7, 0xa, 0x13, 0x2e, 0x39, 0x86, 0x33, 0xc2, 0xfe, 0x0, 0x0, 0x0, 0x1d, 0x69, 0x54, 0x58, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x0, 0x0, 0x0, 0x0, 0x0, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x47, 0x49, 0x4d, 0x50, 0x64, 0x2e, 0x65, 0x7, 0x0, 0x0, 0x0, 0xb7, 0x49, 0x44, 0x41, 0x54, 0x28, 0xcf, 0x63, 0x60, 0xa0, 0x13, 0x60, 0x66, 0xe0, 0x65, 0x90, 0x61, 0x50, 0x67, 0xd0, 0x60, 0x50, 0x62, 0x10, 0x67, 0xe0, 0x2, 0xf2, 0x19, 0x51, 0xa5, 0xc5, 0x8c, 0xf3, 0x5c, 0xf, 0xfa, 0xbc, 0xf7, 0xfe, 0xe0, 0x71, 0xdb, 0x71, 0xbd, 0x66, 0xaa, 0xa0, 0x21, 0x83, 0x8, 0x3, 0x2b, 0x42, 0x1, 0xaf, 0x71, 0x9e, 0xe7, 0xb, 0xf7, 0xff, 0x2e, 0x40, 0xe8, 0xfa, 0xdf, 0xe3, 0xbf, 0xf7, 0x1f, 0x8f, 0x7, 0x36, 0x73, 0xd8, 0x74, 0x18, 0xb8, 0x61, 0xe6, 0xc8, 0xb8, 0x1e, 0x74, 0xff, 0xef, 0x4, 0x87, 0xce, 0x40, 0x65, 0x5e, 0xff, 0x3d, 0x6e, 0xcb, 0xf8, 0x3, 0xcd, 0x61, 0x1, 0x29, 0x50, 0xf7, 0x79, 0xef, 0x82, 0xa4, 0x0, 0xa2, 0xc8, 0xed, 0xbf, 0xdf, 0x17, 0xcb, 0x62, 0xa0, 0x29, 0x78, 0x14, 0x7c, 0xb7, 0xad, 0x65, 0xe0, 0xc1, 0x69, 0x85, 0xe7, 0x1d, 0x85, 0x50, 0x6, 0x31, 0x88, 0x15, 0x48, 0x8e, 0x74, 0xf9, 0xef, 0xfe, 0xdf, 0xfb, 0x9f, 0xe7, 0x3, 0xab, 0xa9, 0x40, 0x47, 0xf2, 0xc0, 0x1c, 0x89, 0xe4, 0x4d, 0xf7, 0x7b, 0xee, 0x47, 0xd5, 0x53, 0x98, 0x34, 0x18, 0x84, 0x91, 0xbd, 0x89, 0x1c, 0x50, 0x2a, 0xc, 0x52, 0x40, 0x9d, 0x4c, 0xc, 0xf4, 0x4, 0x0, 0xf1, 0x9, 0x63, 0x9b, 0x3e, 0x2a, 0x19, 0x52, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
+};
+
static const unsigned char vslider_grabber_hl_png[] = {
0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x8, 0x3, 0x0, 0x0, 0x0, 0x28, 0x2d, 0xf, 0x53, 0x0, 0x0, 0x0, 0xc3, 0x50, 0x4c, 0x54, 0x45, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x17, 0x2a, 0x29, 0x3a, 0x69, 0x69, 0x5b, 0xa6, 0xa5, 0x61, 0xb3, 0xbc, 0x63, 0xb7, 0xc8, 0x65, 0xbb, 0xca, 0x60, 0xaf, 0xb1, 0x48, 0x83, 0x83, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8, 0xf, 0xf, 0x55, 0x9b, 0x9a, 0x60, 0xb2, 0xbd, 0x5e, 0xb1, 0xcd, 0x61, 0xb3, 0xc2, 0x0, 0x0, 0x0, 0x27, 0x48, 0x47, 0x62, 0xb4, 0xbd, 0x51, 0x93, 0x92, 0x68, 0xc0, 0xcf, 0x0, 0x0, 0x0, 0x56, 0x9d, 0x9c, 0x68, 0xc1, 0xcf, 0x2d, 0x52, 0x52, 0x63, 0xb7, 0xbf, 0x52, 0x96, 0x95, 0x62, 0xb3, 0xbf, 0x5e, 0xb0, 0xcd, 0x0, 0x0, 0x0, 0x3, 0x5, 0x5, 0x36, 0x63, 0x63, 0x63, 0xb4, 0xb6, 0x60, 0xb1, 0xbc, 0x63, 0xb7, 0xc7, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x55, 0xa3, 0xc8, 0x4f, 0x98, 0xc4, 0x4b, 0x93, 0xc2, 0x4c, 0x94, 0xc2, 0x54, 0xa2, 0xc8, 0x5a, 0xab, 0xcb, 0x4e, 0x97, 0xc4, 0x49, 0x8f, 0xc0, 0x47, 0x8c, 0xbf, 0x48, 0x8e, 0xc0, 0x52, 0x9e, 0xc6, 0x51, 0x9d, 0xc6, 0x5a, 0xac, 0xcc, 0x53, 0x9f, 0xc7, 0x4d, 0x96, 0xc3, 0x4b, 0x92, 0xc2, 0xff, 0xff, 0xff, 0x76, 0xbd, 0x27, 0x7a, 0x0, 0x0, 0x0, 0x1, 0x74, 0x52, 0x4e, 0x53, 0x0, 0x40, 0xe6, 0xd8, 0x66, 0x0, 0x0, 0x0, 0x1, 0x62, 0x4b, 0x47, 0x44, 0x0, 0x88, 0x5, 0x1d, 0x48, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe1, 0x1, 0x12, 0x1, 0x36, 0x11, 0x34, 0xd2, 0xf, 0x93, 0x0, 0x0, 0x0, 0x19, 0x74, 0x45, 0x58, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x0, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x47, 0x49, 0x4d, 0x50, 0x57, 0x81, 0xe, 0x17, 0x0, 0x0, 0x0, 0x48, 0x49, 0x44, 0x41, 0x54, 0x18, 0xd3, 0x63, 0x60, 0xa0, 0x12, 0x10, 0x14, 0xe0, 0xe7, 0xe3, 0x45, 0xe2, 0x4b, 0x9a, 0x18, 0x1b, 0x19, 0x1a, 0x48, 0x88, 0x8b, 0xc1, 0xe4, 0x4d, 0x2c, 0x2d, 0x80, 0xc0, 0xdc, 0xcc, 0x54, 0x6, 0x22, 0x20, 0x60, 0x6c, 0x1, 0x1, 0xe6, 0x56, 0x72, 0x68, 0x2, 0xd6, 0x8a, 0xa8, 0x5a, 0x6c, 0x94, 0x11, 0x86, 0xda, 0xdb, 0xd9, 0xaa, 0xa9, 0xaa, 0x20, 0x59, 0xab, 0xa3, 0xad, 0xc5, 0x40, 0x3d, 0x0, 0x0, 0xbf, 0x8e, 0xc, 0xed, 0xed, 0xc7, 0x67, 0x72, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
diff --git a/scene/resources/default_theme/vslider_grabber_disabled.png b/scene/resources/default_theme/vslider_grabber_disabled.png
new file mode 100644
index 0000000000..c830359f45
--- /dev/null
+++ b/scene/resources/default_theme/vslider_grabber_disabled.png
Binary files differ
diff --git a/scene/resources/dynamic_font.cpp b/scene/resources/dynamic_font.cpp
index d2848076a0..2fdc4c9e24 100644
--- a/scene/resources/dynamic_font.cpp
+++ b/scene/resources/dynamic_font.cpp
@@ -338,7 +338,7 @@ float DynamicFontAtSize::draw_char(RID p_canvas_item, const Point2 &p_pos, CharT
cpos.y += ch->v_align;
ERR_FAIL_COND_V(ch->texture_idx < -1 || ch->texture_idx >= fb->textures.size(), 0);
if (ch->texture_idx != -1)
- VisualServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, Rect2(cpos, ch->rect.size), fb->textures[ch->texture_idx].texture->get_rid(), ch->rect, p_modulate);
+ VisualServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, Rect2(cpos, ch->rect.size), fb->textures[ch->texture_idx].texture->get_rid(), ch->rect, p_modulate, false, RID(), false);
advance = ch->advance;
used_fallback = true;
break;
@@ -360,7 +360,7 @@ float DynamicFontAtSize::draw_char(RID p_canvas_item, const Point2 &p_pos, CharT
cpos.y += c->v_align;
ERR_FAIL_COND_V(c->texture_idx < -1 || c->texture_idx >= textures.size(), 0);
if (c->texture_idx != -1)
- VisualServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, Rect2(cpos, c->rect.size), textures[c->texture_idx].texture->get_rid(), c->rect, p_modulate);
+ VisualServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, Rect2(cpos, c->rect.size), textures[c->texture_idx].texture->get_rid(), c->rect, p_modulate, false, RID(), false);
advance = c->advance;
//textures[c->texture_idx].texture->draw(p_canvas_item,Vector2());
}
diff --git a/scene/resources/environment.cpp b/scene/resources/environment.cpp
index 24e3977de8..accced404b 100644
--- a/scene/resources/environment.cpp
+++ b/scene/resources/environment.cpp
@@ -28,7 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "environment.h"
-#include "global_config.h"
+#include "project_settings.h"
#include "servers/visual_server.h"
#include "texture.h"
@@ -167,6 +167,7 @@ void Environment::set_tonemap_auto_exposure(bool p_enabled) {
tonemap_auto_exposure = p_enabled;
VS::get_singleton()->environment_set_tonemap(environment, VS::EnvironmentToneMapper(tone_mapper), tonemap_exposure, tonemap_white, tonemap_auto_exposure, tonemap_auto_exposure_min, tonemap_auto_exposure_max, tonemap_auto_exposure_speed, tonemap_auto_exposure_grey);
+ _change_notify();
}
bool Environment::get_tonemap_auto_exposure() const {
@@ -471,7 +472,7 @@ bool Environment::is_ssao_blur_enabled() const {
void Environment::set_glow_enabled(bool p_enabled) {
glow_enabled = p_enabled;
- VS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_bloom, VS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_treshold, glow_hdr_bleed_treshold, glow_bicubic_upscale);
+ VS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_bloom, VS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_threshold, glow_bicubic_upscale);
_change_notify();
}
@@ -489,7 +490,7 @@ void Environment::set_glow_level(int p_level, bool p_enabled) {
else
glow_levels &= ~(1 << p_level);
- VS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_bloom, VS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_treshold, glow_hdr_bleed_treshold, glow_bicubic_upscale);
+ VS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_bloom, VS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_threshold, glow_bicubic_upscale);
}
bool Environment::is_glow_level_enabled(int p_level) const {
@@ -502,7 +503,7 @@ void Environment::set_glow_intensity(float p_intensity) {
glow_intensity = p_intensity;
- VS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_bloom, VS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_treshold, glow_hdr_bleed_treshold, glow_bicubic_upscale);
+ VS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_bloom, VS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_threshold, glow_bicubic_upscale);
}
float Environment::get_glow_intensity() const {
@@ -512,18 +513,18 @@ float Environment::get_glow_intensity() const {
void Environment::set_glow_strength(float p_strength) {
glow_strength = p_strength;
- VS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_bloom, VS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_treshold, glow_hdr_bleed_treshold, glow_bicubic_upscale);
+ VS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_bloom, VS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_threshold, glow_bicubic_upscale);
}
float Environment::get_glow_strength() const {
return glow_strength;
}
-void Environment::set_glow_bloom(float p_treshold) {
+void Environment::set_glow_bloom(float p_threshold) {
- glow_bloom = p_treshold;
+ glow_bloom = p_threshold;
- VS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_bloom, VS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_treshold, glow_hdr_bleed_treshold, glow_bicubic_upscale);
+ VS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_bloom, VS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_threshold, glow_bicubic_upscale);
}
float Environment::get_glow_bloom() const {
@@ -534,29 +535,29 @@ void Environment::set_glow_blend_mode(GlowBlendMode p_mode) {
glow_blend_mode = p_mode;
- VS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_bloom, VS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_treshold, glow_hdr_bleed_treshold, glow_bicubic_upscale);
+ VS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_bloom, VS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_threshold, glow_bicubic_upscale);
}
Environment::GlowBlendMode Environment::get_glow_blend_mode() const {
return glow_blend_mode;
}
-void Environment::set_glow_hdr_bleed_treshold(float p_treshold) {
+void Environment::set_glow_hdr_bleed_threshold(float p_threshold) {
- glow_hdr_bleed_treshold = p_treshold;
+ glow_hdr_bleed_threshold = p_threshold;
- VS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_bloom, VS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_treshold, glow_hdr_bleed_treshold, glow_bicubic_upscale);
+ VS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_bloom, VS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_threshold, glow_bicubic_upscale);
}
-float Environment::get_glow_hdr_bleed_treshold() const {
+float Environment::get_glow_hdr_bleed_threshold() const {
- return glow_hdr_bleed_treshold;
+ return glow_hdr_bleed_threshold;
}
void Environment::set_glow_hdr_bleed_scale(float p_scale) {
glow_hdr_bleed_scale = p_scale;
- VS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_bloom, VS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_treshold, glow_hdr_bleed_treshold, glow_bicubic_upscale);
+ VS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_bloom, VS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_threshold, glow_bicubic_upscale);
}
float Environment::get_glow_hdr_bleed_scale() const {
@@ -566,7 +567,7 @@ float Environment::get_glow_hdr_bleed_scale() const {
void Environment::set_glow_bicubic_upscale(bool p_enable) {
glow_bicubic_upscale = p_enable;
- VS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_bloom, VS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_treshold, glow_hdr_bleed_treshold, glow_bicubic_upscale);
+ VS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_bloom, VS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_threshold, glow_bicubic_upscale);
}
bool Environment::is_glow_bicubic_upscale_enabled() const {
@@ -818,7 +819,7 @@ float Environment::get_fog_height_curve() const {
void Environment::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_background", "mode"), &Environment::set_background);
- ClassDB::bind_method(D_METHOD("set_sky", "sky:CubeMap"), &Environment::set_sky);
+ ClassDB::bind_method(D_METHOD("set_sky", "sky:Sky"), &Environment::set_sky);
ClassDB::bind_method(D_METHOD("set_sky_scale", "scale"), &Environment::set_sky_scale);
ClassDB::bind_method(D_METHOD("set_bg_color", "color"), &Environment::set_bg_color);
ClassDB::bind_method(D_METHOD("set_bg_energy", "energy"), &Environment::set_bg_energy);
@@ -1064,8 +1065,8 @@ void Environment::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_glow_blend_mode", "mode"), &Environment::set_glow_blend_mode);
ClassDB::bind_method(D_METHOD("get_glow_blend_mode"), &Environment::get_glow_blend_mode);
- ClassDB::bind_method(D_METHOD("set_glow_hdr_bleed_treshold", "treshold"), &Environment::set_glow_hdr_bleed_treshold);
- ClassDB::bind_method(D_METHOD("get_glow_hdr_bleed_treshold"), &Environment::get_glow_hdr_bleed_treshold);
+ ClassDB::bind_method(D_METHOD("set_glow_hdr_bleed_threshold", "threshold"), &Environment::set_glow_hdr_bleed_threshold);
+ ClassDB::bind_method(D_METHOD("get_glow_hdr_bleed_threshold"), &Environment::get_glow_hdr_bleed_threshold);
ClassDB::bind_method(D_METHOD("set_glow_hdr_bleed_scale", "scale"), &Environment::set_glow_hdr_bleed_scale);
ClassDB::bind_method(D_METHOD("get_glow_hdr_bleed_scale"), &Environment::get_glow_hdr_bleed_scale);
@@ -1087,7 +1088,7 @@ void Environment::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::REAL, "glow_strength", PROPERTY_HINT_RANGE, "0.0,2.0,0.01"), "set_glow_strength", "get_glow_strength");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "glow_bloom", PROPERTY_HINT_RANGE, "0.0,1.0,0.01"), "set_glow_bloom", "get_glow_bloom");
ADD_PROPERTY(PropertyInfo(Variant::INT, "glow_blend_mode", PROPERTY_HINT_ENUM, "Additive,Screen,Softlight,Replace"), "set_glow_blend_mode", "get_glow_blend_mode");
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "glow_hdr_treshold", PROPERTY_HINT_RANGE, "0.0,4.0,0.01"), "set_glow_hdr_bleed_treshold", "get_glow_hdr_bleed_treshold");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "glow_hdr_threshold", PROPERTY_HINT_RANGE, "0.0,4.0,0.01"), "set_glow_hdr_bleed_threshold", "get_glow_hdr_bleed_threshold");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "glow_hdr_scale", PROPERTY_HINT_RANGE, "0.0,4.0,0.01"), "set_glow_hdr_bleed_scale", "get_glow_hdr_bleed_scale");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "glow_bicubic_upscale"), "set_glow_bicubic_upscale", "is_glow_bicubic_upscale_enabled");
@@ -1103,8 +1104,8 @@ void Environment::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_adjustment_saturation", "saturation"), &Environment::set_adjustment_saturation);
ClassDB::bind_method(D_METHOD("get_adjustment_saturation"), &Environment::get_adjustment_saturation);
- ClassDB::bind_method(D_METHOD("set_adjustment_color_correction", "color_correction"), &Environment::set_adjustment_color_correction);
- ClassDB::bind_method(D_METHOD("get_adjustment_color_correction"), &Environment::get_adjustment_color_correction);
+ ClassDB::bind_method(D_METHOD("set_adjustment_color_correction", "color_correction:Texture"), &Environment::set_adjustment_color_correction);
+ ClassDB::bind_method(D_METHOD("get_adjustment_color_correction:Texture"), &Environment::get_adjustment_color_correction);
ADD_GROUP("Adjustments", "adjustment_");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "adjustment_enabled"), "set_adjustment_enable", "is_adjustment_enabled");
@@ -1113,8 +1114,6 @@ void Environment::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::REAL, "adjustment_saturation", PROPERTY_HINT_RANGE, "0.01,8,0.01"), "set_adjustment_saturation", "get_adjustment_saturation");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "adjustment_color_correction", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_adjustment_color_correction", "get_adjustment_color_correction");
- GLOBAL_DEF("rendering/sky/irradiance_cube_resolution", 256);
-
BIND_CONSTANT(BG_KEEP);
BIND_CONSTANT(BG_CLEAR_COLOR);
BIND_CONSTANT(BG_COLOR);
@@ -1185,7 +1184,7 @@ Environment::Environment() {
glow_strength = 1.0;
glow_bloom = 0.0;
glow_blend_mode = GLOW_BLEND_MODE_SOFTLIGHT;
- glow_hdr_bleed_treshold = 1.0;
+ glow_hdr_bleed_threshold = 1.0;
glow_hdr_bleed_scale = 2.0;
glow_bicubic_upscale = false;
diff --git a/scene/resources/environment.h b/scene/resources/environment.h
index 7eda8506b5..a7c0e2a03d 100644
--- a/scene/resources/environment.h
+++ b/scene/resources/environment.h
@@ -121,7 +121,7 @@ private:
float glow_strength;
float glow_bloom;
GlowBlendMode glow_blend_mode;
- float glow_hdr_bleed_treshold;
+ float glow_hdr_bleed_threshold;
float glow_hdr_bleed_scale;
bool glow_bicubic_upscale;
@@ -275,14 +275,14 @@ public:
void set_glow_strength(float p_strength);
float get_glow_strength() const;
- void set_glow_bloom(float p_treshold);
+ void set_glow_bloom(float p_threshold);
float get_glow_bloom() const;
void set_glow_blend_mode(GlowBlendMode p_mode);
GlowBlendMode get_glow_blend_mode() const;
- void set_glow_hdr_bleed_treshold(float p_treshold);
- float get_glow_hdr_bleed_treshold() const;
+ void set_glow_hdr_bleed_threshold(float p_threshold);
+ float get_glow_hdr_bleed_threshold() const;
void set_glow_hdr_bleed_scale(float p_scale);
float get_glow_hdr_bleed_scale() const;
diff --git a/scene/resources/font.cpp b/scene/resources/font.cpp
index 225a42f651..a6a70d775f 100644
--- a/scene/resources/font.cpp
+++ b/scene/resources/font.cpp
@@ -506,7 +506,7 @@ float BitmapFont::draw_char(RID p_canvas_item, const Point2 &p_pos, CharType p_c
cpos.y += c->v_align;
ERR_FAIL_COND_V(c->texture_idx < -1 || c->texture_idx >= textures.size(), 0);
if (c->texture_idx != -1)
- VisualServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, Rect2(cpos, c->rect.size), textures[c->texture_idx]->get_rid(), c->rect, p_modulate);
+ VisualServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, Rect2(cpos, c->rect.size), textures[c->texture_idx]->get_rid(), c->rect, p_modulate, false, RID(), false);
return get_char_size(p_char, p_next).width;
}
@@ -570,8 +570,8 @@ void BitmapFont::_bind_methods() {
ClassDB::bind_method(D_METHOD("_set_textures"), &BitmapFont::_set_textures);
ClassDB::bind_method(D_METHOD("_get_textures"), &BitmapFont::_get_textures);
- ClassDB::bind_method(D_METHOD("set_fallback", "fallback"), &BitmapFont::set_fallback);
- ClassDB::bind_method(D_METHOD("get_fallback"), &BitmapFont::get_fallback);
+ ClassDB::bind_method(D_METHOD("set_fallback", "fallback:BitmapFont"), &BitmapFont::set_fallback);
+ ClassDB::bind_method(D_METHOD("get_fallback:BitmapFont"), &BitmapFont::get_fallback);
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "textures", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "_set_textures", "_get_textures");
ADD_PROPERTY(PropertyInfo(Variant::POOL_INT_ARRAY, "chars", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "_set_chars", "_get_chars");
diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp
index 3934467855..24ec39afe3 100644
--- a/scene/resources/material.cpp
+++ b/scene/resources/material.cpp
@@ -30,11 +30,36 @@
#include "material.h"
#include "scene/scene_string_names.h"
+void Material::set_next_pass(const Ref<Material> &p_pass) {
+
+ if (next_pass == p_pass)
+ return;
+
+ next_pass = p_pass;
+ RID next_pass_rid;
+ if (next_pass.is_valid())
+ next_pass_rid = next_pass->get_rid();
+ VS::get_singleton()->material_set_next_pass(material, next_pass_rid);
+}
+
+Ref<Material> Material::get_next_pass() const {
+
+ return next_pass;
+}
+
RID Material::get_rid() const {
return material;
}
+void Material::_bind_methods() {
+
+ ClassDB::bind_method(D_METHOD("set_next_pass", "next_pass:Material"), &Material::set_next_pass);
+ ClassDB::bind_method(D_METHOD("get_next_pass:Material"), &Material::get_next_pass);
+
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "next_pass", PROPERTY_HINT_RESOURCE_TYPE, "Material"), "set_next_pass", "get_next_pass");
+}
+
Material::Material() {
material = VisualServer::get_singleton()->material_create();
@@ -138,7 +163,7 @@ void ShaderMaterial::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_shader", "shader:Shader"), &ShaderMaterial::set_shader);
ClassDB::bind_method(D_METHOD("get_shader:Shader"), &ShaderMaterial::get_shader);
ClassDB::bind_method(D_METHOD("set_shader_param", "param", "value"), &ShaderMaterial::set_shader_param);
- ClassDB::bind_method(D_METHOD("get_shader_param", "param"), &ShaderMaterial::get_shader_param);
+ ClassDB::bind_method(D_METHOD("get_shader_param:Variant", "param"), &ShaderMaterial::get_shader_param);
}
void ShaderMaterial::get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const {
@@ -198,6 +223,8 @@ void SpatialMaterial::init_shaders() {
shader_names->uv1_offset = "uv1_offset";
shader_names->uv2_scale = "uv2_scale";
shader_names->uv2_offset = "uv2_offset";
+ shader_names->uv1_blend_sharpness = "uv1_blend_sharpness";
+ shader_names->uv2_blend_sharpness = "uv2_blend_sharpness";
shader_names->particle_h_frames = "particle_h_frames";
shader_names->particle_v_frames = "particle_v_frames";
@@ -205,6 +232,8 @@ void SpatialMaterial::init_shaders() {
shader_names->depth_min_layers = "depth_min_layers";
shader_names->depth_max_layers = "depth_max_layers";
+ shader_names->grow = "grow";
+
shader_names->texture_names[TEXTURE_ALBEDO] = "texture_albedo";
shader_names->texture_names[TEXTURE_METALLIC] = "texture_metallic";
shader_names->texture_names[TEXTURE_ROUGHNESS] = "texture_roughness";
@@ -289,6 +318,14 @@ void SpatialMaterial::_update_shader() {
case DIFFUSE_HALF_LAMBERT: code += ",diffuse_half_lambert"; break;
case DIFFUSE_OREN_NAYAR: code += ",diffuse_oren_nayar"; break;
case DIFFUSE_BURLEY: code += ",diffuse_burley"; break;
+ case DIFFUSE_TOON: code += ",diffuse_toon"; break;
+ }
+ switch (specular_mode) {
+ case SPECULAR_SCHLICK_GGX: code += ",specular_schlick_ggx"; break;
+ case SPECULAR_BLINN: code += ",specular_blinn"; break;
+ case SPECULAR_PHONG: code += ",specular_phong"; break;
+ case SPECULAR_TOON: code += ",specular_toon"; break;
+ case SPECULAR_DISABLED: code += ",specular_disabled"; break;
}
if (flags[FLAG_UNSHADED]) {
@@ -297,22 +334,27 @@ void SpatialMaterial::_update_shader() {
if (flags[FLAG_ONTOP]) {
code += ",ontop";
}
+ if (flags[FLAG_USE_VERTEX_LIGHTING]) {
+ code += ",vertex_lighting";
+ }
+ if (flags[FLAG_UV1_USE_TRIPLANAR] || flags[FLAG_UV2_USE_TRIPLANAR]) {
+ code += ",world_vertex_coords";
+ }
code += ";\n";
code += "uniform vec4 albedo : hint_color;\n";
code += "uniform sampler2D texture_albedo : hint_albedo;\n";
code += "uniform float specular;\n";
code += "uniform float metallic;\n";
+ if (grow_enabled) {
+ code += "uniform float grow;\n";
+ }
code += "uniform float roughness : hint_range(0,1);\n";
code += "uniform float point_size : hint_range(0,128);\n";
code += "uniform sampler2D texture_metallic : hint_white;\n";
code += "uniform sampler2D texture_roughness : hint_white;\n";
- code += "uniform vec2 uv1_scale;\n";
- code += "uniform vec2 uv1_offset;\n";
- code += "uniform vec2 uv2_scale;\n";
- code += "uniform vec2 uv2_offset;\n";
if (billboard_mode == BILLBOARD_PARTICLES) {
code += "uniform int particles_anim_h_frames;\n";
code += "uniform int particles_anim_v_frames;\n";
@@ -371,6 +413,26 @@ void SpatialMaterial::_update_shader() {
code += "uniform int depth_min_layers;\n";
code += "uniform int depth_max_layers;\n";
}
+ if (flags[FLAG_UV1_USE_TRIPLANAR]) {
+ code += "varying vec3 uv1_world_pos;\n";
+ }
+ if (flags[FLAG_UV2_USE_TRIPLANAR]) {
+ code += "varying vec3 uv2_world_pos;\n";
+ }
+ if (flags[FLAG_UV1_USE_TRIPLANAR]) {
+ code += "uniform float uv1_blend_sharpness;\n";
+ code += "varying vec3 uv1_power_normal;\n";
+ }
+
+ if (flags[FLAG_UV2_USE_TRIPLANAR]) {
+ code += "uniform float uv2_blend_sharpness;\n";
+ code += "varying vec3 uv2_power_normal;\n";
+ }
+
+ code += "uniform vec3 uv1_scale;\n";
+ code += "uniform vec3 uv1_offset;\n";
+ code += "uniform vec3 uv2_scale;\n";
+ code += "uniform vec3 uv2_offset;\n";
code += "\n\n";
@@ -384,7 +446,15 @@ void SpatialMaterial::_update_shader() {
code += "\tPOINT_SIZE=point_size;\n";
}
- code += "\tUV=UV*uv1_scale+uv1_offset;\n";
+
+ if (flags[FLAG_USE_VERTEX_LIGHTING]) {
+
+ code += "\tROUGHNESS=roughness;\n";
+ }
+
+ if (!flags[FLAG_UV1_USE_TRIPLANAR]) {
+ code += "\tUV=UV*uv1_scale.xy+uv1_offset.xy;\n";
+ }
switch (billboard_mode) {
case BILLBOARD_DISABLED: {
@@ -414,7 +484,6 @@ void SpatialMaterial::_update_shader() {
//code += "\tUV+= UV * vec2(float(particle_frame % particles_anim_h_frames),float(particle_frame / particles_anim_v_frames));\n";
//handle rotation
// code += "\tmat4 rotation = mat4("
-
} break;
}
@@ -437,22 +506,67 @@ void SpatialMaterial::_update_shader() {
code += "\t}\n";
}
- if (detail_uv == DETAIL_UV_2) {
+ if (detail_uv == DETAIL_UV_2 && !flags[FLAG_UV2_USE_TRIPLANAR]) {
code += "\tUV2=UV2*uv2_scale+uv2_offset;\n";
}
+ if (flags[FLAG_UV1_USE_TRIPLANAR] || flags[FLAG_UV2_USE_TRIPLANAR]) {
+ //generate tangent and binormal in world space
+ code += "\tTANGENT = vec3(0.0,0.0,-1.0) * abs(NORMAL.x);\n";
+ code += "\tTANGENT+= vec3(1.0,0.0,0.0) * abs(NORMAL.y);\n";
+ code += "\tTANGENT+= vec3(1.0,0.0,0.0) * abs(NORMAL.z);\n";
+ code += "\tTANGENT = normalize(TANGENT);\n";
+
+ code += "\tBINORMAL = vec3(0.0,1.0,0.0) * abs(NORMAL.x);\n";
+ code += "\tBINORMAL+= vec3(0.0,0.0,-1.0) * abs(NORMAL.y);\n";
+ code += "\tBINORMAL+= vec3(0.0,1.0,0.0) * abs(NORMAL.z);\n";
+ code += "\tBINORMAL = normalize(BINORMAL);\n";
+ }
+
+ if (flags[FLAG_UV1_USE_TRIPLANAR]) {
+
+ code += "\tuv1_power_normal=pow(abs(NORMAL),vec3(uv1_blend_sharpness));\n";
+ code += "\tuv1_power_normal/=dot(uv1_power_normal,vec3(1.0));\n";
+ code += "\tuv1_world_pos = VERTEX * uv1_scale + uv1_offset;\n";
+ code += "\tuv1_world_pos *= vec3(1.0,-1.0, 1.0);\n";
+ }
+
+ if (flags[FLAG_UV2_USE_TRIPLANAR]) {
+
+ code += "\tuv2_power_normal=pow(abs(NORMAL), vec3(uv2_blend_sharpness));\n";
+ code += "\tuv2_power_normal/=dot(uv2_power_normal,vec3(1.0));\n";
+ code += "\tuv2_world_pos = VERTEX * uv2_scale + uv2_offset;\n";
+ code += "\tuv2_world_pos *= vec3(1.0,-1.0, 1.0);\n";
+ }
+
+ if (grow_enabled) {
+ code += "\tVERTEX+=NORMAL*grow;\n";
+ }
code += "}\n";
code += "\n\n";
+ if (flags[FLAG_UV1_USE_TRIPLANAR] || flags[FLAG_UV2_USE_TRIPLANAR]) {
+ code += "vec4 triplanar_texture(sampler2D p_sampler,vec3 p_weights,vec3 p_world_pos) {\n";
+ code += "\tvec4 samp=vec4(0.0);\n";
+ code += "\tsamp+= texture(p_sampler,p_world_pos.xy) * p_weights.z;\n";
+ code += "\tsamp+= texture(p_sampler,p_world_pos.xz) * p_weights.y;\n";
+ code += "\tsamp+= texture(p_sampler,p_world_pos.zy * vec2(-1.0,1.0)) * p_weights.x;\n";
+ code += "\treturn samp;\n";
+ code += "}\n";
+ }
+ code += "\n\n";
code += "void fragment() {\n";
- code += "\tvec2 base_uv = UV;\n";
- if (features[FEATURE_DETAIL] && detail_uv == DETAIL_UV_2) {
+ if (!flags[FLAG_UV1_USE_TRIPLANAR]) {
+ code += "\tvec2 base_uv = UV;\n";
+ }
+
+ if ((features[FEATURE_DETAIL] && detail_uv == DETAIL_UV_2) || (features[FEATURE_AMBIENT_OCCLUSION] && flags[FLAG_AO_ON_UV2])) {
code += "\tvec2 base_uv2 = UV2;\n";
}
- if (features[FEATURE_DEPTH_MAPPING]) {
+ if (features[FEATURE_DEPTH_MAPPING] && !flags[FLAG_UV1_USE_TRIPLANAR]) { //depthmap not supported with triplanar
code += "\t{\n";
- code += "\t\tvec3 view_dir = normalize(normalize(-VERTEX)*mat3(TANGENT,BINORMAL,NORMAL));\n";
+ code += "\t\tvec3 view_dir = normalize(normalize(-VERTEX)*mat3(TANGENT,-BINORMAL,NORMAL));\n"; //binormal is negative due to mikktpsace
if (deep_parallax) {
code += "\t\tfloat num_layers = mix(float(depth_max_layers),float(depth_min_layers), abs(dot(vec3(0.0, 0.0, 1.0), view_dir)));\n";
@@ -490,7 +604,11 @@ void SpatialMaterial::_update_shader() {
if (flags[FLAG_USE_POINT_SIZE]) {
code += "\tvec4 albedo_tex = texture(texture_albedo,POINT_COORD);\n";
} else {
- code += "\tvec4 albedo_tex = texture(texture_albedo,base_uv);\n";
+ if (flags[FLAG_UV1_USE_TRIPLANAR]) {
+ code += "\tvec4 albedo_tex = triplanar_texture(texture_albedo,uv1_power_normal,uv1_world_pos);\n";
+ } else {
+ code += "\tvec4 albedo_tex = texture(texture_albedo,base_uv);\n";
+ }
}
if (flags[FLAG_ALBEDO_FROM_VERTEX_COLOR]) {
@@ -498,22 +616,39 @@ void SpatialMaterial::_update_shader() {
}
code += "\tALBEDO = albedo.rgb * albedo_tex.rgb;\n";
- code += "\tfloat metallic_tex = texture(texture_metallic,base_uv).r;\n";
+ if (flags[FLAG_UV1_USE_TRIPLANAR]) {
+ code += "\tfloat metallic_tex = triplanar_texture(texture_metallic,uv1_power_normal,uv1_world_pos).r;\n";
+ } else {
+ code += "\tfloat metallic_tex = texture(texture_metallic,base_uv).r;\n";
+ }
code += "\tMETALLIC = metallic_tex * metallic;\n";
- code += "\tfloat roughness_tex = texture(texture_roughness,base_uv).r;\n";
+ if (flags[FLAG_UV1_USE_TRIPLANAR]) {
+ code += "\tfloat roughness_tex = triplanar_texture(texture_roughness,uv1_power_normal,uv1_world_pos).r;\n";
+ } else {
+ code += "\tfloat roughness_tex = texture(texture_roughness,base_uv).r;\n";
+ }
code += "\tROUGHNESS = roughness_tex * roughness;\n";
code += "\tSPECULAR = specular;\n";
if (features[FEATURE_NORMAL_MAPPING]) {
- code += "\tNORMALMAP = texture(texture_normal,base_uv).rgb;\n";
+ if (flags[FLAG_UV1_USE_TRIPLANAR]) {
+ code += "\tNORMALMAP = triplanar_texture(texture_normal,uv1_power_normal,uv1_world_pos).rgb;\n";
+ } else {
+ code += "\tNORMALMAP = texture(texture_normal,base_uv).rgb;\n";
+ }
code += "\tNORMALMAP_DEPTH = normal_scale;\n";
}
if (features[FEATURE_EMISSION]) {
- code += "\tEMISSION = (emission.rgb+texture(texture_emission,base_uv).rgb)*emission_energy;\n";
+ if (flags[FLAG_UV1_USE_TRIPLANAR]) {
+ code += "\tvec3 emission_tex = triplanar_texture(texture_emission,uv1_power_normal,uv1_world_pos).rgb;\n";
+ } else {
+ code += "\tvec3 emission_tex = texture(texture_emission,base_uv).rgb;\n";
+ }
+ code += "\tEMISSION = (emission.rgb+emission_tex)*emission_energy;\n";
}
- if (features[FEATURE_REFRACTION]) {
+ if (features[FEATURE_REFRACTION] && !flags[FLAG_UV1_USE_TRIPLANAR]) { //refraction not supported with triplanar
if (features[FEATURE_NORMAL_MAPPING]) {
code += "\tvec3 ref_normal = normalize( mix(NORMAL,TANGENT * NORMALMAP.x + BINORMAL * NORMALMAP.y + NORMAL * NORMALMAP.z,NORMALMAP_DEPTH) ) * SIDE;\n";
@@ -532,38 +667,82 @@ void SpatialMaterial::_update_shader() {
}
if (features[FEATURE_RIM]) {
- code += "\tvec2 rim_tex = texture(texture_rim,base_uv).xw;\n";
+ if (flags[FLAG_UV1_USE_TRIPLANAR]) {
+ code += "\tvec2 rim_tex = triplanar_texture(texture_rim,uv1_power_normal,uv1_world_pos).xy;\n";
+ } else {
+ code += "\tvec2 rim_tex = texture(texture_rim,base_uv).xy;\n";
+ }
code += "\tRIM = rim*rim_tex.x;";
code += "\tRIM_TINT = rim_tint*rim_tex.y;\n";
}
if (features[FEATURE_CLEARCOAT]) {
- code += "\tvec2 clearcoat_tex = texture(texture_clearcoat,base_uv).xw;\n";
+ if (flags[FLAG_UV1_USE_TRIPLANAR]) {
+ code += "\tvec2 clearcoat_tex = triplanar_texture(texture_clearcoat,uv1_power_normal,uv1_world_pos).xy;\n";
+ } else {
+ code += "\tvec2 clearcoat_tex = texture(texture_clearcoat,base_uv).xy;\n";
+ }
code += "\tCLEARCOAT = clearcoat*clearcoat_tex.x;";
code += "\tCLEARCOAT_GLOSS = clearcoat_gloss*clearcoat_tex.y;\n";
}
if (features[FEATURE_ANISOTROPY]) {
- code += "\tvec4 anisotropy_tex = texture(texture_flowmap,base_uv);\n";
- code += "\tANISOTROPY = anisotropy_ratio*anisotropy_tex.a;\n";
+ if (flags[FLAG_UV1_USE_TRIPLANAR]) {
+ code += "\tvec3 anisotropy_tex = triplanar_texture(texture_flowmap,uv1_power_normal,uv1_world_pos).rga;\n";
+ } else {
+ code += "\tvec3 anisotropy_tex = texture(texture_flowmap,base_uv).rga;\n";
+ }
+ code += "\tANISOTROPY = anisotropy_ratio*anisotropy_tex.b;\n";
code += "\tANISOTROPY_FLOW = anisotropy_tex.rg*2.0-1.0;\n";
}
if (features[FEATURE_AMBIENT_OCCLUSION]) {
- code += "\tAO = texture(texture_ambient_occlusion,base_uv).r;\n";
+ if (flags[FLAG_AO_ON_UV2]) {
+ if (flags[FLAG_UV2_USE_TRIPLANAR]) {
+ code += "\tAO = triplanar_texture(texture_ambient_occlusion,uv2_power_normal,uv2_world_pos).r;\n";
+ } else {
+ code += "\tAO = texture(texture_ambient_occlusion,base_uv2).r;\n";
+ }
+ } else {
+ if (flags[FLAG_UV1_USE_TRIPLANAR]) {
+ code += "\tAO = triplanar_texture(texture_ambient_occlusion,uv1_power_normal,uv1_world_pos).r;\n";
+ } else {
+ code += "\tAO = texture(texture_ambient_occlusion,base_uv).r;\n";
+ }
+ }
}
if (features[FEATURE_SUBSURACE_SCATTERING]) {
- code += "\tfloat sss_tex = texture(texture_subsurface_scattering,base_uv).r;\n";
+ if (flags[FLAG_UV1_USE_TRIPLANAR]) {
+ code += "\tfloat sss_tex = triplanar_texture(texture_subsurface_scattering,uv1_power_normal,uv1_world_pos).r;\n";
+ } else {
+ code += "\tfloat sss_tex = texture(texture_subsurface_scattering,base_uv).r;\n";
+ }
code += "\tSSS_STRENGTH=subsurface_scattering_strength*sss_tex;\n";
}
if (features[FEATURE_DETAIL]) {
- String det_uv = detail_uv == DETAIL_UV_1 ? "base_uv" : "base_uv2";
- code += "\tvec4 detail_tex = texture(texture_detail_albedo," + det_uv + ");\n";
- code += "\tvec4 detail_norm_tex = texture(texture_detail_normal," + det_uv + ");\n";
- code += "\tvec4 detail_mask_tex = texture(texture_detail_mask,base_uv);\n";
+
+ bool triplanar = (flags[FLAG_UV1_USE_TRIPLANAR] && detail_uv == DETAIL_UV_1) || (flags[FLAG_UV2_USE_TRIPLANAR] && detail_uv == DETAIL_UV_2);
+
+ if (triplanar) {
+ String tp_uv = detail_uv == DETAIL_UV_1 ? "uv1" : "uv2";
+ code += "\tvec4 detail_tex = triplanar_texture(texture_detail_albedo," + tp_uv + "_power_normal," + tp_uv + "_world_pos);\n";
+ code += "\tvec4 detail_norm_tex = triplanar_texture(texture_detail_normal," + tp_uv + "_power_normal," + tp_uv + "_world_pos);\n";
+
+ } else {
+ String det_uv = detail_uv == DETAIL_UV_1 ? "base_uv" : "base_uv2";
+ code += "\tvec4 detail_tex = texture(texture_detail_albedo," + det_uv + ");\n";
+ code += "\tvec4 detail_norm_tex = texture(texture_detail_normal," + det_uv + ");\n";
+ }
+
+ if (flags[FLAG_UV1_USE_TRIPLANAR]) {
+
+ code += "\tvec4 detail_mask_tex = triplanar_texture(texture_detail_mask,uv1_power_normal);\n";
+ } else {
+ code += "\tvec4 detail_mask_tex = texture(texture_detail_mask,base_uv);\n";
+ }
switch (detail_blend_mode) {
case BLEND_MODE_MIX: {
@@ -581,7 +760,6 @@ void SpatialMaterial::_update_shader() {
}
code += "\tvec3 detail_norm = mix(NORMALMAP,detail_norm_tex.rgb,detail_tex.a);\n";
-
code += "\tNORMALMAP = mix(NORMALMAP,detail_norm,detail_mask_tex.r);\n";
code += "\tALBEDO.rgb = mix(ALBEDO.rgb,detail,detail_mask_tex.r);\n";
}
@@ -875,6 +1053,19 @@ SpatialMaterial::DiffuseMode SpatialMaterial::get_diffuse_mode() const {
return diffuse_mode;
}
+void SpatialMaterial::set_specular_mode(SpecularMode p_mode) {
+
+ if (specular_mode == p_mode)
+ return;
+
+ specular_mode = p_mode;
+ _queue_shader_change();
+}
+SpatialMaterial::SpecularMode SpatialMaterial::get_specular_mode() const {
+
+ return specular_mode;
+}
+
void SpatialMaterial::set_flag(Flags p_flag, bool p_enabled) {
ERR_FAIL_INDEX(p_flag, FLAG_MAX);
@@ -947,6 +1138,10 @@ void SpatialMaterial::_validate_property(PropertyInfo &property) const {
if (property.name.begins_with("particles_anim_") && billboard_mode != BILLBOARD_PARTICLES) {
property.usage = 0;
}
+
+ if (property.name == "params_grow_amount" && !grow_enabled) {
+ property.usage = 0;
+ }
}
void SpatialMaterial::set_line_width(float p_line_width) {
@@ -971,49 +1166,71 @@ float SpatialMaterial::get_point_size() const {
return point_size;
}
-void SpatialMaterial::set_uv1_scale(const Vector2 &p_scale) {
+void SpatialMaterial::set_uv1_scale(const Vector3 &p_scale) {
uv1_scale = p_scale;
VS::get_singleton()->material_set_param(_get_material(), shader_names->uv1_scale, p_scale);
}
-Vector2 SpatialMaterial::get_uv1_scale() const {
+Vector3 SpatialMaterial::get_uv1_scale() const {
return uv1_scale;
}
-void SpatialMaterial::set_uv1_offset(const Vector2 &p_offset) {
+void SpatialMaterial::set_uv1_offset(const Vector3 &p_offset) {
uv1_offset = p_offset;
VS::get_singleton()->material_set_param(_get_material(), shader_names->uv1_offset, p_offset);
}
-Vector2 SpatialMaterial::get_uv1_offset() const {
+Vector3 SpatialMaterial::get_uv1_offset() const {
return uv1_offset;
}
-void SpatialMaterial::set_uv2_scale(const Vector2 &p_scale) {
+void SpatialMaterial::set_uv1_triplanar_blend_sharpness(float p_sharpness) {
+
+ uv1_triplanar_sharpness = p_sharpness;
+ VS::get_singleton()->material_set_param(_get_material(), shader_names->uv1_blend_sharpness, p_sharpness);
+}
+
+float SpatialMaterial::get_uv1_triplanar_blend_sharpness() const {
+
+ return uv1_triplanar_sharpness;
+}
+
+void SpatialMaterial::set_uv2_scale(const Vector3 &p_scale) {
uv2_scale = p_scale;
VS::get_singleton()->material_set_param(_get_material(), shader_names->uv2_scale, p_scale);
}
-Vector2 SpatialMaterial::get_uv2_scale() const {
+Vector3 SpatialMaterial::get_uv2_scale() const {
return uv2_scale;
}
-void SpatialMaterial::set_uv2_offset(const Vector2 &p_offset) {
+void SpatialMaterial::set_uv2_offset(const Vector3 &p_offset) {
uv2_offset = p_offset;
VS::get_singleton()->material_set_param(_get_material(), shader_names->uv2_offset, p_offset);
}
-Vector2 SpatialMaterial::get_uv2_offset() const {
+Vector3 SpatialMaterial::get_uv2_offset() const {
return uv2_offset;
}
+void SpatialMaterial::set_uv2_triplanar_blend_sharpness(float p_sharpness) {
+
+ uv2_triplanar_sharpness = p_sharpness;
+ VS::get_singleton()->material_set_param(_get_material(), shader_names->uv2_blend_sharpness, p_sharpness);
+}
+
+float SpatialMaterial::get_uv2_triplanar_blend_sharpness() const {
+
+ return uv2_triplanar_sharpness;
+}
+
void SpatialMaterial::set_billboard_mode(BillboardMode p_mode) {
billboard_mode = p_mode;
@@ -1063,7 +1280,6 @@ void SpatialMaterial::set_depth_deep_parallax(bool p_enable) {
deep_parallax = p_enable;
_queue_shader_change();
_change_notify();
- ;
}
bool SpatialMaterial::is_depth_deep_parallax_enabled() const {
@@ -1091,6 +1307,26 @@ int SpatialMaterial::get_depth_deep_parallax_max_layers() const {
return deep_parallax_max_layers;
}
+void SpatialMaterial::set_grow_enabled(bool p_enable) {
+ grow_enabled = p_enable;
+ _queue_shader_change();
+ _change_notify();
+}
+
+bool SpatialMaterial::is_grow_enabled() const {
+ return grow_enabled;
+}
+
+void SpatialMaterial::set_grow(float p_grow) {
+ grow = p_grow;
+ VS::get_singleton()->material_set_param(_get_material(), shader_names->grow, p_grow);
+}
+
+float SpatialMaterial::get_grow() const {
+
+ return grow;
+}
+
void SpatialMaterial::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_albedo", "albedo"), &SpatialMaterial::set_albedo);
@@ -1159,14 +1395,17 @@ void SpatialMaterial::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_diffuse_mode", "diffuse_mode"), &SpatialMaterial::set_diffuse_mode);
ClassDB::bind_method(D_METHOD("get_diffuse_mode"), &SpatialMaterial::get_diffuse_mode);
+ ClassDB::bind_method(D_METHOD("set_specular_mode", "specular_mode"), &SpatialMaterial::set_specular_mode);
+ ClassDB::bind_method(D_METHOD("get_specular_mode"), &SpatialMaterial::get_specular_mode);
+
ClassDB::bind_method(D_METHOD("set_flag", "flag", "enable"), &SpatialMaterial::set_flag);
- ClassDB::bind_method(D_METHOD("get_flag"), &SpatialMaterial::get_flag);
+ ClassDB::bind_method(D_METHOD("get_flag", "flag"), &SpatialMaterial::get_flag);
ClassDB::bind_method(D_METHOD("set_feature", "feature", "enable"), &SpatialMaterial::set_feature);
ClassDB::bind_method(D_METHOD("get_feature", "feature"), &SpatialMaterial::get_feature);
- ClassDB::bind_method(D_METHOD("set_texture", "param:Texture", "texture"), &SpatialMaterial::set_texture);
- ClassDB::bind_method(D_METHOD("get_texture:Texture", "param:Texture"), &SpatialMaterial::get_texture);
+ ClassDB::bind_method(D_METHOD("set_texture", "param", "texture:Texture"), &SpatialMaterial::set_texture);
+ ClassDB::bind_method(D_METHOD("get_texture:Texture", "param"), &SpatialMaterial::get_texture);
ClassDB::bind_method(D_METHOD("set_detail_blend_mode", "detail_blend_mode"), &SpatialMaterial::set_detail_blend_mode);
ClassDB::bind_method(D_METHOD("get_detail_blend_mode"), &SpatialMaterial::get_detail_blend_mode);
@@ -1177,12 +1416,18 @@ void SpatialMaterial::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_uv1_offset", "offset"), &SpatialMaterial::set_uv1_offset);
ClassDB::bind_method(D_METHOD("get_uv1_offset"), &SpatialMaterial::get_uv1_offset);
+ ClassDB::bind_method(D_METHOD("set_uv1_triplanar_blend_sharpness", "sharpness"), &SpatialMaterial::set_uv1_triplanar_blend_sharpness);
+ ClassDB::bind_method(D_METHOD("get_uv1_triplanar_blend_sharpness"), &SpatialMaterial::get_uv1_triplanar_blend_sharpness);
+
ClassDB::bind_method(D_METHOD("set_uv2_scale", "scale"), &SpatialMaterial::set_uv2_scale);
ClassDB::bind_method(D_METHOD("get_uv2_scale"), &SpatialMaterial::get_uv2_scale);
ClassDB::bind_method(D_METHOD("set_uv2_offset", "offset"), &SpatialMaterial::set_uv2_offset);
ClassDB::bind_method(D_METHOD("get_uv2_offset"), &SpatialMaterial::get_uv2_offset);
+ ClassDB::bind_method(D_METHOD("set_uv2_triplanar_blend_sharpness", "sharpness"), &SpatialMaterial::set_uv2_triplanar_blend_sharpness);
+ ClassDB::bind_method(D_METHOD("get_uv2_triplanar_blend_sharpness"), &SpatialMaterial::get_uv2_triplanar_blend_sharpness);
+
ClassDB::bind_method(D_METHOD("set_billboard_mode", "mode"), &SpatialMaterial::set_billboard_mode);
ClassDB::bind_method(D_METHOD("get_billboard_mode"), &SpatialMaterial::get_billboard_mode);
@@ -1204,9 +1449,16 @@ void SpatialMaterial::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_depth_deep_parallax_max_layers", "layer"), &SpatialMaterial::set_depth_deep_parallax_max_layers);
ClassDB::bind_method(D_METHOD("get_depth_deep_parallax_max_layers"), &SpatialMaterial::get_depth_deep_parallax_max_layers);
+ ClassDB::bind_method(D_METHOD("set_grow", "amount"), &SpatialMaterial::set_grow);
+ ClassDB::bind_method(D_METHOD("get_grow"), &SpatialMaterial::get_grow);
+
+ ClassDB::bind_method(D_METHOD("set_grow_enabled", "enable"), &SpatialMaterial::set_grow_enabled);
+ ClassDB::bind_method(D_METHOD("is_grow_enabled"), &SpatialMaterial::is_grow_enabled);
+
ADD_GROUP("Flags", "flags_");
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "flags_transparent"), "set_feature", "get_feature", FEATURE_TRANSPARENT);
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "flags_unshaded"), "set_flag", "get_flag", FLAG_UNSHADED);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "flags_vertex_lighting"), "set_flag", "get_flag", FLAG_USE_VERTEX_LIGHTING);
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "flags_on_top"), "set_flag", "get_flag", FLAG_ONTOP);
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "flags_use_point_size"), "set_flag", "get_flag", FLAG_USE_POINT_SIZE);
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "flags_fixed_size"), "set_flag", "get_flag", FLAG_FIXED_SIZE);
@@ -1215,13 +1467,16 @@ void SpatialMaterial::_bind_methods() {
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "vertex_color_is_srgb"), "set_flag", "get_flag", FLAG_SRGB_VERTEX_COLOR);
ADD_GROUP("Parameters", "params_");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "params_diffuse_mode", PROPERTY_HINT_ENUM, "Lambert,Lambert Wrap,Oren Nayar,Burley"), "set_diffuse_mode", "get_diffuse_mode");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "params_diffuse_mode", PROPERTY_HINT_ENUM, "Lambert,Lambert Wrap,Oren Nayar,Burley,Toon"), "set_diffuse_mode", "get_diffuse_mode");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "params_specular_mode", PROPERTY_HINT_ENUM, "SchlickGGX,Blinn,Phong,Toon,Disabled"), "set_specular_mode", "get_specular_mode");
ADD_PROPERTY(PropertyInfo(Variant::INT, "params_blend_mode", PROPERTY_HINT_ENUM, "Mix,Add,Sub,Mul"), "set_blend_mode", "get_blend_mode");
ADD_PROPERTY(PropertyInfo(Variant::INT, "params_cull_mode", PROPERTY_HINT_ENUM, "Back,Front,Disabled"), "set_cull_mode", "get_cull_mode");
ADD_PROPERTY(PropertyInfo(Variant::INT, "params_depth_draw_mode", PROPERTY_HINT_ENUM, "Opaque Only,Always,Never,Opaque Pre-Pass"), "set_depth_draw_mode", "get_depth_draw_mode");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "params_line_width", PROPERTY_HINT_RANGE, "0.1,128,0.1"), "set_line_width", "get_line_width");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "params_point_size", PROPERTY_HINT_RANGE, "0.1,128,0.1"), "set_point_size", "get_point_size");
ADD_PROPERTY(PropertyInfo(Variant::INT, "params_billboard_mode", PROPERTY_HINT_ENUM, "Disabled,Enabled,Y-Billboard,Particle Billboard"), "set_billboard_mode", "get_billboard_mode");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "params_grow"), "set_grow_enabled", "is_grow_enabled");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "params_grow_amount", PROPERTY_HINT_RANGE, "-16,10,0.01"), "set_grow", "get_grow");
ADD_GROUP("Particles Anim", "particles_anim_");
ADD_PROPERTY(PropertyInfo(Variant::INT, "particles_anim_h_frames", PROPERTY_HINT_RANGE, "1,128,1"), "set_particles_anim_h_frames", "get_particles_anim_h_frames");
ADD_PROPERTY(PropertyInfo(Variant::INT, "particles_anim_v_frames", PROPERTY_HINT_RANGE, "1,128,1"), "set_particles_anim_v_frames", "get_particles_anim_v_frames");
@@ -1265,12 +1520,13 @@ void SpatialMaterial::_bind_methods() {
ADD_GROUP("Anisotropy", "anisotropy_");
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "anisotropy_enabled"), "set_feature", "get_feature", FEATURE_ANISOTROPY);
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "anisotropy", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_anisotropy", "get_anisotropy");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "anisotropy", PROPERTY_HINT_RANGE, "-1,1,0.01"), "set_anisotropy", "get_anisotropy");
ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "anisotropy_flowmap", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture", TEXTURE_FLOWMAP);
ADD_GROUP("Ambient Occlusion", "ao_");
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "ao_enabled"), "set_feature", "get_feature", FEATURE_AMBIENT_OCCLUSION);
ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "ao_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture", TEXTURE_AMBIENT_OCCLUSION);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "ao_on_uv2"), "set_flag", "get_flag", FLAG_AO_ON_UV2);
ADD_GROUP("Depth", "depth_");
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "depth_enabled"), "set_feature", "get_feature", FEATURE_DEPTH_MAPPING);
@@ -1299,12 +1555,16 @@ void SpatialMaterial::_bind_methods() {
ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "detail_normal", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture", TEXTURE_DETAIL_NORMAL);
ADD_GROUP("UV1", "uv1_");
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "uv1_scale"), "set_uv1_scale", "get_uv1_scale");
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "uv1_offset"), "set_uv1_offset", "get_uv1_offset");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "uv1_scale"), "set_uv1_scale", "get_uv1_scale");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "uv1_offset"), "set_uv1_offset", "get_uv1_offset");
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "uv1_triplanar"), "set_flag", "get_flag", FLAG_UV1_USE_TRIPLANAR);
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "uv1_triplanar_sharpness", PROPERTY_HINT_EXP_EASING), "set_uv1_triplanar_blend_sharpness", "get_uv1_triplanar_blend_sharpness");
ADD_GROUP("UV2", "uv2_");
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "uv2_scale"), "set_uv2_scale", "get_uv2_scale");
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "uv2_offset"), "set_uv2_offset", "get_uv2_offset");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "uv2_scale"), "set_uv2_scale", "get_uv2_scale");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "uv2_offset"), "set_uv2_offset", "get_uv2_offset");
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "uv2_triplanar"), "set_flag", "get_flag", FLAG_UV2_USE_TRIPLANAR);
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "uv2_triplanar_sharpness", PROPERTY_HINT_EXP_EASING), "set_uv2_triplanar_blend_sharpness", "get_uv2_triplanar_blend_sharpness");
BIND_CONSTANT(TEXTURE_ALBEDO);
BIND_CONSTANT(TEXTURE_METALLIC);
@@ -1354,6 +1614,7 @@ void SpatialMaterial::_bind_methods() {
BIND_CONSTANT(CULL_DISABLED);
BIND_CONSTANT(FLAG_UNSHADED);
+ BIND_CONSTANT(FLAG_USE_VERTEX_LIGHTING);
BIND_CONSTANT(FLAG_ONTOP);
BIND_CONSTANT(FLAG_ALBEDO_FROM_VERTEX_COLOR);
BIND_CONSTANT(FLAG_SRGB_VERTEX_COLOR)
@@ -1365,6 +1626,13 @@ void SpatialMaterial::_bind_methods() {
BIND_CONSTANT(DIFFUSE_HALF_LAMBERT);
BIND_CONSTANT(DIFFUSE_OREN_NAYAR);
BIND_CONSTANT(DIFFUSE_BURLEY);
+ BIND_CONSTANT(DIFFUSE_TOON);
+
+ BIND_CONSTANT(SPECULAR_SCHLICK_GGX);
+ BIND_CONSTANT(SPECULAR_BLINN);
+ BIND_CONSTANT(SPECULAR_PHONG);
+ BIND_CONSTANT(SPECULAR_TOON);
+ BIND_CONSTANT(SPECULAR_DISABLED);
BIND_CONSTANT(BILLBOARD_DISABLED);
BIND_CONSTANT(BILLBOARD_ENABLED);
@@ -1393,15 +1661,20 @@ SpatialMaterial::SpatialMaterial()
set_refraction(0.05);
set_line_width(1);
set_point_size(1);
- set_uv1_offset(Vector2(0, 0));
- set_uv1_scale(Vector2(1, 1));
- set_uv2_offset(Vector2(0, 0));
- set_uv2_scale(Vector2(1, 1));
+ set_uv1_offset(Vector3(0, 0, 0));
+ set_uv1_scale(Vector3(1, 1, 1));
+ set_uv1_triplanar_blend_sharpness(1);
+ set_uv2_offset(Vector3(0, 0, 0));
+ set_uv2_scale(Vector3(1, 1, 1));
+ set_uv2_triplanar_blend_sharpness(1);
set_billboard_mode(BILLBOARD_DISABLED);
set_particles_anim_h_frames(1);
set_particles_anim_v_frames(1);
set_particles_anim_loop(false);
+ grow_enabled = false;
+ set_grow(0.0);
+
deep_parallax = false;
set_depth_deep_parallax_min_layers(8);
set_depth_deep_parallax_max_layers(32);
@@ -1415,6 +1688,7 @@ SpatialMaterial::SpatialMaterial()
flags[i] = 0;
}
diffuse_mode = DIFFUSE_LAMBERT;
+ specular_mode = SPECULAR_SCHLICK_GGX;
for (int i = 0; i < FEATURE_MAX; i++) {
features[i] = false;
diff --git a/scene/resources/material.h b/scene/resources/material.h
index fb6c5b81d9..7587fc7927 100644
--- a/scene/resources/material.h
+++ b/scene/resources/material.h
@@ -47,11 +47,16 @@ class Material : public Resource {
OBJ_SAVE_TYPE(Material)
RID material;
+ Ref<Material> next_pass;
protected:
_FORCE_INLINE_ RID _get_material() const { return material; }
+ static void _bind_methods();
public:
+ void set_next_pass(const Ref<Material> &p_pass);
+ Ref<Material> get_next_pass() const;
+
virtual RID get_rid() const;
Material();
virtual ~Material();
@@ -150,11 +155,15 @@ public:
enum Flags {
FLAG_UNSHADED,
+ FLAG_USE_VERTEX_LIGHTING,
FLAG_ONTOP,
FLAG_ALBEDO_FROM_VERTEX_COLOR,
FLAG_SRGB_VERTEX_COLOR,
FLAG_USE_POINT_SIZE,
FLAG_FIXED_SIZE,
+ FLAG_UV1_USE_TRIPLANAR,
+ FLAG_UV2_USE_TRIPLANAR,
+ FLAG_AO_ON_UV2,
FLAG_MAX
};
@@ -163,6 +172,15 @@ public:
DIFFUSE_HALF_LAMBERT,
DIFFUSE_OREN_NAYAR,
DIFFUSE_BURLEY,
+ DIFFUSE_TOON,
+ };
+
+ enum SpecularMode {
+ SPECULAR_SCHLICK_GGX,
+ SPECULAR_BLINN,
+ SPECULAR_PHONG,
+ SPECULAR_TOON,
+ SPECULAR_DISABLED,
};
enum BillboardMode {
@@ -176,20 +194,22 @@ private:
union MaterialKey {
struct {
- uint32_t feature_mask : 11;
- uint32_t detail_uv : 1;
- uint32_t blend_mode : 2;
- uint32_t depth_draw_mode : 2;
- uint32_t cull_mode : 2;
- uint32_t flags : 6;
- uint32_t detail_blend_mode : 2;
- uint32_t diffuse_mode : 2;
- uint32_t invalid_key : 1;
- uint32_t deep_parallax : 1;
- uint32_t billboard_mode : 2;
+ uint64_t feature_mask : 11;
+ uint64_t detail_uv : 1;
+ uint64_t blend_mode : 2;
+ uint64_t depth_draw_mode : 2;
+ uint64_t cull_mode : 2;
+ uint64_t flags : 9;
+ uint64_t detail_blend_mode : 2;
+ uint64_t diffuse_mode : 3;
+ uint64_t specular_mode : 2;
+ uint64_t invalid_key : 1;
+ uint64_t deep_parallax : 1;
+ uint64_t billboard_mode : 2;
+ uint64_t grow : 1;
};
- uint32_t key;
+ uint64_t key;
bool operator<(const MaterialKey &p_key) const {
return key < p_key.key;
@@ -225,9 +245,10 @@ private:
}
mk.detail_blend_mode = detail_blend_mode;
mk.diffuse_mode = diffuse_mode;
+ mk.specular_mode = specular_mode;
mk.billboard_mode = billboard_mode;
mk.deep_parallax = deep_parallax ? 1 : 0;
- ;
+ mk.grow = grow_enabled;
return mk;
}
@@ -258,6 +279,9 @@ private:
StringName particles_anim_loop;
StringName depth_min_layers;
StringName depth_max_layers;
+ StringName uv1_blend_sharpness;
+ StringName uv2_blend_sharpness;
+ StringName grow;
StringName texture_names[TEXTURE_MAX];
};
@@ -289,15 +313,19 @@ private:
float refraction;
float line_width;
float point_size;
+ bool grow_enabled;
+ float grow;
int particles_anim_h_frames;
int particles_anim_v_frames;
bool particles_anim_loop;
- Vector2 uv1_scale;
- Vector2 uv1_offset;
+ Vector3 uv1_scale;
+ Vector3 uv1_offset;
+ float uv1_triplanar_sharpness;
- Vector2 uv2_scale;
- Vector2 uv2_offset;
+ Vector3 uv2_scale;
+ Vector3 uv2_offset;
+ float uv2_triplanar_sharpness;
DetailUV detail_uv;
@@ -310,6 +338,7 @@ private:
DepthDrawMode depth_draw_mode;
CullMode cull_mode;
bool flags[FLAG_MAX];
+ SpecularMode specular_mode;
DiffuseMode diffuse_mode;
BillboardMode billboard_mode;
@@ -402,6 +431,9 @@ public:
void set_diffuse_mode(DiffuseMode p_mode);
DiffuseMode get_diffuse_mode() const;
+ void set_specular_mode(SpecularMode p_mode);
+ SpecularMode get_specular_mode() const;
+
void set_flag(Flags p_flag, bool p_enabled);
bool get_flag(Flags p_flag) const;
@@ -411,17 +443,23 @@ public:
void set_feature(Feature p_feature, bool p_enabled);
bool get_feature(Feature p_feature) const;
- void set_uv1_scale(const Vector2 &p_scale);
- Vector2 get_uv1_scale() const;
+ void set_uv1_scale(const Vector3 &p_scale);
+ Vector3 get_uv1_scale() const;
- void set_uv1_offset(const Vector2 &p_offset);
- Vector2 get_uv1_offset() const;
+ void set_uv1_offset(const Vector3 &p_offset);
+ Vector3 get_uv1_offset() const;
- void set_uv2_scale(const Vector2 &p_scale);
- Vector2 get_uv2_scale() const;
+ void set_uv1_triplanar_blend_sharpness(float p_sharpness);
+ float get_uv1_triplanar_blend_sharpness() const;
- void set_uv2_offset(const Vector2 &p_offset);
- Vector2 get_uv2_offset() const;
+ void set_uv2_scale(const Vector3 &p_scale);
+ Vector3 get_uv2_scale() const;
+
+ void set_uv2_offset(const Vector3 &p_offset);
+ Vector3 get_uv2_offset() const;
+
+ void set_uv2_triplanar_blend_sharpness(float p_sharpness);
+ float get_uv2_triplanar_blend_sharpness() const;
void set_billboard_mode(BillboardMode p_mode);
BillboardMode get_billboard_mode() const;
@@ -434,6 +472,12 @@ public:
void set_particles_anim_loop(int p_frames);
int get_particles_anim_loop() const;
+ void set_grow_enabled(bool p_enable);
+ bool is_grow_enabled() const;
+
+ void set_grow(float p_grow);
+ float get_grow() const;
+
static void init_shaders();
static void finish_shaders();
static void flush_changes();
@@ -450,6 +494,7 @@ VARIANT_ENUM_CAST(SpatialMaterial::DepthDrawMode)
VARIANT_ENUM_CAST(SpatialMaterial::CullMode)
VARIANT_ENUM_CAST(SpatialMaterial::Flags)
VARIANT_ENUM_CAST(SpatialMaterial::DiffuseMode)
+VARIANT_ENUM_CAST(SpatialMaterial::SpecularMode)
VARIANT_ENUM_CAST(SpatialMaterial::BillboardMode)
//////////////////////
diff --git a/scene/resources/mesh.cpp b/scene/resources/mesh.cpp
index ef7011b2af..310ab5e371 100644
--- a/scene/resources/mesh.cpp
+++ b/scene/resources/mesh.cpp
@@ -32,7 +32,7 @@
#include "scene/resources/convex_polygon_shape.h"
#include "surface_tool.h"
-void Mesh::_clear_triangle_mesh() {
+void Mesh::_clear_triangle_mesh() const {
triangle_mesh.unref();
;
@@ -413,6 +413,17 @@ Ref<Mesh> Mesh::create_outline(float p_margin) const {
return newmesh;
}
+void Mesh::_bind_methods() {
+
+ BIND_CONSTANT(PRIMITIVE_POINTS);
+ BIND_CONSTANT(PRIMITIVE_LINES);
+ BIND_CONSTANT(PRIMITIVE_LINE_STRIP);
+ BIND_CONSTANT(PRIMITIVE_LINE_LOOP);
+ BIND_CONSTANT(PRIMITIVE_TRIANGLES);
+ BIND_CONSTANT(PRIMITIVE_TRIANGLE_STRIP);
+ BIND_CONSTANT(PRIMITIVE_TRIANGLE_FAN);
+}
+
Mesh::Mesh() {
}
@@ -1034,14 +1045,6 @@ void ArrayMesh::_bind_methods() {
BIND_CONSTANT(ARRAY_FORMAT_BONES);
BIND_CONSTANT(ARRAY_FORMAT_WEIGHTS);
BIND_CONSTANT(ARRAY_FORMAT_INDEX);
-
- BIND_CONSTANT(PRIMITIVE_POINTS);
- BIND_CONSTANT(PRIMITIVE_LINES);
- BIND_CONSTANT(PRIMITIVE_LINE_STRIP);
- BIND_CONSTANT(PRIMITIVE_LINE_LOOP);
- BIND_CONSTANT(PRIMITIVE_TRIANGLES);
- BIND_CONSTANT(PRIMITIVE_TRIANGLE_STRIP);
- BIND_CONSTANT(PRIMITIVE_TRIANGLE_FAN);
}
ArrayMesh::ArrayMesh() {
diff --git a/scene/resources/mesh.h b/scene/resources/mesh.h
index f716b59fe9..e40ef99237 100644
--- a/scene/resources/mesh.h
+++ b/scene/resources/mesh.h
@@ -44,7 +44,9 @@ class Mesh : public Resource {
mutable Ref<TriangleMesh> triangle_mesh; //cached
protected:
- void _clear_triangle_mesh();
+ void _clear_triangle_mesh() const;
+
+ static void _bind_methods();
public:
enum {
diff --git a/scene/resources/mesh_data_tool.cpp b/scene/resources/mesh_data_tool.cpp
index dc3713fb57..5dc596abff 100644
--- a/scene/resources/mesh_data_tool.cpp
+++ b/scene/resources/mesh_data_tool.cpp
@@ -520,8 +520,8 @@ void MeshDataTool::set_material(const Ref<Material> &p_material) {
void MeshDataTool::_bind_methods() {
ClassDB::bind_method(D_METHOD("clear"), &MeshDataTool::clear);
- ClassDB::bind_method(D_METHOD("create_from_surface", "mesh", "surface"), &MeshDataTool::create_from_surface);
- ClassDB::bind_method(D_METHOD("commit_to_surface", "mesh"), &MeshDataTool::commit_to_surface);
+ ClassDB::bind_method(D_METHOD("create_from_surface", "mesh:ArrayMesh", "surface"), &MeshDataTool::create_from_surface);
+ ClassDB::bind_method(D_METHOD("commit_to_surface", "mesh:ArrayMesh"), &MeshDataTool::commit_to_surface);
ClassDB::bind_method(D_METHOD("get_format"), &MeshDataTool::get_format);
@@ -554,7 +554,7 @@ void MeshDataTool::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_vertex_weights", "idx"), &MeshDataTool::get_vertex_weights);
ClassDB::bind_method(D_METHOD("set_vertex_meta", "idx", "meta"), &MeshDataTool::set_vertex_meta);
- ClassDB::bind_method(D_METHOD("get_vertex_meta", "idx"), &MeshDataTool::get_vertex_meta);
+ ClassDB::bind_method(D_METHOD("get_vertex_meta:Variant", "idx"), &MeshDataTool::get_vertex_meta);
ClassDB::bind_method(D_METHOD("get_vertex_edges", "idx"), &MeshDataTool::get_vertex_edges);
ClassDB::bind_method(D_METHOD("get_vertex_faces", "idx"), &MeshDataTool::get_vertex_faces);
@@ -563,18 +563,18 @@ void MeshDataTool::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_edge_faces", "idx", "faces"), &MeshDataTool::get_edge_faces);
ClassDB::bind_method(D_METHOD("set_edge_meta", "idx", "meta"), &MeshDataTool::set_edge_meta);
- ClassDB::bind_method(D_METHOD("get_edge_meta", "idx"), &MeshDataTool::get_edge_meta);
+ ClassDB::bind_method(D_METHOD("get_edge_meta:Variant", "idx"), &MeshDataTool::get_edge_meta);
ClassDB::bind_method(D_METHOD("get_face_vertex", "idx", "vertex"), &MeshDataTool::get_face_vertex);
ClassDB::bind_method(D_METHOD("get_face_edge", "idx", "edge"), &MeshDataTool::get_face_edge);
ClassDB::bind_method(D_METHOD("set_face_meta", "idx", "meta"), &MeshDataTool::set_face_meta);
- ClassDB::bind_method(D_METHOD("get_face_meta", "idx"), &MeshDataTool::get_face_meta);
+ ClassDB::bind_method(D_METHOD("get_face_meta:Variant", "idx"), &MeshDataTool::get_face_meta);
ClassDB::bind_method(D_METHOD("get_face_normal", "idx"), &MeshDataTool::get_face_normal);
ClassDB::bind_method(D_METHOD("set_material", "material:Material"), &MeshDataTool::set_material);
- ClassDB::bind_method(D_METHOD("get_material", "material"), &MeshDataTool::get_material);
+ ClassDB::bind_method(D_METHOD("get_material:Material", "material"), &MeshDataTool::get_material);
}
MeshDataTool::MeshDataTool() {
diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp
index 50fbb6a162..6bf3590c12 100644
--- a/scene/resources/packed_scene.cpp
+++ b/scene/resources/packed_scene.cpp
@@ -29,8 +29,8 @@
/*************************************************************************/
#include "packed_scene.h"
#include "core/core_string_names.h"
-#include "global_config.h"
#include "io/resource_loader.h"
+#include "project_settings.h"
#include "scene/2d/node_2d.h"
#include "scene/3d/spatial.h"
#include "scene/gui/control.h"
@@ -1671,7 +1671,7 @@ void SceneState::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_node_groups", "idx"), &SceneState::_get_node_groups);
ClassDB::bind_method(D_METHOD("get_node_property_count", "idx"), &SceneState::get_node_property_count);
ClassDB::bind_method(D_METHOD("get_node_property_name", "idx", "prop_idx"), &SceneState::get_node_property_name);
- ClassDB::bind_method(D_METHOD("get_node_property_value", "idx", "prop_idx"), &SceneState::get_node_property_value);
+ ClassDB::bind_method(D_METHOD("get_node_property_value:Variant", "idx", "prop_idx"), &SceneState::get_node_property_value);
ClassDB::bind_method(D_METHOD("get_connection_count"), &SceneState::get_connection_count);
ClassDB::bind_method(D_METHOD("get_connection_source", "idx"), &SceneState::get_connection_source);
ClassDB::bind_method(D_METHOD("get_connection_signal", "idx"), &SceneState::get_connection_signal);
diff --git a/scene/resources/primitive_meshes.cpp b/scene/resources/primitive_meshes.cpp
index 8d058377db..327de2f6f3 100644
--- a/scene/resources/primitive_meshes.cpp
+++ b/scene/resources/primitive_meshes.cpp
@@ -34,34 +34,44 @@
/**
PrimitiveMesh
*/
-void PrimitiveMesh::_update() {
- if (!cache_is_dirty)
- return;
+void PrimitiveMesh::_update() const {
Array arr;
arr.resize(VS::ARRAY_MAX);
_create_mesh_array(arr);
+ PoolVector<Vector3> points = arr[VS::ARRAY_VERTEX];
+
+ aabb = Rect3();
+
+ int pc = points.size();
+ ERR_FAIL_COND(pc == 0);
+ {
+
+ PoolVector<Vector3>::Read r = points.read();
+ for (int i = 0; i < pc; i++) {
+ if (i == 0)
+ aabb.position = r[i];
+ else
+ aabb.expand_to(r[i]);
+ }
+ }
+
// in with the new
VisualServer::get_singleton()->mesh_clear(mesh);
VisualServer::get_singleton()->mesh_add_surface_from_arrays(mesh, (VisualServer::PrimitiveType)primitive_type, arr);
VisualServer::get_singleton()->mesh_surface_set_material(mesh, 0, material.is_null() ? RID() : material->get_rid());
- cache_is_dirty = false;
+ pending_request = false;
_clear_triangle_mesh();
- emit_changed();
}
-void PrimitiveMesh::_queue_update() {
- if (!cache_is_dirty) {
- cache_is_dirty = true;
- call_deferred("_update");
- }
-}
+void PrimitiveMesh::_request_update() {
-void PrimitiveMesh::set_aabb(Rect3 p_aabb) {
- aabb = p_aabb;
+ if (pending_request)
+ return;
+ _update();
}
int PrimitiveMesh::get_surface_count() const {
@@ -70,21 +80,37 @@ int PrimitiveMesh::get_surface_count() const {
int PrimitiveMesh::surface_get_array_len(int p_idx) const {
ERR_FAIL_INDEX_V(p_idx, 1, -1);
+ if (pending_request) {
+ _update();
+ }
+
return VisualServer::get_singleton()->mesh_surface_get_array_len(mesh, 0);
}
int PrimitiveMesh::surface_get_array_index_len(int p_idx) const {
ERR_FAIL_INDEX_V(p_idx, 1, -1);
+ if (pending_request) {
+ _update();
+ }
+
return VisualServer::get_singleton()->mesh_surface_get_array_index_len(mesh, 0);
}
Array PrimitiveMesh::surface_get_arrays(int p_surface) const {
ERR_FAIL_INDEX_V(p_surface, 1, Array());
+ if (pending_request) {
+ _update();
+ }
+
return VisualServer::get_singleton()->mesh_surface_get_arrays(mesh, 0);
}
uint32_t PrimitiveMesh::surface_get_format(int p_idx) const {
ERR_FAIL_INDEX_V(p_idx, 1, 0);
+ if (pending_request) {
+ _update();
+ }
+
return VisualServer::get_singleton()->mesh_surface_get_format(mesh, 0);
}
@@ -105,10 +131,17 @@ StringName PrimitiveMesh::get_blend_shape_name(int p_index) const {
}
Rect3 PrimitiveMesh::get_aabb() const {
+ if (pending_request) {
+ _update();
+ }
+
return aabb;
}
RID PrimitiveMesh::get_rid() const {
+ if (pending_request) {
+ _update();
+ }
return mesh;
}
@@ -123,10 +156,9 @@ void PrimitiveMesh::_bind_methods() {
void PrimitiveMesh::set_material(const Ref<Material> &p_material) {
material = p_material;
- if (!cache_is_dirty) {
+ if (!pending_request) {
// just apply it, else it'll happen when _update is called.
VisualServer::get_singleton()->mesh_surface_set_material(mesh, 0, material.is_null() ? RID() : material->get_rid());
-
_change_notify();
emit_changed();
};
@@ -144,8 +176,7 @@ PrimitiveMesh::PrimitiveMesh() {
primitive_type = Mesh::PRIMITIVE_TRIANGLES;
// make sure we do an update after we've finished constructing our object
- cache_is_dirty = false;
- _queue_update();
+ pending_request = true;
}
PrimitiveMesh::~PrimitiveMesh() {
@@ -156,13 +187,13 @@ PrimitiveMesh::~PrimitiveMesh() {
CapsuleMesh
*/
-void CapsuleMesh::_create_mesh_array(Array &p_arr) {
+void CapsuleMesh::_create_mesh_array(Array &p_arr) const {
int i, j, prevrow, thisrow, point;
float x, y, z, u, v, w;
float onethird = 1.0 / 3.0;
float twothirds = 2.0 / 3.0;
- set_aabb(Rect3(Vector3(-radius, (mid_height * -0.5) - radius, -radius), Vector3(radius * 2.0, mid_height + (2.0 * radius), radius * 2.0)));
+ // note, this has been aligned with our collision shape but I've left the descriptions as top/middle/bottom
PoolVector<Vector3> points;
PoolVector<Vector3> normals;
@@ -186,19 +217,19 @@ void CapsuleMesh::_create_mesh_array(Array &p_arr) {
v /= (rings + 1);
w = sin(0.5 * Math_PI * v);
- y = radius * cos(0.5 * Math_PI * v);
+ z = radius * cos(0.5 * Math_PI * v);
for (i = 0; i <= radial_segments; i++) {
u = i;
u /= radial_segments;
x = sin(u * (Math_PI * 2.0));
- z = cos(u * (Math_PI * 2.0));
+ y = -cos(u * (Math_PI * 2.0));
- Vector3 p = Vector3(x * radius * w, y, z * radius * w);
- points.push_back(p + Vector3(0.0, 0.5 * mid_height, 0.0));
+ Vector3 p = Vector3(x * radius * w, y * radius * w, z);
+ points.push_back(p + Vector3(0.0, 0.0, 0.5 * mid_height));
normals.push_back(p.normalized());
- ADD_TANGENT(-z, 0.0, x, -1.0)
+ ADD_TANGENT(y, -x, 0.0, -1.0)
uvs.push_back(Vector2(u, v * onethird));
point++;
@@ -224,20 +255,20 @@ void CapsuleMesh::_create_mesh_array(Array &p_arr) {
v = j;
v /= (rings + 1);
- y = mid_height * v;
- y = (mid_height * 0.5) - y;
+ z = mid_height * v;
+ z = (mid_height * 0.5) - z;
for (i = 0; i <= radial_segments; i++) {
u = i;
u /= radial_segments;
x = sin(u * (Math_PI * 2.0));
- z = cos(u * (Math_PI * 2.0));
+ y = -cos(u * (Math_PI * 2.0));
- Vector3 p = Vector3(x * radius, y, z * radius);
+ Vector3 p = Vector3(x * radius, y * radius, z);
points.push_back(p);
- normals.push_back(Vector3(x, 0.0, z));
- ADD_TANGENT(-z, 0.0, x, -1.0)
+ normals.push_back(Vector3(x, y, 0.0));
+ ADD_TANGENT(y, -x, 0.0, -1.0)
uvs.push_back(Vector2(u, onethird + (v * onethird)));
point++;
@@ -266,19 +297,19 @@ void CapsuleMesh::_create_mesh_array(Array &p_arr) {
v /= (rings + 1);
v += 1.0;
w = sin(0.5 * Math_PI * v);
- y = radius * cos(0.5 * Math_PI * v);
+ z = radius * cos(0.5 * Math_PI * v);
for (i = 0; i <= radial_segments; i++) {
float u = i;
u /= radial_segments;
x = sin(u * (Math_PI * 2.0));
- z = cos(u * (Math_PI * 2.0));
+ y = -cos(u * (Math_PI * 2.0));
- Vector3 p = Vector3(x * radius * w, y, z * radius * w);
- points.push_back(p + Vector3(0.0, -0.5 * mid_height, 0.0));
+ Vector3 p = Vector3(x * radius * w, y * radius * w, z);
+ points.push_back(p + Vector3(0.0, 0.0, -0.5 * mid_height));
normals.push_back(p.normalized());
- ADD_TANGENT(-z, 0.0, x, -1.0)
+ ADD_TANGENT(y, -x, 0.0, -1.0)
uvs.push_back(Vector2(u, twothirds + ((v - 1.0) * onethird)));
point++;
@@ -323,7 +354,7 @@ void CapsuleMesh::_bind_methods() {
void CapsuleMesh::set_radius(const float p_radius) {
radius = p_radius;
- _queue_update();
+ _request_update();
}
float CapsuleMesh::get_radius() const {
@@ -332,7 +363,7 @@ float CapsuleMesh::get_radius() const {
void CapsuleMesh::set_mid_height(const float p_mid_height) {
mid_height = p_mid_height;
- _queue_update();
+ _request_update();
}
float CapsuleMesh::get_mid_height() const {
@@ -341,7 +372,7 @@ float CapsuleMesh::get_mid_height() const {
void CapsuleMesh::set_radial_segments(const int p_segments) {
radial_segments = p_segments > 4 ? p_segments : 4;
- _queue_update();
+ _request_update();
}
int CapsuleMesh::get_radial_segments() const {
@@ -350,7 +381,7 @@ int CapsuleMesh::get_radial_segments() const {
void CapsuleMesh::set_rings(const int p_rings) {
rings = p_rings > 1 ? p_rings : 1;
- _queue_update();
+ _request_update();
}
int CapsuleMesh::get_rings() const {
@@ -369,7 +400,7 @@ CapsuleMesh::CapsuleMesh() {
CubeMesh
*/
-void CubeMesh::_create_mesh_array(Array &p_arr) {
+void CubeMesh::_create_mesh_array(Array &p_arr) const {
int i, j, prevrow, thisrow, point;
float x, y, z;
float onethird = 1.0 / 3.0;
@@ -378,7 +409,6 @@ void CubeMesh::_create_mesh_array(Array &p_arr) {
Vector3 start_pos = size * -0.5;
// set our bounding box
- set_aabb(Rect3(start_pos, size));
PoolVector<Vector3> points;
PoolVector<Vector3> normals;
@@ -581,7 +611,7 @@ void CubeMesh::_bind_methods() {
void CubeMesh::set_size(const Vector3 &p_size) {
size = p_size;
- _queue_update();
+ _request_update();
}
Vector3 CubeMesh::get_size() const {
@@ -590,7 +620,7 @@ Vector3 CubeMesh::get_size() const {
void CubeMesh::set_subdivide_width(const int p_subdivide) {
subdivide_w = p_subdivide > 0 ? p_subdivide : 0;
- _queue_update();
+ _request_update();
}
int CubeMesh::get_subdivide_width() const {
@@ -599,7 +629,7 @@ int CubeMesh::get_subdivide_width() const {
void CubeMesh::set_subdivide_height(const int p_subdivide) {
subdivide_h = p_subdivide > 0 ? p_subdivide : 0;
- _queue_update();
+ _request_update();
}
int CubeMesh::get_subdivide_height() const {
@@ -608,7 +638,7 @@ int CubeMesh::get_subdivide_height() const {
void CubeMesh::set_subdivide_depth(const int p_subdivide) {
subdivide_d = p_subdivide > 0 ? p_subdivide : 0;
- _queue_update();
+ _request_update();
}
int CubeMesh::get_subdivide_depth() const {
@@ -627,14 +657,12 @@ CubeMesh::CubeMesh() {
CylinderMesh
*/
-void CylinderMesh::_create_mesh_array(Array &p_arr) {
+void CylinderMesh::_create_mesh_array(Array &p_arr) const {
int i, j, prevrow, thisrow, point;
float x, y, z, u, v, radius;
radius = bottom_radius > top_radius ? bottom_radius : top_radius;
- set_aabb(Rect3(Vector3(-radius, height * -0.5, -radius), Vector3(radius * 2.0, height, radius * 2.0)));
-
PoolVector<Vector3> points;
PoolVector<Vector3> normals;
PoolVector<float> tangents;
@@ -789,7 +817,7 @@ void CylinderMesh::_bind_methods() {
void CylinderMesh::set_top_radius(const float p_radius) {
top_radius = p_radius;
- _queue_update();
+ _request_update();
}
float CylinderMesh::get_top_radius() const {
@@ -798,7 +826,7 @@ float CylinderMesh::get_top_radius() const {
void CylinderMesh::set_bottom_radius(const float p_radius) {
bottom_radius = p_radius;
- _queue_update();
+ _request_update();
}
float CylinderMesh::get_bottom_radius() const {
@@ -807,7 +835,7 @@ float CylinderMesh::get_bottom_radius() const {
void CylinderMesh::set_height(const float p_height) {
height = p_height;
- _queue_update();
+ _request_update();
}
float CylinderMesh::get_height() const {
@@ -816,7 +844,7 @@ float CylinderMesh::get_height() const {
void CylinderMesh::set_radial_segments(const int p_segments) {
radial_segments = p_segments > 4 ? p_segments : 4;
- _queue_update();
+ _request_update();
}
int CylinderMesh::get_radial_segments() const {
@@ -825,7 +853,7 @@ int CylinderMesh::get_radial_segments() const {
void CylinderMesh::set_rings(const int p_rings) {
rings = p_rings > 0 ? p_rings : 0;
- _queue_update();
+ _request_update();
}
int CylinderMesh::get_rings() const {
@@ -845,14 +873,12 @@ CylinderMesh::CylinderMesh() {
PlaneMesh
*/
-void PlaneMesh::_create_mesh_array(Array &p_arr) {
+void PlaneMesh::_create_mesh_array(Array &p_arr) const {
int i, j, prevrow, thisrow, point;
float x, z;
Size2 start_pos = size * -0.5;
- set_aabb(Rect3(Vector3(start_pos.x, 0.0, start_pos.y), Vector3(size.x, 0.0, size.y)));
-
PoolVector<Vector3> points;
PoolVector<Vector3> normals;
PoolVector<float> tangents;
@@ -924,7 +950,7 @@ void PlaneMesh::_bind_methods() {
void PlaneMesh::set_size(const Size2 &p_size) {
size = p_size;
- _queue_update();
+ _request_update();
}
Size2 PlaneMesh::get_size() const {
@@ -933,7 +959,7 @@ Size2 PlaneMesh::get_size() const {
void PlaneMesh::set_subdivide_width(const int p_subdivide) {
subdivide_w = p_subdivide > 0 ? p_subdivide : 0;
- _queue_update();
+ _request_update();
}
int PlaneMesh::get_subdivide_width() const {
@@ -942,7 +968,7 @@ int PlaneMesh::get_subdivide_width() const {
void PlaneMesh::set_subdivide_depth(const int p_subdivide) {
subdivide_d = p_subdivide > 0 ? p_subdivide : 0;
- _queue_update();
+ _request_update();
}
int PlaneMesh::get_subdivide_depth() const {
@@ -960,7 +986,7 @@ PlaneMesh::PlaneMesh() {
PrismMesh
*/
-void PrismMesh::_create_mesh_array(Array &p_arr) {
+void PrismMesh::_create_mesh_array(Array &p_arr) const {
int i, j, prevrow, thisrow, point;
float x, y, z;
float onethird = 1.0 / 3.0;
@@ -969,7 +995,6 @@ void PrismMesh::_create_mesh_array(Array &p_arr) {
Vector3 start_pos = size * -0.5;
// set our bounding box
- set_aabb(Rect3(start_pos, size));
PoolVector<Vector3> points;
PoolVector<Vector3> normals;
@@ -1196,7 +1221,7 @@ void PrismMesh::_bind_methods() {
void PrismMesh::set_left_to_right(const float p_left_to_right) {
left_to_right = p_left_to_right;
- _queue_update();
+ _request_update();
}
float PrismMesh::get_left_to_right() const {
@@ -1205,7 +1230,7 @@ float PrismMesh::get_left_to_right() const {
void PrismMesh::set_size(const Vector3 &p_size) {
size = p_size;
- _queue_update();
+ _request_update();
}
Vector3 PrismMesh::get_size() const {
@@ -1214,7 +1239,7 @@ Vector3 PrismMesh::get_size() const {
void PrismMesh::set_subdivide_width(const int p_divisions) {
subdivide_w = p_divisions > 0 ? p_divisions : 0;
- _queue_update();
+ _request_update();
}
int PrismMesh::get_subdivide_width() const {
@@ -1223,7 +1248,7 @@ int PrismMesh::get_subdivide_width() const {
void PrismMesh::set_subdivide_height(const int p_divisions) {
subdivide_h = p_divisions > 0 ? p_divisions : 0;
- _queue_update();
+ _request_update();
}
int PrismMesh::get_subdivide_height() const {
@@ -1232,7 +1257,7 @@ int PrismMesh::get_subdivide_height() const {
void PrismMesh::set_subdivide_depth(const int p_divisions) {
subdivide_d = p_divisions > 0 ? p_divisions : 0;
- _queue_update();
+ _request_update();
}
int PrismMesh::get_subdivide_depth() const {
@@ -1252,7 +1277,7 @@ PrismMesh::PrismMesh() {
QuadMesh
*/
-void QuadMesh::_create_mesh_array(Array &p_arr) {
+void QuadMesh::_create_mesh_array(Array &p_arr) const {
PoolVector<Vector3> faces;
PoolVector<Vector3> normals;
PoolVector<float> tangents;
@@ -1307,12 +1332,11 @@ QuadMesh::QuadMesh() {
SphereMesh
*/
-void SphereMesh::_create_mesh_array(Array &p_arr) {
+void SphereMesh::_create_mesh_array(Array &p_arr) const {
int i, j, prevrow, thisrow, point;
float x, y, z;
// set our bounding box
- set_aabb(Rect3(Vector3(-radius, height * -0.5, -radius), Vector3(radius * 2.0, height, radius * 2.0)));
PoolVector<Vector3> points;
PoolVector<Vector3> normals;
@@ -1401,7 +1425,7 @@ void SphereMesh::_bind_methods() {
void SphereMesh::set_radius(const float p_radius) {
radius = p_radius;
- _queue_update();
+ _request_update();
}
float SphereMesh::get_radius() const {
@@ -1410,7 +1434,7 @@ float SphereMesh::get_radius() const {
void SphereMesh::set_height(const float p_height) {
height = p_height;
- _queue_update();
+ _request_update();
}
float SphereMesh::get_height() const {
@@ -1419,7 +1443,7 @@ float SphereMesh::get_height() const {
void SphereMesh::set_radial_segments(const int p_radial_segments) {
radial_segments = p_radial_segments > 4 ? p_radial_segments : 4;
- _queue_update();
+ _request_update();
}
int SphereMesh::get_radial_segments() const {
@@ -1428,7 +1452,7 @@ int SphereMesh::get_radial_segments() const {
void SphereMesh::set_rings(const int p_rings) {
rings = p_rings > 1 ? p_rings : 1;
- _queue_update();
+ _request_update();
}
int SphereMesh::get_rings() const {
@@ -1437,7 +1461,7 @@ int SphereMesh::get_rings() const {
void SphereMesh::set_is_hemisphere(const bool p_is_hemisphere) {
is_hemisphere = p_is_hemisphere;
- _queue_update();
+ _request_update();
}
bool SphereMesh::get_is_hemisphere() const {
diff --git a/scene/resources/primitive_meshes.h b/scene/resources/primitive_meshes.h
index 91d1af2ee1..bcd5d30dd3 100644
--- a/scene/resources/primitive_meshes.h
+++ b/scene/resources/primitive_meshes.h
@@ -47,22 +47,20 @@ class PrimitiveMesh : public Mesh {
private:
RID mesh;
- Rect3 aabb;
+ mutable Rect3 aabb;
Ref<Material> material;
- bool cache_is_dirty;
- void _update();
+ mutable bool pending_request;
+ void _update() const;
protected:
Mesh::PrimitiveType primitive_type;
static void _bind_methods();
- virtual void _create_mesh_array(Array &p_arr) = 0;
- void _queue_update();
-
- void set_aabb(Rect3 p_aabb);
+ virtual void _create_mesh_array(Array &p_arr) const = 0;
+ void _request_update();
public:
virtual int get_surface_count() const;
@@ -98,7 +96,7 @@ private:
protected:
static void _bind_methods();
- virtual void _create_mesh_array(Array &p_arr);
+ virtual void _create_mesh_array(Array &p_arr) const;
public:
void set_radius(const float p_radius);
@@ -131,7 +129,7 @@ private:
protected:
static void _bind_methods();
- virtual void _create_mesh_array(Array &p_arr);
+ virtual void _create_mesh_array(Array &p_arr) const;
public:
void set_size(const Vector3 &p_size);
@@ -166,7 +164,7 @@ private:
protected:
static void _bind_methods();
- virtual void _create_mesh_array(Array &p_arr);
+ virtual void _create_mesh_array(Array &p_arr) const;
public:
void set_top_radius(const float p_radius);
@@ -201,7 +199,7 @@ private:
protected:
static void _bind_methods();
- virtual void _create_mesh_array(Array &p_arr);
+ virtual void _create_mesh_array(Array &p_arr) const;
public:
void set_size(const Size2 &p_size);
@@ -232,7 +230,7 @@ private:
protected:
static void _bind_methods();
- virtual void _create_mesh_array(Array &p_arr);
+ virtual void _create_mesh_array(Array &p_arr) const;
public:
void set_left_to_right(const float p_left_to_right);
@@ -266,7 +264,7 @@ private:
protected:
static void _bind_methods();
- virtual void _create_mesh_array(Array &p_arr);
+ virtual void _create_mesh_array(Array &p_arr) const;
public:
QuadMesh();
@@ -288,7 +286,7 @@ private:
protected:
static void _bind_methods();
- virtual void _create_mesh_array(Array &p_arr);
+ virtual void _create_mesh_array(Array &p_arr) const;
public:
void set_radius(const float p_radius);
diff --git a/scene/resources/scene_format_text.cpp b/scene/resources/scene_format_text.cpp
index 8ad2970005..03a862b744 100644
--- a/scene/resources/scene_format_text.cpp
+++ b/scene/resources/scene_format_text.cpp
@@ -29,8 +29,8 @@
/*************************************************************************/
#include "scene_format_text.h"
-#include "global_config.h"
#include "os/dir_access.h"
+#include "project_settings.h"
#include "version.h"
//version 2: changed names for basis, rect3, poolvectors, etc.
@@ -110,7 +110,7 @@ Error ResourceInteractiveLoaderText::_parse_ext_resource(VariantParser::Stream *
if (path.find("://") == -1 && path.is_rel_path()) {
// path is relative to file being loaded, so convert to a resource path
- path = GlobalConfig::get_singleton()->localize_path(res_path.get_base_dir().plus_file(path));
+ path = ProjectSettings::get_singleton()->localize_path(res_path.get_base_dir().plus_file(path));
}
r_res = ResourceLoader::load(path, type);
@@ -165,7 +165,7 @@ Error ResourceInteractiveLoaderText::poll() {
if (path.find("://") == -1 && path.is_rel_path()) {
// path is relative to file being loaded, so convert to a resource path
- path = GlobalConfig::get_singleton()->localize_path(local_path.get_base_dir().plus_file(path));
+ path = ProjectSettings::get_singleton()->localize_path(local_path.get_base_dir().plus_file(path));
}
if (remaps.has(path)) {
@@ -648,7 +648,7 @@ void ResourceInteractiveLoaderText::get_dependencies(FileAccess *f, List<String>
if (path.find("://") == -1 && path.is_rel_path()) {
// path is relative to file being loaded, so convert to a resource path
- path = GlobalConfig::get_singleton()->localize_path(local_path.get_base_dir().plus_file(path));
+ path = ProjectSettings::get_singleton()->localize_path(local_path.get_base_dir().plus_file(path));
}
if (p_add_types) {
@@ -905,9 +905,9 @@ Ref<ResourceInteractiveLoader> ResourceFormatLoaderText::load_interactive(const
}
Ref<ResourceInteractiveLoaderText> ria = memnew(ResourceInteractiveLoaderText);
- ria->local_path = GlobalConfig::get_singleton()->localize_path(p_path);
+ ria->local_path = ProjectSettings::get_singleton()->localize_path(p_path);
ria->res_path = ria->local_path;
- //ria->set_local_path( GlobalConfig::get_singleton()->localize_path(p_path) );
+ //ria->set_local_path( ProjectSettings::get_singleton()->localize_path(p_path) );
ria->open(f);
return ria;
@@ -953,9 +953,9 @@ String ResourceFormatLoaderText::get_resource_type(const String &p_path) const {
}
Ref<ResourceInteractiveLoaderText> ria = memnew(ResourceInteractiveLoaderText);
- ria->local_path = GlobalConfig::get_singleton()->localize_path(p_path);
+ ria->local_path = ProjectSettings::get_singleton()->localize_path(p_path);
ria->res_path = ria->local_path;
- //ria->set_local_path( GlobalConfig::get_singleton()->localize_path(p_path) );
+ //ria->set_local_path( ProjectSettings::get_singleton()->localize_path(p_path) );
String r = ria->recognize(f);
return r;
}
@@ -969,9 +969,9 @@ void ResourceFormatLoaderText::get_dependencies(const String &p_path, List<Strin
}
Ref<ResourceInteractiveLoaderText> ria = memnew(ResourceInteractiveLoaderText);
- ria->local_path = GlobalConfig::get_singleton()->localize_path(p_path);
+ ria->local_path = ProjectSettings::get_singleton()->localize_path(p_path);
ria->res_path = ria->local_path;
- //ria->set_local_path( GlobalConfig::get_singleton()->localize_path(p_path) );
+ //ria->set_local_path( ProjectSettings::get_singleton()->localize_path(p_path) );
ria->get_dependencies(f, p_dependencies, p_add_types);
}
@@ -984,9 +984,9 @@ Error ResourceFormatLoaderText::rename_dependencies(const String &p_path, const
}
Ref<ResourceInteractiveLoaderText> ria = memnew(ResourceInteractiveLoaderText);
- ria->local_path = GlobalConfig::get_singleton()->localize_path(p_path);
+ ria->local_path = ProjectSettings::get_singleton()->localize_path(p_path);
ria->res_path = ria->local_path;
- //ria->set_local_path( GlobalConfig::get_singleton()->localize_path(p_path) );
+ //ria->set_local_path( ProjectSettings::get_singleton()->localize_path(p_path) );
return ria->rename_dependencies(f, p_path, p_map);
}
@@ -1118,7 +1118,7 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path, const RES &p_r
ERR_FAIL_COND_V(err, ERR_CANT_OPEN);
FileAccessRef _fref(f);
- local_path = GlobalConfig::get_singleton()->localize_path(p_path);
+ local_path = ProjectSettings::get_singleton()->localize_path(p_path);
relative_paths = p_flags & ResourceSaver::FLAG_RELATIVE_PATHS;
skip_editor = p_flags & ResourceSaver::FLAG_OMIT_EDITOR_PROPERTIES;
diff --git a/scene/resources/sky_box.cpp b/scene/resources/sky_box.cpp
index 61aaaf8fb4..b1ca72571e 100644
--- a/scene/resources/sky_box.cpp
+++ b/scene/resources/sky_box.cpp
@@ -47,8 +47,11 @@ void Sky::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_radiance_size", "size"), &Sky::set_radiance_size);
ClassDB::bind_method(D_METHOD("get_radiance_size"), &Sky::get_radiance_size);
- ADD_PROPERTY(PropertyInfo(Variant::INT, "radiance_size", PROPERTY_HINT_ENUM, "256,512,1024,2048"), "set_radiance_size", "get_radiance_size");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "radiance_size", PROPERTY_HINT_ENUM, "32,64,128,256,512,1024,2048"), "set_radiance_size", "get_radiance_size");
+ BIND_CONSTANT(RADIANCE_SIZE_32);
+ BIND_CONSTANT(RADIANCE_SIZE_64);
+ BIND_CONSTANT(RADIANCE_SIZE_128);
BIND_CONSTANT(RADIANCE_SIZE_256);
BIND_CONSTANT(RADIANCE_SIZE_512);
BIND_CONSTANT(RADIANCE_SIZE_1024);
@@ -66,7 +69,7 @@ void PanoramaSky::_radiance_changed() {
if (panorama.is_valid()) {
static const int size[RADIANCE_SIZE_MAX] = {
- 256, 512, 1024, 2048
+ 32, 64, 128, 256, 512, 1024, 2048
};
VS::get_singleton()->sky_set_texture(sky, panorama->get_rid(), size[get_radiance_size()]);
}
@@ -120,7 +123,7 @@ void ProceduralSky::_radiance_changed() {
return; //do nothing yet
static const int size[RADIANCE_SIZE_MAX] = {
- 256, 512, 1024, 2048
+ 32, 64, 128, 256, 512, 1024, 2048
};
VS::get_singleton()->sky_set_texture(sky, texture, size[get_radiance_size()]);
}
@@ -132,7 +135,7 @@ void ProceduralSky::_update_sky() {
PoolVector<uint8_t> imgdata;
static const int size[TEXTURE_SIZE_MAX] = {
- 1024, 2048, 4096
+ 256, 512, 1024, 2048, 4096
};
int w = size[texture_size];
@@ -465,7 +468,14 @@ void ProceduralSky::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::REAL, "sun_energy", PROPERTY_HINT_RANGE, "0,64,0.01"), "set_sun_energy", "get_sun_energy");
ADD_GROUP("Texture", "texture_");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "texture_size", PROPERTY_HINT_ENUM, "1024,2048,4096"), "set_texture_size", "get_texture_size");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "texture_size", PROPERTY_HINT_ENUM, "256,512,1024,2048,4096"), "set_texture_size", "get_texture_size");
+
+ BIND_CONSTANT(TEXTURE_SIZE_256);
+ BIND_CONSTANT(TEXTURE_SIZE_512);
+ BIND_CONSTANT(TEXTURE_SIZE_1024);
+ BIND_CONSTANT(TEXTURE_SIZE_2048);
+ BIND_CONSTANT(TEXTURE_SIZE_4096);
+ BIND_CONSTANT(TEXTURE_SIZE_MAX);
}
ProceduralSky::ProceduralSky() {
@@ -474,15 +484,14 @@ ProceduralSky::ProceduralSky() {
texture = VS::get_singleton()->texture_create();
update_queued = false;
-
- sky_top_color = Color::hex(0x4d67e8ff);
+ sky_top_color = Color::hex(0x0c74f9ff);
sky_horizon_color = Color::hex(0x8ed2e8ff);
sky_curve = 0.25;
sky_energy = 1;
- ground_bottom_color = Color::hex(0x322719ff);
- ground_horizon_color = Color::hex(0x543610ff);
- ground_curve = 0.25;
+ ground_bottom_color = Color::hex(0x1a2530ff);
+ ground_horizon_color = Color::hex(0x7bc9f3ff);
+ ground_curve = 0.01;
ground_energy = 1;
sun_color = Color(1, 1, 1);
diff --git a/scene/resources/sky_box.h b/scene/resources/sky_box.h
index 7b707af3a6..8298d1b3c0 100644
--- a/scene/resources/sky_box.h
+++ b/scene/resources/sky_box.h
@@ -37,6 +37,9 @@ class Sky : public Resource {
public:
enum RadianceSize {
+ RADIANCE_SIZE_32,
+ RADIANCE_SIZE_64,
+ RADIANCE_SIZE_128,
RADIANCE_SIZE_256,
RADIANCE_SIZE_512,
RADIANCE_SIZE_1024,
@@ -85,6 +88,8 @@ class ProceduralSky : public Sky {
public:
enum TextureSize {
+ TEXTURE_SIZE_256,
+ TEXTURE_SIZE_512,
TEXTURE_SIZE_1024,
TEXTURE_SIZE_2048,
TEXTURE_SIZE_4096,
diff --git a/scene/resources/style_box.cpp b/scene/resources/style_box.cpp
index c67f40782d..3666c18487 100644
--- a/scene/resources/style_box.cpp
+++ b/scene/resources/style_box.cpp
@@ -438,3 +438,81 @@ StyleBoxFlat::StyleBoxFlat() {
}
StyleBoxFlat::~StyleBoxFlat() {
}
+
+void StyleBoxLine::set_color(const Color &p_color) {
+ color = p_color;
+ emit_changed();
+}
+Color StyleBoxLine::get_color() const {
+ return color;
+}
+
+void StyleBoxLine::set_thickness(int p_thickness) {
+ thickness = p_thickness;
+ emit_changed();
+}
+int StyleBoxLine::get_thickness() const {
+ return thickness;
+}
+
+void StyleBoxLine::set_vertical(bool p_vertical) {
+ vertical = p_vertical;
+}
+bool StyleBoxLine::is_vertical() const {
+ return vertical;
+}
+
+void StyleBoxLine::set_grow(float p_grow) {
+ grow = p_grow;
+ emit_changed();
+}
+float StyleBoxLine::get_grow() const {
+ return grow;
+}
+
+void StyleBoxLine::_bind_methods() {
+
+ ClassDB::bind_method(D_METHOD("set_color", "color"), &StyleBoxLine::set_color);
+ ClassDB::bind_method(D_METHOD("get_color"), &StyleBoxLine::get_color);
+ ClassDB::bind_method(D_METHOD("set_thickness", "thickness"), &StyleBoxLine::set_thickness);
+ ClassDB::bind_method(D_METHOD("get_thickness"), &StyleBoxLine::get_thickness);
+ ClassDB::bind_method(D_METHOD("set_grow", "grow"), &StyleBoxLine::set_grow);
+ ClassDB::bind_method(D_METHOD("get_grow"), &StyleBoxLine::get_grow);
+ ClassDB::bind_method(D_METHOD("set_vertical", "vertical"), &StyleBoxLine::set_vertical);
+ ClassDB::bind_method(D_METHOD("is_vertical"), &StyleBoxLine::is_vertical);
+
+ ADD_PROPERTY(PropertyInfo(Variant::COLOR, "color"), "set_color", "get_color");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "thickness", PROPERTY_HINT_RANGE, "0,10"), "set_thickness", "get_thickness");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "vertical"), "set_vertical", "is_vertical");
+}
+float StyleBoxLine::get_style_margin(Margin p_margin) const {
+ return thickness;
+}
+Size2 StyleBoxLine::get_center_size() const {
+ return Size2();
+}
+
+void StyleBoxLine::draw(RID p_canvas_item, const Rect2 &p_rect) const {
+ VisualServer *vs = VisualServer::get_singleton();
+ Rect2i r = p_rect;
+
+ if (vertical) {
+ r.position.y -= grow;
+ r.size.y += grow * 2;
+ r.size.x = thickness;
+ } else {
+ r.position.x -= grow;
+ r.size.x += grow * 2;
+ r.size.y = thickness;
+ }
+
+ vs->canvas_item_add_rect(p_canvas_item, r, color);
+}
+
+StyleBoxLine::StyleBoxLine() {
+ grow = 1.0;
+ thickness = 1;
+ color = Color(0.0, 0.0, 0.0);
+ vertical = false;
+}
+StyleBoxLine::~StyleBoxLine() {}
diff --git a/scene/resources/style_box.h b/scene/resources/style_box.h
index 7547c2ea81..64ce3528aa 100644
--- a/scene/resources/style_box.h
+++ b/scene/resources/style_box.h
@@ -164,4 +164,38 @@ public:
~StyleBoxFlat();
};
+// just used to draw lines.
+class StyleBoxLine : public StyleBox {
+
+ GDCLASS(StyleBoxLine, StyleBox);
+ Color color;
+ int thickness;
+ bool vertical;
+ float grow;
+
+protected:
+ virtual float get_style_margin(Margin p_margin) const;
+ static void _bind_methods();
+
+public:
+ void set_color(const Color &p_color);
+ Color get_color() const;
+
+ void set_thickness(int p_thickness);
+ int get_thickness() const;
+
+ void set_vertical(bool p_vertical);
+ bool is_vertical() const;
+
+ void set_grow(float p_grow);
+ float get_grow() const;
+
+ virtual Size2 get_center_size() const;
+
+ virtual void draw(RID p_canvas_item, const Rect2 &p_rect) const;
+
+ StyleBoxLine();
+ ~StyleBoxLine();
+};
+
#endif
diff --git a/scene/resources/surface_tool.cpp b/scene/resources/surface_tool.cpp
index b2822ca0c4..8478432a04 100644
--- a/scene/resources/surface_tool.cpp
+++ b/scene/resources/surface_tool.cpp
@@ -812,11 +812,13 @@ void SurfaceTool::clear() {
index_array.clear();
vertex_array.clear();
smooth_groups.clear();
+ material.unref();
}
void SurfaceTool::_bind_methods() {
ClassDB::bind_method(D_METHOD("begin", "primitive"), &SurfaceTool::begin);
+
ClassDB::bind_method(D_METHOD("add_vertex", "vertex"), &SurfaceTool::add_vertex);
ClassDB::bind_method(D_METHOD("add_color", "color"), &SurfaceTool::add_color);
ClassDB::bind_method(D_METHOD("add_normal", "normal"), &SurfaceTool::add_normal);
@@ -826,15 +828,25 @@ void SurfaceTool::_bind_methods() {
ClassDB::bind_method(D_METHOD("add_bones", "bones"), &SurfaceTool::add_bones);
ClassDB::bind_method(D_METHOD("add_weights", "weights"), &SurfaceTool::add_weights);
ClassDB::bind_method(D_METHOD("add_smooth_group", "smooth"), &SurfaceTool::add_smooth_group);
+
ClassDB::bind_method(D_METHOD("add_triangle_fan", "vertexes", "uvs", "colors", "uv2s", "normals", "tangents"), &SurfaceTool::add_triangle_fan, DEFVAL(Vector<Vector2>()), DEFVAL(Vector<Color>()), DEFVAL(Vector<Vector2>()), DEFVAL(Vector<Vector3>()), DEFVAL(Vector<Plane>()));
- ClassDB::bind_method(D_METHOD("set_material", "material:Material"), &SurfaceTool::set_material);
+
+ ClassDB::bind_method(D_METHOD("add_index", "index"), &SurfaceTool::add_index);
+
ClassDB::bind_method(D_METHOD("index"), &SurfaceTool::index);
ClassDB::bind_method(D_METHOD("deindex"), &SurfaceTool::deindex);
- ///ClassDB::bind_method(D_METHOD("generate_flat_normals"),&SurfaceTool::generate_flat_normals);
ClassDB::bind_method(D_METHOD("generate_normals"), &SurfaceTool::generate_normals);
- ClassDB::bind_method(D_METHOD("add_index", "index"), &SurfaceTool::add_index);
- ClassDB::bind_method(D_METHOD("commit:Mesh", "existing:Mesh"), &SurfaceTool::commit, DEFVAL(Variant()));
+ ClassDB::bind_method(D_METHOD("generate_tangents"), &SurfaceTool::generate_tangents);
+
+ ClassDB::bind_method(D_METHOD("add_to_format", "flags"), &SurfaceTool::add_to_format);
+
+ ClassDB::bind_method(D_METHOD("set_material", "material:Material"), &SurfaceTool::set_material);
+
ClassDB::bind_method(D_METHOD("clear"), &SurfaceTool::clear);
+
+ ClassDB::bind_method(D_METHOD("create_from", "existing:Mesh", "surface"), &SurfaceTool::create_from);
+ ClassDB::bind_method(D_METHOD("append_from", "existing:Mesh", "surface", "transform"), &SurfaceTool::append_from);
+ ClassDB::bind_method(D_METHOD("commit:Mesh", "existing:Mesh"), &SurfaceTool::commit, DEFVAL(Variant()));
}
SurfaceTool::SurfaceTool() {
diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp
index f6856b3539..fe7cd0097c 100644
--- a/scene/resources/texture.cpp
+++ b/scene/resources/texture.cpp
@@ -1327,8 +1327,8 @@ void CubeMap::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_flags", "flags"), &CubeMap::set_flags);
ClassDB::bind_method(D_METHOD("get_flags"), &CubeMap::get_flags);
- ClassDB::bind_method(D_METHOD("set_side", "side", "image"), &CubeMap::set_side);
- ClassDB::bind_method(D_METHOD("get_side", "side"), &CubeMap::get_side);
+ ClassDB::bind_method(D_METHOD("set_side", "side", "image:Image"), &CubeMap::set_side);
+ ClassDB::bind_method(D_METHOD("get_side:Image", "side"), &CubeMap::get_side);
ClassDB::bind_method(D_METHOD("set_storage", "mode"), &CubeMap::set_storage);
ClassDB::bind_method(D_METHOD("get_storage"), &CubeMap::get_storage);
ClassDB::bind_method(D_METHOD("set_lossy_storage_quality", "quality"), &CubeMap::set_lossy_storage_quality);
diff --git a/scene/resources/texture.h b/scene/resources/texture.h
index 9bbbd1d091..6c20c71af0 100644
--- a/scene/resources/texture.h
+++ b/scene/resources/texture.h
@@ -414,7 +414,7 @@ public:
void set_width(int p_width);
int get_width() const;
- void ensure_default_setup(float p_min=0, float p_max=1);
+ void ensure_default_setup(float p_min = 0, float p_max = 1);
void set_curve(Ref<Curve> p_curve);
Ref<Curve> get_curve() const;
diff --git a/scene/resources/theme.cpp b/scene/resources/theme.cpp
index faf9f31b43..d5c68457d0 100644
--- a/scene/resources/theme.cpp
+++ b/scene/resources/theme.cpp
@@ -660,8 +660,8 @@ void Theme::_bind_methods() {
ClassDB::bind_method(D_METHOD("clear_constant", "name", "type"), &Theme::clear_constant);
ClassDB::bind_method(D_METHOD("get_constant_list", "type"), &Theme::_get_constant_list);
- ClassDB::bind_method(D_METHOD("set_default_font", "font"), &Theme::set_default_theme_font);
- ClassDB::bind_method(D_METHOD("get_default_font"), &Theme::get_default_theme_font);
+ ClassDB::bind_method(D_METHOD("set_default_font", "font:Font"), &Theme::set_default_theme_font);
+ ClassDB::bind_method(D_METHOD("get_default_font:Font"), &Theme::get_default_theme_font);
ClassDB::bind_method(D_METHOD("get_type_list", "type"), &Theme::_get_type_list);
diff --git a/scene/resources/tile_set.cpp b/scene/resources/tile_set.cpp
index b9d2c503e1..dc8f6a0a69 100644
--- a/scene/resources/tile_set.cpp
+++ b/scene/resources/tile_set.cpp
@@ -57,8 +57,12 @@ bool TileSet::_set(const StringName &p_name, const Variant &p_value) {
tile_set_region(id, p_value);
else if (what == "shape")
tile_set_shape(id, 0, p_value);
- else if (what == "shape_offset")
- tile_set_shape_offset(id, 0, p_value);
+ else if (what == "shape_offset") {
+ Transform2D xform = tile_get_shape_transform(id, 0);
+ xform.set_origin(p_value);
+ tile_set_shape_transform(id, 0, xform);
+ } else if (what == "shape_transform")
+ tile_set_shape_transform(id, 0, p_value);
else if (what == "shape_one_way")
tile_set_shape_one_way(id, 0, p_value);
else if (what == "shapes")
@@ -106,7 +110,9 @@ bool TileSet::_get(const StringName &p_name, Variant &r_ret) const {
else if (what == "shape")
r_ret = tile_get_shape(id, 0);
else if (what == "shape_offset")
- r_ret = tile_get_shape_offset(id, 0);
+ r_ret = tile_get_shape_transform(id, 0).get_origin();
+ else if (what == "shape_transform")
+ r_ret = tile_get_shape_transform(id, 0);
else if (what == "shape_one_way")
r_ret = tile_get_shape_one_way(id, 0);
else if (what == "shapes")
@@ -143,6 +149,7 @@ void TileSet::_get_property_list(List<PropertyInfo> *p_list) const {
p_list->push_back(PropertyInfo(Variant::VECTOR2, pre + "navigation_offset"));
p_list->push_back(PropertyInfo(Variant::OBJECT, pre + "navigation", PROPERTY_HINT_RESOURCE_TYPE, "NavigationPolygon"));
p_list->push_back(PropertyInfo(Variant::VECTOR2, pre + "shape_offset", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR));
+ p_list->push_back(PropertyInfo(Variant::VECTOR2, pre + "shape_transform", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR));
p_list->push_back(PropertyInfo(Variant::OBJECT, pre + "shape", PROPERTY_HINT_RESOURCE_TYPE, "Shape2D", PROPERTY_USAGE_EDITOR));
p_list->push_back(PropertyInfo(Variant::BOOL, pre + "shape_one_way", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR));
p_list->push_back(PropertyInfo(Variant::ARRAY, pre + "shapes", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR));
@@ -252,13 +259,13 @@ void TileSet::tile_clear_shapes(int p_id) {
tile_map[p_id].shapes_data.clear();
}
-void TileSet::tile_add_shape(int p_id, const Ref<Shape2D> &p_shape, const Vector2 &p_offset, bool p_one_way) {
+void TileSet::tile_add_shape(int p_id, const Ref<Shape2D> &p_shape, const Transform2D &p_transform, bool p_one_way) {
ERR_FAIL_COND(!tile_map.has(p_id));
ShapeData new_data = ShapeData();
new_data.shape = p_shape;
- new_data.shape_offset = p_offset;
+ new_data.shape_transform = p_transform;
new_data.one_way_collision = p_one_way;
tile_map[p_id].shapes_data.push_back(new_data);
@@ -288,22 +295,22 @@ Ref<Shape2D> TileSet::tile_get_shape(int p_id, int p_shape_id) const {
return Ref<Shape2D>();
}
-void TileSet::tile_set_shape_offset(int p_id, int p_shape_id, const Vector2 &p_offset) {
+void TileSet::tile_set_shape_transform(int p_id, int p_shape_id, const Transform2D &p_offset) {
ERR_FAIL_COND(!tile_map.has(p_id));
if (tile_map[p_id].shapes_data.size() <= p_shape_id)
tile_map[p_id].shapes_data.resize(p_shape_id + 1);
- tile_map[p_id].shapes_data[p_shape_id].shape_offset = p_offset;
+ tile_map[p_id].shapes_data[p_shape_id].shape_transform = p_offset;
emit_changed();
}
-Vector2 TileSet::tile_get_shape_offset(int p_id, int p_shape_id) const {
+Transform2D TileSet::tile_get_shape_transform(int p_id, int p_shape_id) const {
- ERR_FAIL_COND_V(!tile_map.has(p_id), Vector2());
+ ERR_FAIL_COND_V(!tile_map.has(p_id), Transform2D());
if (tile_map[p_id].shapes_data.size() > p_shape_id)
- return tile_map[p_id].shapes_data[p_shape_id].shape_offset;
+ return tile_map[p_id].shapes_data[p_shape_id].shape_transform;
- return Vector2();
+ return Transform2D();
}
void TileSet::tile_set_shape_one_way(int p_id, int p_shape_id, const bool p_one_way) {
@@ -388,7 +395,7 @@ void TileSet::_tile_set_shapes(int p_id, const Array &p_shapes) {
ERR_FAIL_COND(!tile_map.has(p_id));
Vector<ShapeData> shapes_data;
- Vector2 default_offset = tile_get_shape_offset(p_id, 0);
+ Transform2D default_transform = tile_get_shape_transform(p_id, 0);
bool default_one_way = tile_get_shape_one_way(p_id, 0);
for (int i = 0; i < p_shapes.size(); i++) {
ShapeData s = ShapeData();
@@ -398,7 +405,7 @@ void TileSet::_tile_set_shapes(int p_id, const Array &p_shapes) {
if (shape.is_null()) continue;
s.shape = shape;
- s.shape_offset = default_offset;
+ s.shape_transform = default_transform;
s.one_way_collision = default_one_way;
} else if (p_shapes[i].get_type() == Variant::DICTIONARY) {
Dictionary d = p_shapes[i];
@@ -408,10 +415,12 @@ void TileSet::_tile_set_shapes(int p_id, const Array &p_shapes) {
else
continue;
- if (d.has("shape_offset") && d["shape_offset"].get_type() == Variant::VECTOR2)
- s.shape_offset = d["shape_offset"];
+ if (d.has("shape_transform") && d["shape_transform"].get_type() == Variant::TRANSFORM2D)
+ s.shape_transform = d["shape_transform"];
+ else if (d.has("shape_offset") && d["shape_offset"].get_type() == Variant::VECTOR2)
+ s.shape_transform = Transform2D(0, (Vector2)d["shape_offset"]);
else
- s.shape_offset = default_offset;
+ s.shape_transform = default_transform;
if (d.has("one_way") && d["one_way"].get_type() == Variant::BOOL)
s.one_way_collision = d["one_way"];
@@ -438,7 +447,7 @@ Array TileSet::_tile_get_shapes(int p_id) const {
for (int i = 0; i < data.size(); i++) {
Dictionary shape_data;
shape_data["shape"] = data[i].shape;
- shape_data["shape_offset"] = data[i].shape_offset;
+ shape_data["shape_transform"] = data[i].shape_transform;
shape_data["one_way"] = data[i].one_way_collision;
arr.push_back(shape_data);
}
@@ -520,11 +529,11 @@ void TileSet::_bind_methods() {
ClassDB::bind_method(D_METHOD("tile_get_region", "id"), &TileSet::tile_get_region);
ClassDB::bind_method(D_METHOD("tile_set_shape", "id", "shape_id", "shape:Shape2D"), &TileSet::tile_set_shape);
ClassDB::bind_method(D_METHOD("tile_get_shape:Shape2D", "id", "shape_id"), &TileSet::tile_get_shape);
- ClassDB::bind_method(D_METHOD("tile_set_shape_offset", "id", "shape_id", "shape_offset"), &TileSet::tile_set_shape_offset);
- ClassDB::bind_method(D_METHOD("tile_get_shape_offset", "id", "shape_id"), &TileSet::tile_get_shape_offset);
+ ClassDB::bind_method(D_METHOD("tile_set_shape_transform", "id", "shape_id", "shape_transform"), &TileSet::tile_set_shape_transform);
+ ClassDB::bind_method(D_METHOD("tile_get_shape_transform", "id", "shape_id"), &TileSet::tile_get_shape_transform);
ClassDB::bind_method(D_METHOD("tile_set_shape_one_way", "id", "shape_id", "one_way"), &TileSet::tile_set_shape_one_way);
ClassDB::bind_method(D_METHOD("tile_get_shape_one_way", "id", "shape_id"), &TileSet::tile_get_shape_one_way);
- ClassDB::bind_method(D_METHOD("tile_add_shape", "id", "shape:Shape2D", "shape_offset", "one_way"), &TileSet::tile_add_shape, DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("tile_add_shape", "id", "shape:Shape2D", "shape_transform", "one_way"), &TileSet::tile_add_shape, DEFVAL(false));
ClassDB::bind_method(D_METHOD("tile_get_shape_count", "id"), &TileSet::tile_get_shape_count);
ClassDB::bind_method(D_METHOD("tile_set_shapes", "id", "shapes"), &TileSet::_tile_set_shapes);
ClassDB::bind_method(D_METHOD("tile_get_shapes", "id"), &TileSet::_tile_get_shapes);
diff --git a/scene/resources/tile_set.h b/scene/resources/tile_set.h
index c07d82c75a..99c506390c 100644
--- a/scene/resources/tile_set.h
+++ b/scene/resources/tile_set.h
@@ -43,7 +43,7 @@ class TileSet : public Resource {
public:
struct ShapeData {
Ref<Shape2D> shape;
- Vector2 shape_offset;
+ Transform2D shape_transform;
bool one_way_collision;
ShapeData() {
@@ -105,14 +105,14 @@ public:
void tile_set_shape(int p_id, int p_shape_id, const Ref<Shape2D> &p_shape);
Ref<Shape2D> tile_get_shape(int p_id, int p_shape_id) const;
- void tile_set_shape_offset(int p_id, int p_shape_id, const Vector2 &p_offset);
- Vector2 tile_get_shape_offset(int p_id, int p_shape_id) const;
+ void tile_set_shape_transform(int p_id, int p_shape_id, const Transform2D &p_transform);
+ Transform2D tile_get_shape_transform(int p_id, int p_shape_id) const;
void tile_set_shape_one_way(int p_id, int p_shape_id, bool p_one_way);
bool tile_get_shape_one_way(int p_id, int p_shape_id) const;
void tile_clear_shapes(int p_id);
- void tile_add_shape(int p_id, const Ref<Shape2D> &p_shape, const Vector2 &p_offset, bool p_one_way = false);
+ void tile_add_shape(int p_id, const Ref<Shape2D> &p_shape, const Transform2D &p_transform, bool p_one_way = false);
int tile_get_shape_count(int p_id) const;
void tile_set_shapes(int p_id, const Vector<ShapeData> &p_shapes);
diff --git a/scene/resources/world.cpp b/scene/resources/world.cpp
index 24551e9135..b84cc9563e 100644
--- a/scene/resources/world.cpp
+++ b/scene/resources/world.cpp
@@ -299,6 +299,13 @@ PhysicsDirectSpaceState *World::get_direct_space_state() {
return PhysicsServer::get_singleton()->space_get_direct_state(space);
}
+void World::get_camera_list(List<Camera *> *r_cameras) {
+
+ for (Map<Camera *, SpatialIndexer::CameraData>::Element *E = indexer->cameras.front(); E; E = E->next()) {
+ r_cameras->push_back(E->key());
+ }
+}
+
void World::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_space"), &World::get_space);
diff --git a/scene/resources/world.h b/scene/resources/world.h
index 5291b3974b..158086974c 100644
--- a/scene/resources/world.h
+++ b/scene/resources/world.h
@@ -76,6 +76,8 @@ public:
void set_fallback_environment(const Ref<Environment> &p_environment);
Ref<Environment> get_fallback_environment() const;
+ void get_camera_list(List<Camera *> *r_cameras);
+
PhysicsDirectSpaceState *get_direct_space_state();
World();
diff --git a/scene/resources/world_2d.cpp b/scene/resources/world_2d.cpp
index 36d2a38b3d..056c49f1ae 100644
--- a/scene/resources/world_2d.cpp
+++ b/scene/resources/world_2d.cpp
@@ -31,8 +31,7 @@
#include "servers/physics_2d_server.h"
#include "servers/visual_server.h"
//#include "servers/spatial_sound_2d_server.h"
-#include "global_config.h"
-#include "global_config.h"
+#include "project_settings.h"
#include "scene/2d/camera_2d.h"
#include "scene/2d/visibility_notifier_2d.h"
#include "scene/main/viewport.h"
diff --git a/scene/resources/world_2d.h b/scene/resources/world_2d.h
index 35c8ce390f..f968b08a15 100644
--- a/scene/resources/world_2d.h
+++ b/scene/resources/world_2d.h
@@ -30,7 +30,7 @@
#ifndef WORLD_2D_H
#define WORLD_2D_H
-#include "global_config.h"
+#include "project_settings.h"
#include "resource.h"
#include "servers/physics_2d_server.h"
diff --git a/servers/SCsub b/servers/SCsub
index eefa6278c4..df55010a36 100644
--- a/servers/SCsub
+++ b/servers/SCsub
@@ -7,12 +7,11 @@ env.add_source_files(env.servers_sources, "*.cpp")
Export('env')
+SConscript('arvr/SCsub')
SConscript('physics/SCsub')
SConscript('physics_2d/SCsub')
SConscript('visual/SCsub')
SConscript('audio/SCsub')
-SConscript('spatial_sound/SCsub')
-SConscript('spatial_sound_2d/SCsub')
lib = env.Library("servers", env.servers_sources)
diff --git a/servers/arvr/SCsub b/servers/arvr/SCsub
new file mode 100644
index 0000000000..ccc76e823f
--- /dev/null
+++ b/servers/arvr/SCsub
@@ -0,0 +1,7 @@
+#!/usr/bin/env python
+
+Import('env')
+
+env.add_source_files(env.servers_sources, "*.cpp")
+
+Export('env')
diff --git a/servers/arvr/arvr_interface.cpp b/servers/arvr/arvr_interface.cpp
new file mode 100644
index 0000000000..81eb011932
--- /dev/null
+++ b/servers/arvr/arvr_interface.cpp
@@ -0,0 +1,82 @@
+/*************************************************************************/
+/* arvr_interface.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+#include "arvr_interface.h"
+
+void ARVRInterface::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("get_name"), &ARVRInterface::get_name);
+
+ ClassDB::bind_method(D_METHOD("is_primary"), &ARVRInterface::is_primary);
+ ClassDB::bind_method(D_METHOD("set_is_primary", "enable"), &ARVRInterface::set_is_primary);
+
+ ClassDB::bind_method(D_METHOD("is_installed"), &ARVRInterface::is_installed);
+ ClassDB::bind_method(D_METHOD("hmd_is_present"), &ARVRInterface::hmd_is_present);
+ ClassDB::bind_method(D_METHOD("supports_hmd"), &ARVRInterface::supports_hmd);
+ ClassDB::bind_method(D_METHOD("is_initialized"), &ARVRInterface::is_initialized);
+ ClassDB::bind_method(D_METHOD("initialize"), &ARVRInterface::initialize);
+ ClassDB::bind_method(D_METHOD("uninitialize"), &ARVRInterface::uninitialize);
+
+ ClassDB::bind_method(D_METHOD("get_recommended_render_targetsize"), &ARVRInterface::get_recommended_render_targetsize);
+
+ // These are now purely used internally, we may expose them again if we expose CameraMatrix through Variant but reduz is not a fan for good reasons :)
+ // ClassDB::bind_method(D_METHOD("get_transform_for_eye", "eye", "cam_transform"), &ARVRInterface::get_transform_for_eye);
+ // ClassDB::bind_method(D_METHOD("get_projection_for_eye", "eye"), &ARVRInterface::get_projection_for_eye);
+ // ClassDB::bind_method(D_METHOD("commit_for_eye", "node:viewport"), &ARVRInterface::commit_for_eye);
+
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "primary"), "set_is_primary", "is_primary");
+
+ BIND_CONSTANT(EYE_MONO);
+ BIND_CONSTANT(EYE_LEFT);
+ BIND_CONSTANT(EYE_RIGHT);
+};
+
+StringName ARVRInterface::get_name() const {
+ return "Unknown";
+};
+
+bool ARVRInterface::is_primary() {
+ ARVRServer *arvr_server = ARVRServer::get_singleton();
+ ERR_FAIL_NULL_V(arvr_server, false);
+
+ return arvr_server->get_primary_interface() == this;
+};
+
+void ARVRInterface::set_is_primary(bool p_is_primary) {
+ ARVRServer *arvr_server = ARVRServer::get_singleton();
+ ERR_FAIL_NULL(arvr_server);
+
+ if (p_is_primary) {
+ ERR_FAIL_COND(!is_initialized());
+ ERR_FAIL_COND(!supports_hmd());
+
+ arvr_server->set_primary_interface(this);
+ } else {
+ arvr_server->clear_primary_interface_if(this);
+ };
+};
diff --git a/servers/arvr/arvr_interface.h b/servers/arvr/arvr_interface.h
new file mode 100644
index 0000000000..e405499fbb
--- /dev/null
+++ b/servers/arvr/arvr_interface.h
@@ -0,0 +1,89 @@
+/*************************************************************************/
+/* arvr_interface.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+#ifndef ARVR_INTERFACE_H
+#define ARVR_INTERFACE_H
+
+#include "core/math/camera_matrix.h"
+#include "os/thread_safe.h"
+#include "scene/main/viewport.h"
+#include "servers/arvr_server.h"
+
+/**
+ @author Bastiaan Olij <mux213@gmail.com>
+
+ The ARVR interface is a template class ontop of which we build interface to differt AR, VR and tracking SDKs.
+ The idea is that we subclass this class, implement the logic, and then instantiate a singleton of each interface
+ when Godot starts. These instances do not initialize themselves but register themselves with the AR/VR server.
+
+ If the user wants to enable AR/VR the choose the interface they want to use and initialize it.
+
+ Note that we may make this into a fully instantiable class for GDNative support.
+*/
+
+class ARVRInterface : public Reference {
+ GDCLASS(ARVRInterface, Reference);
+
+protected:
+ _THREAD_SAFE_CLASS_
+
+ static void _bind_methods();
+
+public:
+ enum Eyes {
+ EYE_MONO, /* my son says we should call this EYE_CYCLOPS */
+ EYE_LEFT,
+ EYE_RIGHT
+ };
+
+ virtual StringName get_name() const;
+
+ bool is_primary();
+ void set_is_primary(bool p_is_primary);
+
+ virtual bool is_installed() = 0; /* returns true if the middle ware related to this interface has been installed */
+ virtual bool hmd_is_present() = 0; /* returns true if our HMD is connected */
+ virtual bool supports_hmd() = 0; /* returns true is this interface handles output to an HMD or only handles positioning */
+
+ virtual bool is_initialized() = 0; /* returns true if we've initialized this interface */
+ virtual bool initialize() = 0; /* initialize this interface, if this has an HMD it becomes the primary interface */
+ virtual void uninitialize() = 0; /* deinitialize this interface */
+
+ virtual Size2 get_recommended_render_targetsize() = 0; /* returns the recommended render target size per eye for this device */
+ virtual bool is_stereo() = 0; /* returns true if this interface requires stereo rendering (for VR HMDs) or mono rendering (for mobile AR) */
+ virtual Transform get_transform_for_eye(ARVRInterface::Eyes p_eye, const Transform &p_cam_transform) = 0; /* get each eyes camera transform, also implement EYE_MONO */
+ virtual CameraMatrix get_projection_for_eye(ARVRInterface::Eyes p_eye, real_t p_aspect, real_t p_z_near, real_t p_z_far) = 0; /* get each eyes projection matrix */
+ virtual void commit_for_eye(ARVRInterface::Eyes p_eye, RID p_render_target, const Rect2 &p_screen_rect) = 0; /* output the left or right eye */
+
+ virtual void process() = 0;
+};
+
+VARIANT_ENUM_CAST(ARVRInterface::Eyes);
+
+#endif
diff --git a/servers/arvr/arvr_positional_tracker.cpp b/servers/arvr/arvr_positional_tracker.cpp
new file mode 100644
index 0000000000..4215363d16
--- /dev/null
+++ b/servers/arvr/arvr_positional_tracker.cpp
@@ -0,0 +1,142 @@
+/*************************************************************************/
+/* arvr_postional_tracker.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+#include "arvr_positional_tracker.h"
+#include "core/os/input.h"
+
+void ARVRPositionalTracker::_bind_methods() {
+ // this class is read only from GDScript, so we only have access to getters..
+ ClassDB::bind_method(D_METHOD("get_type"), &ARVRPositionalTracker::get_type);
+ ClassDB::bind_method(D_METHOD("get_name"), &ARVRPositionalTracker::get_name);
+ ClassDB::bind_method(D_METHOD("get_joy_id"), &ARVRPositionalTracker::get_joy_id);
+ ClassDB::bind_method(D_METHOD("get_tracks_orientation"), &ARVRPositionalTracker::get_tracks_orientation);
+ ClassDB::bind_method(D_METHOD("get_orientation"), &ARVRPositionalTracker::get_orientation);
+ ClassDB::bind_method(D_METHOD("get_tracks_position"), &ARVRPositionalTracker::get_tracks_position);
+ ClassDB::bind_method(D_METHOD("get_position"), &ARVRPositionalTracker::get_position);
+ ClassDB::bind_method(D_METHOD("get_transform", "adjust_by_reference_frame"), &ARVRPositionalTracker::get_transform);
+};
+
+void ARVRPositionalTracker::set_type(ARVRServer::TrackerType p_type) {
+ if (type != p_type) {
+ type = p_type;
+
+ ARVRServer *arvr_server = ARVRServer::get_singleton();
+ ERR_FAIL_NULL(arvr_server);
+
+ // get a tracker id for our type
+ tracker_id = arvr_server->get_free_tracker_id_for_type(p_type);
+ }
+};
+
+ARVRServer::TrackerType ARVRPositionalTracker::get_type() const {
+ return type;
+};
+
+void ARVRPositionalTracker::set_name(const String p_name) {
+ name = p_name;
+};
+
+StringName ARVRPositionalTracker::get_name() const {
+ return name;
+};
+
+int ARVRPositionalTracker::get_tracker_id() const {
+ return tracker_id;
+};
+
+void ARVRPositionalTracker::set_joy_id(int p_joy_id) {
+ joy_id = p_joy_id;
+};
+
+int ARVRPositionalTracker::get_joy_id() const {
+ return joy_id;
+};
+
+bool ARVRPositionalTracker::get_tracks_orientation() const {
+ return tracks_orientation;
+};
+
+void ARVRPositionalTracker::set_orientation(const Basis &p_orientation) {
+ _THREAD_SAFE_METHOD_
+
+ tracks_orientation = true; // obviously we have this
+ orientation = p_orientation;
+};
+
+Basis ARVRPositionalTracker::get_orientation() const {
+ _THREAD_SAFE_METHOD_
+
+ return orientation;
+};
+
+bool ARVRPositionalTracker::get_tracks_position() const {
+ return tracks_position;
+};
+
+void ARVRPositionalTracker::set_position(const Vector3 &p_position) {
+ _THREAD_SAFE_METHOD_
+
+ tracks_position = true; // obviously we have this
+ position = p_position;
+};
+
+Vector3 ARVRPositionalTracker::get_position() const {
+ _THREAD_SAFE_METHOD_
+
+ return position;
+};
+
+Transform ARVRPositionalTracker::get_transform(bool p_adjust_by_reference_frame) const {
+ Transform new_transform;
+
+ new_transform.basis = get_orientation();
+ new_transform.origin = get_position();
+
+ if (p_adjust_by_reference_frame) {
+ ARVRServer *arvr_server = ARVRServer::get_singleton();
+ ERR_FAIL_NULL_V(arvr_server, new_transform);
+
+ new_transform = arvr_server->get_reference_frame() * new_transform;
+ };
+
+ return new_transform;
+};
+
+ARVRPositionalTracker::ARVRPositionalTracker() {
+ type = ARVRServer::TRACKER_UNKNOWN;
+ name = "Unknown";
+ joy_id = -1;
+ tracker_id = 0;
+ tracks_orientation = false;
+ tracks_position = false;
+};
+
+ARVRPositionalTracker::~ARVRPositionalTracker(){
+
+};
diff --git a/servers/arvr/arvr_positional_tracker.h b/servers/arvr/arvr_positional_tracker.h
new file mode 100644
index 0000000000..e8c613b29d
--- /dev/null
+++ b/servers/arvr/arvr_positional_tracker.h
@@ -0,0 +1,85 @@
+/*************************************************************************/
+/* arvr_positional_tracker.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+#ifndef ARVR_POSITIONAL_TRACKER_H
+#define ARVR_POSITIONAL_TRACKER_H
+
+#include "os/thread_safe.h"
+#include "servers/arvr_server.h"
+
+/**
+ @author Bastiaan Olij <mux213@gmail.com>
+
+ The positional tracker object as an object that represents the position and orientation of a tracked object like a controller or headset.
+ An AR/VR Interface will registered the trackers it manages with our AR/VR server and update its position and orientation.
+ This is where potentially additional AR/VR interfaces may be active as there are AR/VR SDKs that solely deal with positional tracking.
+
+ @TODO:
+ - create subclass of spatial node that uses one of our positional trackers to automatically determine its position
+*/
+
+class ARVRPositionalTracker : public Object {
+ GDCLASS(ARVRPositionalTracker, Object);
+ _THREAD_SAFE_CLASS_
+
+private:
+ ARVRServer::TrackerType type; // type of tracker
+ StringName name; // (unique) name of the tracker
+ int tracker_id; // tracker index id that is unique per type
+ int joy_id; // if we also have a related joystick entity, the id of the joystick
+ bool tracks_orientation; // do we track orientation?
+ Basis orientation; // our orientation
+ bool tracks_position; // do we track position?
+ Vector3 position; // our position
+
+protected:
+ static void _bind_methods();
+
+public:
+ void set_type(ARVRServer::TrackerType p_type);
+ ARVRServer::TrackerType get_type() const;
+ void set_name(const String p_name);
+ StringName get_name() const;
+ int get_tracker_id() const;
+ void set_joy_id(int p_joy_id);
+ int get_joy_id() const;
+ bool get_tracks_orientation() const;
+ void set_orientation(const Basis &p_orientation);
+ Basis get_orientation() const;
+ bool get_tracks_position() const;
+ void set_position(const Vector3 &p_position);
+ Vector3 get_position() const;
+
+ Transform get_transform(bool p_adjust_by_reference_frame) const;
+
+ ARVRPositionalTracker();
+ ~ARVRPositionalTracker();
+};
+
+#endif
diff --git a/servers/arvr/arvr_script_interface.cpp b/servers/arvr/arvr_script_interface.cpp
new file mode 100644
index 0000000000..16e607920e
--- /dev/null
+++ b/servers/arvr/arvr_script_interface.cpp
@@ -0,0 +1,127 @@
+#include "arvr_script_interface.h"
+
+ARVRScriptInterface::ARVRScriptInterface() {
+ // testing
+ printf("Construct script interface");
+}
+
+ARVRScriptInterface::~ARVRScriptInterface() {
+ if (is_initialized()) {
+ uninitialize();
+ };
+
+ // testing
+ printf("Destruct script interface");
+}
+
+StringName ARVRScriptInterface::get_name() const {
+ if (get_script_instance() && get_script_instance()->has_method("get_name")) {
+ return get_script_instance()->call("get_name");
+ } else {
+ // just return something for now
+ return "ARVR Script interface";
+ }
+}
+
+bool ARVRScriptInterface::is_installed() {
+ ERR_FAIL_COND_V(!(get_script_instance() && get_script_instance()->has_method("is_installed")), false);
+ return get_script_instance()->call("is_installed");
+}
+
+bool ARVRScriptInterface::hmd_is_present() {
+ ERR_FAIL_COND_V(!(get_script_instance() && get_script_instance()->has_method("hmd_is_present")), false);
+ return get_script_instance()->call("hmd_is_present");
+}
+
+bool ARVRScriptInterface::supports_hmd() {
+ ERR_FAIL_COND_V(!(get_script_instance() && get_script_instance()->has_method("supports_hmd")), false);
+ return get_script_instance()->call("supports_hmd");
+}
+
+bool ARVRScriptInterface::is_stereo() {
+ ERR_FAIL_COND_V(!(get_script_instance() && get_script_instance()->has_method("is_stereo")), false);
+ return get_script_instance()->call("is_stereo");
+}
+
+bool ARVRScriptInterface::is_initialized() {
+ ERR_FAIL_COND_V(!(get_script_instance() && get_script_instance()->has_method("is_initialized")), false);
+ return get_script_instance()->call("is_initialized");
+}
+
+bool ARVRScriptInterface::initialize() {
+ ERR_FAIL_COND_V(!(get_script_instance() && get_script_instance()->has_method("initialize")), false);
+ return get_script_instance()->call("initialize");
+}
+
+void ARVRScriptInterface::uninitialize() {
+ ARVRServer *arvr_server = ARVRServer::get_singleton();
+ if (arvr_server != NULL) {
+ // Whatever happens, make sure this is no longer our primary interface
+ arvr_server->clear_primary_interface_if(this);
+ }
+
+ ERR_FAIL_COND(!(get_script_instance() && get_script_instance()->has_method("uninitialize")));
+ get_script_instance()->call("uninitialize");
+}
+
+Size2 ARVRScriptInterface::get_recommended_render_targetsize() {
+ ERR_FAIL_COND_V(!(get_script_instance() && get_script_instance()->has_method("get_recommended_render_targetsize")), Size2());
+ return get_script_instance()->call("get_recommended_render_targetsize");
+}
+
+Transform ARVRScriptInterface::get_transform_for_eye(Eyes p_eye, const Transform &p_cam_transform) {
+ ERR_FAIL_COND_V(!(get_script_instance() && get_script_instance()->has_method("get_transform_for_eye")), Transform());
+ return get_script_instance()->call("get_transform_for_eye", p_eye, p_cam_transform);
+}
+
+// Suggestion from Reduz, as we can't return a CameraMatrix, return a PoolVector with our 16 floats
+PoolVector<float> ARVRScriptInterface::_get_projection_for_eye(Eyes p_eye, real_t p_aspect, real_t p_z_near, real_t p_z_far) {
+ ERR_FAIL_COND_V(!(get_script_instance() && get_script_instance()->has_method("_get_projection_for_eye")), PoolVector<float>());
+ return get_script_instance()->call("_get_projection_for_eye", p_eye, p_aspect, p_z_near, p_z_far);
+}
+
+CameraMatrix ARVRScriptInterface::get_projection_for_eye(Eyes p_eye, real_t p_aspect, real_t p_z_near, real_t p_z_far) {
+ CameraMatrix cm;
+ int i = 0;
+ int j = 0;
+
+ PoolVector<float> cm_as_floats = _get_projection_for_eye(p_eye, p_aspect, p_z_near, p_z_far);
+
+ for (int k = 0; k < cm_as_floats.size() && i < 4; k++) {
+ cm.matrix[i][j] = cm_as_floats[k];
+ j++;
+ if (j == 4) {
+ j = 0;
+ i++;
+ };
+ };
+
+ return cm;
+}
+
+void ARVRScriptInterface::commit_for_eye(ARVRInterface::Eyes p_eye, RID p_render_target, const Rect2 &p_screen_rect) {
+ ERR_FAIL_COND(!(get_script_instance() && get_script_instance()->has_method("commit_for_eye")));
+ get_script_instance()->call("commit_for_eye");
+}
+
+void ARVRScriptInterface::process() {
+ ERR_FAIL_COND(!(get_script_instance() && get_script_instance()->has_method("process")));
+ get_script_instance()->call("process");
+}
+
+void ARVRScriptInterface::_bind_methods() {
+ ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "is_installed"));
+ ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "hmd_is_present"));
+ ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "supports_hmd"));
+
+ ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "is_initialized"));
+ ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "initialize"));
+ ClassDB::add_virtual_method(get_class_static(), MethodInfo("uninitialize"));
+
+ ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "is_stereo"));
+ ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::VECTOR2, "get_recommended_render_targetsize"));
+ ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::TRANSFORM, "get_transform_for_eye", PropertyInfo(Variant::INT, "eye"), PropertyInfo(Variant::TRANSFORM, "cam_transform")));
+ ClassDB::add_virtual_method(get_class_static(), MethodInfo("_get_projection_for_eye"));
+ ClassDB::add_virtual_method(get_class_static(), MethodInfo("commit_for_eye", PropertyInfo(Variant::INT, "eye"), PropertyInfo(Variant::_RID, "render_target")));
+ ClassDB::add_virtual_method(get_class_static(), MethodInfo("process"));
+}
diff --git a/servers/arvr/arvr_script_interface.h b/servers/arvr/arvr_script_interface.h
new file mode 100644
index 0000000000..04ca33901a
--- /dev/null
+++ b/servers/arvr/arvr_script_interface.h
@@ -0,0 +1,47 @@
+#ifndef SCRIPT_INTERFACE_H
+#define SCRIPT_INTERFACE_H
+
+#include "arvr_interface.h"
+
+/**
+ @authors Hinsbart & Karroffel
+
+ This subclass of our AR/VR interface forms a bridge to GDNative.
+*/
+
+class ARVRScriptInterface : public ARVRInterface {
+ GDCLASS(ARVRScriptInterface, ARVRInterface);
+
+protected:
+ static void _bind_methods();
+
+public:
+ ARVRScriptInterface();
+ ~ARVRScriptInterface();
+
+ virtual StringName get_name() const;
+
+ virtual bool is_installed();
+ virtual bool hmd_is_present();
+ virtual bool supports_hmd();
+
+ virtual bool is_initialized();
+ virtual bool initialize();
+ virtual void uninitialize();
+
+ virtual Size2 get_recommended_render_targetsize();
+ virtual bool is_stereo();
+ virtual Transform get_transform_for_eye(ARVRInterface::Eyes p_eye, const Transform &p_cam_transform);
+
+ // we expose a PoolVector<float> version of this function to GDNative
+ PoolVector<float> _get_projection_for_eye(Eyes p_eye, real_t p_aspect, real_t p_z_near, real_t p_z_far);
+
+ // and a CameraMatrix version to ARVRServer
+ virtual CameraMatrix get_projection_for_eye(ARVRInterface::Eyes p_eye, real_t p_aspect, real_t p_z_near, real_t p_z_far);
+
+ virtual void commit_for_eye(ARVRInterface::Eyes p_eye, RID p_render_target, const Rect2 &p_screen_rect);
+
+ virtual void process();
+};
+
+#endif // SCRIPT_INTERFACE_H
diff --git a/servers/arvr_server.cpp b/servers/arvr_server.cpp
new file mode 100644
index 0000000000..78b3e514e6
--- /dev/null
+++ b/servers/arvr_server.cpp
@@ -0,0 +1,313 @@
+/*************************************************************************/
+/* arvr_server.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#include "arvr_server.h"
+#include "arvr/arvr_interface.h"
+#include "arvr/arvr_positional_tracker.h"
+#include "project_settings.h"
+
+ARVRServer *ARVRServer::singleton = NULL;
+
+ARVRServer *ARVRServer::get_singleton() {
+ return singleton;
+};
+
+void ARVRServer::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("get_world_scale"), &ARVRServer::get_world_scale);
+ ClassDB::bind_method(D_METHOD("set_world_scale"), &ARVRServer::set_world_scale);
+ ClassDB::bind_method(D_METHOD("get_reference_frame"), &ARVRServer::get_reference_frame);
+ ClassDB::bind_method(D_METHOD("request_reference_frame", "ignore_tilt", "keep_height"), &ARVRServer::request_reference_frame);
+
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "world_scale"), "set_world_scale", "get_world_scale");
+
+ ClassDB::bind_method(D_METHOD("get_interface_count"), &ARVRServer::get_interface_count);
+ ClassDB::bind_method(D_METHOD("get_interface:ARVRInterface", "idx"), &ARVRServer::get_interface);
+ ClassDB::bind_method(D_METHOD("find_interface:ARVRInterface", "name"), &ARVRServer::find_interface);
+ ClassDB::bind_method(D_METHOD("get_tracker_count"), &ARVRServer::get_tracker_count);
+ ClassDB::bind_method(D_METHOD("get_tracker:ARVRPositionalTracker", "idx"), &ARVRServer::get_tracker);
+
+ ClassDB::bind_method(D_METHOD("set_primary_interface"), &ARVRServer::set_primary_interface);
+
+ ClassDB::bind_method(D_METHOD("add_interface"), &ARVRServer::add_interface);
+ ClassDB::bind_method(D_METHOD("remove_interface"), &ARVRServer::remove_interface);
+
+ BIND_CONSTANT(TRACKER_CONTROLLER);
+ BIND_CONSTANT(TRACKER_BASESTATION);
+ BIND_CONSTANT(TRACKER_ANCHOR);
+ BIND_CONSTANT(TRACKER_UNKNOWN);
+ BIND_CONSTANT(TRACKER_ANY_KNOWN);
+ BIND_CONSTANT(TRACKER_ANY);
+
+ ADD_SIGNAL(MethodInfo("interface_added", PropertyInfo(Variant::STRING, "name")));
+ ADD_SIGNAL(MethodInfo("interface_removed", PropertyInfo(Variant::STRING, "name")));
+
+ ADD_SIGNAL(MethodInfo("tracker_added", PropertyInfo(Variant::STRING, "name"), PropertyInfo(Variant::INT, "type")));
+ ADD_SIGNAL(MethodInfo("tracker_removed", PropertyInfo(Variant::STRING, "name")));
+};
+
+real_t ARVRServer::get_world_scale() const {
+ return world_scale;
+};
+
+void ARVRServer::set_world_scale(real_t p_world_scale) {
+ if (world_scale < 0.01) {
+ world_scale = 0.01;
+ } else if (world_scale > 1000.0) {
+ world_scale = 1000.0;
+ };
+
+ world_scale = p_world_scale;
+};
+
+Transform ARVRServer::get_world_origin() const {
+ return world_origin;
+};
+
+void ARVRServer::set_world_origin(const Transform p_world_origin) {
+ world_origin = p_world_origin;
+};
+
+Transform ARVRServer::get_reference_frame() const {
+ return reference_frame;
+};
+
+void ARVRServer::request_reference_frame(bool p_ignore_tilt, bool p_keep_height) {
+ if (primary_interface != NULL) {
+ // clear our current reference frame or we'll end up double adjusting it
+ reference_frame = Transform();
+
+ // requesting our EYE_MONO transform should return our current HMD position
+ Transform new_reference_frame = primary_interface->get_transform_for_eye(ARVRInterface::EYE_MONO, Transform());
+
+ // remove our tilt
+ if (p_ignore_tilt) {
+ // take the Y out of our Z
+ new_reference_frame.basis.set_axis(2, Vector3(new_reference_frame.basis.elements[0][2], 0.0, new_reference_frame.basis.elements[2][2]).normalized());
+
+ // Y is straight up
+ new_reference_frame.basis.set_axis(1, Vector3(0.0, 1.0, 0.0));
+
+ // and X is our cross reference
+ new_reference_frame.basis.set_axis(0, new_reference_frame.basis.get_axis(1).cross(new_reference_frame.basis.get_axis(2)).normalized());
+ };
+
+ // don't negate our height
+ if (p_keep_height) {
+ new_reference_frame.origin.y = 0.0;
+ };
+
+ reference_frame = new_reference_frame.inverse();
+ };
+};
+
+void ARVRServer::add_interface(const Ref<ARVRInterface> &p_interface) {
+ ERR_FAIL_COND(p_interface.is_null());
+
+ int idx = -1;
+ for (int i = 0; i < interfaces.size(); i++) {
+
+ if (interfaces[i] == p_interface) {
+ ERR_PRINT("Interface was already added");
+ return;
+ };
+ };
+
+ print_line("Registered interface " + p_interface->get_name());
+
+ interfaces.push_back(p_interface);
+ emit_signal("interface_added", p_interface->get_name());
+};
+
+void ARVRServer::remove_interface(const Ref<ARVRInterface> &p_interface) {
+ ERR_FAIL_COND(p_interface.is_null());
+
+ int idx = -1;
+ for (int i = 0; i < interfaces.size(); i++) {
+
+ if (interfaces[i] == p_interface) {
+
+ idx = i;
+ break;
+ };
+ };
+
+ ERR_FAIL_COND(idx == -1);
+
+ print_line("Removed interface" + p_interface->get_name());
+
+ emit_signal("interface_removed", p_interface->get_name());
+ interfaces.remove(idx);
+};
+
+int ARVRServer::get_interface_count() const {
+ return interfaces.size();
+};
+
+Ref<ARVRInterface> ARVRServer::get_interface(int p_index) const {
+ ERR_FAIL_INDEX_V(p_index, interfaces.size(), NULL);
+
+ return interfaces[p_index];
+};
+
+Ref<ARVRInterface> ARVRServer::find_interface(const String &p_name) const {
+ int idx = -1;
+ for (int i = 0; i < interfaces.size(); i++) {
+
+ if (interfaces[i]->get_name() == p_name) {
+
+ idx = i;
+ break;
+ };
+ };
+
+ ERR_FAIL_COND_V(idx == -1, NULL);
+
+ return interfaces[idx];
+};
+
+/*
+ A little extra info on the tracker ids, these are unique per tracker type so we get soem consistency in recognising our trackers, specifically controllers.
+
+ The first controller that is turned of will get ID 1, the second will get ID 2, etc.
+ The magic happens when one of the controllers is turned off, say controller 1 turns off, controller 2 will remain controller 2, controller 3 will remain controller 3.
+ If controller number 1 is turned on again it again gets ID 1 unless another new controller was turned on since.
+
+ The most likely scenario however is a controller that runs out of battery and another controller being used to replace it.
+ Because the controllers are often linked to physical objects, say you're holding a shield in controller 1, your left hand, and a gun in controller 2, your right hand, and controller 1 dies:
+ - using our tracker index would suddenly make the gun disappear and the shield jump into your right hand because controller 2 becomes controller 1.
+ - using this approach the shield disappears or is no longer tracked, but the gun stays firmly in your right hand because that is still controller 2, further more, if controller 1 is replaced the shield will return.
+*/
+
+bool ARVRServer::is_tracker_id_in_use_for_type(TrackerType p_tracker_type, int p_tracker_id) const {
+ for (int i = 0; i < trackers.size(); i++) {
+ if (trackers[i]->get_type() == p_tracker_type && trackers[i]->get_tracker_id() == p_tracker_id) {
+ return true;
+ };
+ };
+
+ // all good
+ return false;
+};
+
+int ARVRServer::get_free_tracker_id_for_type(TrackerType p_tracker_type) {
+ // we start checking at 1, 0 means that it's not a controller..
+ int tracker_id = 1;
+
+ while (is_tracker_id_in_use_for_type(p_tracker_type, tracker_id)) {
+ // try the next one
+ tracker_id++;
+ };
+
+ return tracker_id;
+};
+
+void ARVRServer::add_tracker(ARVRPositionalTracker *p_tracker) {
+ ERR_FAIL_NULL(p_tracker);
+
+ trackers.push_back(p_tracker);
+ emit_signal("tracker_added", p_tracker->get_name(), p_tracker->get_type());
+};
+
+void ARVRServer::remove_tracker(ARVRPositionalTracker *p_tracker) {
+ ERR_FAIL_NULL(p_tracker);
+
+ int idx = -1;
+ for (int i = 0; i < trackers.size(); i++) {
+
+ if (trackers[i] == p_tracker) {
+
+ idx = i;
+ break;
+ };
+ };
+
+ ERR_FAIL_COND(idx == -1);
+
+ emit_signal("tracker_removed", p_tracker->get_name());
+ trackers.remove(idx);
+};
+
+int ARVRServer::get_tracker_count() const {
+ return trackers.size();
+};
+
+ARVRPositionalTracker *ARVRServer::get_tracker(int p_index) const {
+ ERR_FAIL_INDEX_V(p_index, trackers.size(), NULL);
+
+ return trackers[p_index];
+};
+
+ARVRPositionalTracker *ARVRServer::find_by_type_and_id(TrackerType p_tracker_type, int p_tracker_id) const {
+ ERR_FAIL_COND_V(p_tracker_id == 0, NULL);
+
+ for (int i = 0; i < trackers.size(); i++) {
+ if (trackers[i]->get_type() == p_tracker_type && trackers[i]->get_tracker_id() == p_tracker_id) {
+ return trackers[i];
+ };
+ };
+
+ return NULL;
+};
+
+Ref<ARVRInterface> ARVRServer::get_primary_interface() const {
+ return primary_interface;
+};
+
+void ARVRServer::set_primary_interface(const Ref<ARVRInterface> &p_primary_interface) {
+ primary_interface = p_primary_interface;
+
+ print_line("Primary interface set to: " + primary_interface->get_name());
+};
+
+void ARVRServer::clear_primary_interface_if(const Ref<ARVRInterface> &p_primary_interface) {
+ if (primary_interface == p_primary_interface) {
+ print_line("Clearing primary interface");
+ primary_interface.unref();
+ };
+};
+
+ARVRServer::ARVRServer() {
+ singleton = this;
+ world_scale = 1.0;
+};
+
+ARVRServer::~ARVRServer() {
+ primary_interface.unref();
+
+ while (interfaces.size() > 0) {
+ interfaces.remove(0);
+ }
+
+ while (trackers.size() > 0) {
+ trackers.remove(0);
+ }
+
+ singleton = NULL;
+};
diff --git a/servers/arvr_server.h b/servers/arvr_server.h
new file mode 100644
index 0000000000..fd7c5470c3
--- /dev/null
+++ b/servers/arvr_server.h
@@ -0,0 +1,167 @@
+/*************************************************************************/
+/* arvr_server.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#ifndef ARVR_SERVER_H
+#define ARVR_SERVER_H
+
+#include "os/thread_safe.h"
+#include "reference.h"
+#include "rid.h"
+#include "variant.h"
+
+class ARVRInterface;
+class ARVRPositionalTracker;
+
+/**
+ @author Bastiaan Olij <mux213@gmail.com>
+
+ The ARVR server is a singleton object that gives access to the various
+ objects and SDKs that are available on the system.
+ Because there can be multiple SDKs active this is exposed as an array
+ and our ARVR server object acts as a pass through
+ Also each positioning tracker is accessible from here.
+
+ I've added some additional info into this header file that should move
+ into the documention, I will do so when we're close to accepting this PR
+ or as a separate PR once this has been merged into the master branch.
+**/
+
+class ARVRServer : public Object {
+ GDCLASS(ARVRServer, Object);
+ _THREAD_SAFE_CLASS_
+
+public:
+ enum TrackerType {
+ TRACKER_CONTROLLER = 0x01, /* tracks a controller */
+ TRACKER_BASESTATION = 0x02, /* tracks location of a base station */
+ TRACKER_ANCHOR = 0x04, /* tracks an anchor point, used in AR to track a real live location */
+ TRACKER_UNKNOWN = 0x80, /* unknown tracker */
+
+ TRACKER_ANY_KNOWN = 0x7f, /* all except unknown */
+ TRACKER_ANY = 0xff /* used by get_connected_trackers to return all types */
+ };
+
+private:
+ Vector<Ref<ARVRInterface> > interfaces;
+ Vector<ARVRPositionalTracker *> trackers;
+
+ Ref<ARVRInterface> primary_interface; /* we'll identify one interface as primary, this will be used by our viewports */
+
+ real_t world_scale; /* scale by which we multiply our tracker positions */
+ Transform world_origin; /* our world origin point, maps a location in our virtual world to the origin point in our real world tracking volume */
+ Transform reference_frame; /* our reference frame */
+
+ bool is_tracker_id_in_use_for_type(TrackerType p_tracker_type, int p_tracker_id) const;
+
+protected:
+ static ARVRServer *singleton;
+
+ static void _bind_methods();
+
+public:
+ static ARVRServer *get_singleton();
+
+ /*
+ World scale allows you to specify a scale factor that is applied to all positioning vectors in our VR world in essence scaling up, or scaling down the world.
+ For stereoscopic rendering specifically this is very important to give an accurate sense of scale.
+ Add controllers into the mix and an accurate mapping of real world movement to percieved virtual movement becomes very important.
+
+ Most VR platforms, and our assumption, is that 1 unit in our virtual world equates to 1 meter in the real mode.
+ This scale basically effects the unit size relationship to real world size.
+
+ I may remove access to this property in GDScript in favour of exposing it on the ARVROrigin node
+ */
+ real_t get_world_scale() const;
+ void set_world_scale(real_t p_world_scale);
+
+ /*
+ The world maps the 0,0,0 coordinate of our real world coordinate system for our tracking volume to a location in our
+ virtual world. It is this origin point that should be moved when the player is moved through the world by controller
+ actions be it straffing, teleporting, etc. Movement of the player by moving through the physical space is always tracked
+ in relation to this point.
+
+ Note that the ARVROrigin spatial node in your scene automatically updates this property and it should be used instead of
+ direct access to this property and it therefor is not available in GDScript
+
+ Note: this should not be used in AR and should be ignored by an AR based interface as it would throw what you're looking at in the real world
+ and in the virtual world out of sync
+ */
+ Transform get_world_origin() const;
+ void set_world_origin(const Transform p_origin);
+
+ /*
+ Requesting a reference frame results in a matrix being calculated that ensures the HMD is positioned to 0,0,0 facing 0,0,-1 (need to verify this direction)
+ in the virtual world.
+
+ Note: this should not be used in AR and should be ignored by an AR based interface as it would throw what you're looking at in the real world
+ and in the virtual world out of sync
+ */
+ Transform get_reference_frame() const;
+ void request_reference_frame(bool p_ignore_tilt, bool p_keep_height);
+
+ /*
+ Interfaces are objects that 'glue' Godot to an AR or VR SDK such as the Oculus SDK, OpenVR, OpenHMD, etc.
+ */
+ void add_interface(const Ref<ARVRInterface> &p_interface);
+ void remove_interface(const Ref<ARVRInterface> &p_interface);
+ int get_interface_count() const;
+ Ref<ARVRInterface> get_interface(int p_index) const;
+ Ref<ARVRInterface> find_interface(const String &p_name) const;
+
+ /*
+ note, more then one interface can technically be active, especially on mobile, but only one interface is used for
+ rendering. This interface identifies itself by calling set_primary_interface when it is initialized
+ */
+ Ref<ARVRInterface> get_primary_interface() const;
+ void set_primary_interface(const Ref<ARVRInterface> &p_primary_interface);
+ void clear_primary_interface_if(const Ref<ARVRInterface> &p_primary_interface); /* this is automatically called if an interface destructs */
+
+ /*
+ Our trackers are objects that expose the orientation and position of physical devices such as controller, anchor points, etc.
+ They are created and managed by our active AR/VR interfaces.
+
+ Note that for trackers that
+ */
+ int get_free_tracker_id_for_type(TrackerType p_tracker_type);
+ void add_tracker(ARVRPositionalTracker *p_tracker);
+ void remove_tracker(ARVRPositionalTracker *p_tracker);
+ int get_tracker_count() const;
+ ARVRPositionalTracker *get_tracker(int p_index) const;
+ ARVRPositionalTracker *find_by_type_and_id(TrackerType p_tracker_type, int p_tracker_id) const;
+
+ ARVRServer();
+ ~ARVRServer();
+};
+
+#define ARVR ARVRServer
+
+VARIANT_ENUM_CAST(ARVRServer::TrackerType);
+
+#endif
diff --git a/servers/audio/audio_driver_dummy.cpp b/servers/audio/audio_driver_dummy.cpp
index 3aaf73df03..0f15b43b41 100644
--- a/servers/audio/audio_driver_dummy.cpp
+++ b/servers/audio/audio_driver_dummy.cpp
@@ -29,8 +29,8 @@
/*************************************************************************/
#include "audio_driver_dummy.h"
-#include "global_config.h"
#include "os/os.h"
+#include "project_settings.h"
Error AudioDriverDummy::init() {
diff --git a/servers/audio/audio_filter_sw.cpp b/servers/audio/audio_filter_sw.cpp
index 1210312ac5..4bf1cebf12 100644
--- a/servers/audio/audio_filter_sw.cpp
+++ b/servers/audio/audio_filter_sw.cpp
@@ -242,28 +242,49 @@ AudioFilterSW::Processor::Processor() {
set_filter(NULL);
}
-void AudioFilterSW::Processor::set_filter(AudioFilterSW *p_filter) {
+void AudioFilterSW::Processor::set_filter(AudioFilterSW *p_filter, bool p_clear_history) {
- ha1 = ha2 = hb1 = hb2 = 0;
+ if (p_clear_history) {
+ ha1 = ha2 = hb1 = hb2 = 0;
+ }
filter = p_filter;
}
-void AudioFilterSW::Processor::update_coeffs() {
+void AudioFilterSW::Processor::update_coeffs(int p_interp_buffer_len) {
if (!filter)
return;
- filter->prepare_coefficients(&coeffs);
+ if (p_interp_buffer_len) { //interpolate
+ Coeffs old_coeffs = coeffs;
+ filter->prepare_coefficients(&coeffs);
+ incr_coeffs.a1 = (coeffs.a1 - old_coeffs.a1) / p_interp_buffer_len;
+ incr_coeffs.a2 = (coeffs.a2 - old_coeffs.a2) / p_interp_buffer_len;
+ incr_coeffs.b0 = (coeffs.b0 - old_coeffs.b0) / p_interp_buffer_len;
+ incr_coeffs.b1 = (coeffs.b1 - old_coeffs.b1) / p_interp_buffer_len;
+ incr_coeffs.b2 = (coeffs.b2 - old_coeffs.b2) / p_interp_buffer_len;
+ coeffs = old_coeffs;
+ } else {
+ filter->prepare_coefficients(&coeffs);
+ }
}
-void AudioFilterSW::Processor::process(float *p_samples, int p_amount, int p_stride) {
+void AudioFilterSW::Processor::process(float *p_samples, int p_amount, int p_stride, bool p_interpolate) {
if (!filter)
return;
- for (int i = 0; i < p_amount; i++) {
+ if (p_interpolate) {
+ for (int i = 0; i < p_amount; i++) {
+
+ process_one_interp(*p_samples);
+ p_samples += p_stride;
+ }
+ } else {
+ for (int i = 0; i < p_amount; i++) {
- process_one(*p_samples);
- p_samples += p_stride;
+ process_one(*p_samples);
+ p_samples += p_stride;
+ }
}
}
diff --git a/servers/audio/audio_filter_sw.h b/servers/audio/audio_filter_sw.h
index e1dd5e5c0e..f5a07c4c8f 100644
--- a/servers/audio/audio_filter_sw.h
+++ b/servers/audio/audio_filter_sw.h
@@ -60,11 +60,14 @@ public:
AudioFilterSW *filter;
Coeffs coeffs;
float ha1, ha2, hb1, hb2; //history
+ Coeffs incr_coeffs;
+
public:
- void set_filter(AudioFilterSW *p_filter);
- void process(float *p_samples, int p_amount, int p_stride = 1);
- void update_coeffs();
+ void set_filter(AudioFilterSW *p_filter, bool p_clear_history = true);
+ void process(float *p_samples, int p_amount, int p_stride = 1, bool p_interpolate = false);
+ void update_coeffs(int p_interp_buffer_len = 0);
_ALWAYS_INLINE_ void process_one(float &p_sample);
+ _ALWAYS_INLINE_ void process_one_interp(float &p_sample);
Processor();
};
@@ -104,4 +107,20 @@ void AudioFilterSW::Processor::process_one(float &p_val) {
ha1 = p_val;
}
+void AudioFilterSW::Processor::process_one_interp(float &p_val) {
+
+ float pre = p_val;
+ p_val = (p_val * coeffs.b0 + hb1 * coeffs.b1 + hb2 * coeffs.b2 + ha1 * coeffs.a1 + ha2 * coeffs.a2);
+ ha2 = ha1;
+ hb2 = hb1;
+ hb1 = pre;
+ ha1 = p_val;
+
+ coeffs.b0 += incr_coeffs.b0;
+ coeffs.b1 += incr_coeffs.b1;
+ coeffs.b2 += incr_coeffs.b2;
+ coeffs.a1 += incr_coeffs.a1;
+ coeffs.a2 += incr_coeffs.a2;
+}
+
#endif // AUDIO_FILTER_SW_H
diff --git a/servers/audio/audio_stream.cpp b/servers/audio/audio_stream.cpp
index 14a091e27c..aa498cccad 100644
--- a/servers/audio/audio_stream.cpp
+++ b/servers/audio/audio_stream.cpp
@@ -81,3 +81,134 @@ void AudioStreamPlaybackResampled::mix(AudioFrame *p_buffer, float p_rate_scale,
}
}
}
+////////////////////////////////
+
+void AudioStreamRandomPitch::set_audio_stream(const Ref<AudioStream> &p_audio_stream) {
+
+ audio_stream = p_audio_stream;
+ if (audio_stream.is_valid()) {
+ for (Set<AudioStreamPlaybackRandomPitch *>::Element *E = playbacks.front(); E; E = E->next()) {
+ E->get()->playback = audio_stream->instance_playback();
+ }
+ }
+}
+
+Ref<AudioStream> AudioStreamRandomPitch::get_audio_stream() const {
+
+ return audio_stream;
+}
+
+void AudioStreamRandomPitch::set_random_pitch(float p_pitch) {
+
+ if (p_pitch < 1)
+ p_pitch = 1;
+ random_pitch = p_pitch;
+}
+
+float AudioStreamRandomPitch::get_random_pitch() const {
+ return random_pitch;
+}
+
+Ref<AudioStreamPlayback> AudioStreamRandomPitch::instance_playback() {
+ Ref<AudioStreamPlaybackRandomPitch> playback;
+ playback.instance();
+ if (audio_stream.is_valid())
+ playback->playback = audio_stream->instance_playback();
+
+ playbacks.insert(playback.ptr());
+ playback->random_pitch = Ref<AudioStreamRandomPitch>((AudioStreamRandomPitch *)this);
+ return playback;
+}
+
+String AudioStreamRandomPitch::get_stream_name() const {
+
+ if (audio_stream.is_valid()) {
+ return "Random: " + audio_stream->get_name();
+ }
+ return "RandomPitch";
+}
+
+void AudioStreamRandomPitch::_bind_methods() {
+
+ ClassDB::bind_method(D_METHOD("set_audio_stream", "stream"), &AudioStreamRandomPitch::set_audio_stream);
+ ClassDB::bind_method(D_METHOD("get_audio_stream"), &AudioStreamRandomPitch::get_audio_stream);
+
+ ClassDB::bind_method(D_METHOD("set_random_pitch", "scale"), &AudioStreamRandomPitch::set_random_pitch);
+ ClassDB::bind_method(D_METHOD("get_random_pitch"), &AudioStreamRandomPitch::get_random_pitch);
+
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "audio_stream", PROPERTY_HINT_RESOURCE_TYPE, "AudioStream"), "set_audio_stream", "get_audio_stream");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "random_pitch", PROPERTY_HINT_RANGE, "1,16,0.01"), "set_random_pitch", "get_random_pitch");
+}
+
+AudioStreamRandomPitch::AudioStreamRandomPitch() {
+ random_pitch = 1.1;
+}
+
+void AudioStreamPlaybackRandomPitch::start(float p_from_pos) {
+ playing = playback;
+ float range_from = 1.0 / random_pitch->random_pitch;
+ float range_to = random_pitch->random_pitch;
+
+ pitch_scale = range_from + Math::randf() * (range_to - range_from);
+
+ if (playing.is_valid()) {
+ playing->start(p_from_pos);
+ }
+}
+
+void AudioStreamPlaybackRandomPitch::stop() {
+ if (playing.is_valid()) {
+ playing->stop();
+ ;
+ }
+}
+bool AudioStreamPlaybackRandomPitch::is_playing() const {
+ if (playing.is_valid()) {
+ return playing->is_playing();
+ }
+
+ return false;
+}
+
+int AudioStreamPlaybackRandomPitch::get_loop_count() const {
+ if (playing.is_valid()) {
+ return playing->get_loop_count();
+ }
+
+ return 0;
+}
+
+float AudioStreamPlaybackRandomPitch::get_pos() const {
+ if (playing.is_valid()) {
+ return playing->get_pos();
+ }
+
+ return 0;
+}
+void AudioStreamPlaybackRandomPitch::seek_pos(float p_time) {
+ if (playing.is_valid()) {
+ playing->seek_pos(p_time);
+ }
+}
+
+void AudioStreamPlaybackRandomPitch::mix(AudioFrame *p_bufer, float p_rate_scale, int p_frames) {
+ if (playing.is_valid()) {
+ playing->mix(p_bufer, p_rate_scale * pitch_scale, p_frames);
+ } else {
+ for (int i = 0; i < p_frames; i++) {
+ p_bufer[i] = AudioFrame(0, 0);
+ }
+ }
+}
+
+float AudioStreamPlaybackRandomPitch::get_length() const {
+ if (playing.is_valid()) {
+ return playing->get_length();
+ }
+
+ return 0;
+}
+
+AudioStreamPlaybackRandomPitch::~AudioStreamPlaybackRandomPitch() {
+ random_pitch->playbacks.erase(this);
+}
diff --git a/servers/audio/audio_stream.h b/servers/audio/audio_stream.h
index 1cf3cd294d..a35826be21 100644
--- a/servers/audio/audio_stream.h
+++ b/servers/audio/audio_stream.h
@@ -31,6 +31,7 @@
#define AUDIO_STREAM_H
#include "resource.h"
+#include "servers/audio/audio_filter_sw.h"
#include "servers/audio_server.h"
class AudioStreamPlayback : public Reference {
@@ -88,4 +89,58 @@ public:
virtual String get_stream_name() const = 0;
};
+class AudioStreamPlaybackRandomPitch;
+
+class AudioStreamRandomPitch : public AudioStream {
+
+ GDCLASS(AudioStreamRandomPitch, AudioStream)
+ friend class AudioStreamPlaybackRandomPitch;
+
+ Set<AudioStreamPlaybackRandomPitch *> playbacks;
+ Ref<AudioStream> audio_stream;
+ float random_pitch;
+
+protected:
+ static void _bind_methods();
+
+public:
+ void set_audio_stream(const Ref<AudioStream> &audio_stream);
+ Ref<AudioStream> get_audio_stream() const;
+
+ void set_random_pitch(float p_pitch);
+ float get_random_pitch() const;
+
+ virtual Ref<AudioStreamPlayback> instance_playback();
+ virtual String get_stream_name() const;
+
+ AudioStreamRandomPitch();
+};
+
+class AudioStreamPlaybackRandomPitch : public AudioStreamPlayback {
+
+ GDCLASS(AudioStreamPlaybackRandomPitch, AudioStreamPlayback)
+ friend class AudioStreamRandomPitch;
+
+ Ref<AudioStreamRandomPitch> random_pitch;
+ Ref<AudioStreamPlayback> playback;
+ Ref<AudioStreamPlayback> playing;
+ float pitch_scale;
+
+public:
+ virtual void start(float p_from_pos = 0.0);
+ virtual void stop();
+ virtual bool is_playing() const;
+
+ virtual int get_loop_count() const; //times it looped
+
+ virtual float get_pos() const;
+ virtual void seek_pos(float p_time);
+
+ virtual void mix(AudioFrame *p_bufer, float p_rate_scale, int p_frames);
+
+ virtual float get_length() const; //if supported, otherwise return 0
+
+ ~AudioStreamPlaybackRandomPitch();
+};
+
#endif // AUDIO_STREAM_H
diff --git a/servers/audio/effects/audio_effect_compressor.cpp b/servers/audio/effects/audio_effect_compressor.cpp
index 997a620f7c..491e6ecc81 100644
--- a/servers/audio/effects/audio_effect_compressor.cpp
+++ b/servers/audio/effects/audio_effect_compressor.cpp
@@ -32,7 +32,7 @@
void AudioEffectCompressorInstance::process(const AudioFrame *p_src_frames, AudioFrame *p_dst_frames, int p_frame_count) {
- float treshold = Math::db2linear(base->treshold);
+ float threshold = Math::db2linear(base->threshold);
float sample_rate = AudioServer::get_singleton()->get_mix_rate();
float ratatcoef = exp(-1 / (0.00001f * sample_rate));
@@ -66,7 +66,7 @@ void AudioEffectCompressorInstance::process(const AudioFrame *p_src_frames, Audi
float peak = MAX(s.l, s.r);
- float overdb = 2.08136898f * Math::linear2db(peak / treshold);
+ float overdb = 2.08136898f * Math::linear2db(peak / threshold);
if (overdb < 0.0) //we only care about what goes over to compress
overdb = 0.0;
@@ -125,14 +125,14 @@ Ref<AudioEffectInstance> AudioEffectCompressor::instance() {
return ins;
}
-void AudioEffectCompressor::set_treshold(float p_treshold) {
+void AudioEffectCompressor::set_threshold(float p_threshold) {
- treshold = p_treshold;
+ threshold = p_threshold;
}
-float AudioEffectCompressor::get_treshold() const {
+float AudioEffectCompressor::get_threshold() const {
- return treshold;
+ return threshold;
}
void AudioEffectCompressor::set_ratio(float p_ratio) {
@@ -208,8 +208,8 @@ void AudioEffectCompressor::_validate_property(PropertyInfo &property) const {
void AudioEffectCompressor::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_treshold", "treshold"), &AudioEffectCompressor::set_treshold);
- ClassDB::bind_method(D_METHOD("get_treshold"), &AudioEffectCompressor::get_treshold);
+ ClassDB::bind_method(D_METHOD("set_threshold", "threshold"), &AudioEffectCompressor::set_threshold);
+ ClassDB::bind_method(D_METHOD("get_threshold"), &AudioEffectCompressor::get_threshold);
ClassDB::bind_method(D_METHOD("set_ratio", "ratio"), &AudioEffectCompressor::set_ratio);
ClassDB::bind_method(D_METHOD("get_ratio"), &AudioEffectCompressor::get_ratio);
@@ -229,7 +229,7 @@ void AudioEffectCompressor::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_sidechain", "sidechain"), &AudioEffectCompressor::set_sidechain);
ClassDB::bind_method(D_METHOD("get_sidechain"), &AudioEffectCompressor::get_sidechain);
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "treshold", PROPERTY_HINT_RANGE, "-60,0,0.1"), "set_treshold", "get_treshold");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "threshold", PROPERTY_HINT_RANGE, "-60,0,0.1"), "set_threshold", "get_threshold");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "ratio", PROPERTY_HINT_RANGE, "1,48,0.1"), "set_ratio", "get_ratio");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "gain", PROPERTY_HINT_RANGE, "-20,20,0.1"), "set_gain", "get_gain");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "attack_us", PROPERTY_HINT_RANGE, "20,2000,1"), "set_attack_us", "get_attack_us");
@@ -239,7 +239,7 @@ void AudioEffectCompressor::_bind_methods() {
}
AudioEffectCompressor::AudioEffectCompressor() {
- treshold = 0;
+ threshold = 0;
ratio = 4;
gain = 0;
attack_us = 20;
diff --git a/servers/audio/effects/audio_effect_compressor.h b/servers/audio/effects/audio_effect_compressor.h
index a624370962..550302056c 100644
--- a/servers/audio/effects/audio_effect_compressor.h
+++ b/servers/audio/effects/audio_effect_compressor.h
@@ -51,7 +51,7 @@ class AudioEffectCompressor : public AudioEffect {
GDCLASS(AudioEffectCompressor, AudioEffect)
friend class AudioEffectCompressorInstance;
- float treshold;
+ float threshold;
float ratio;
float gain;
float attack_us;
@@ -66,8 +66,8 @@ protected:
public:
Ref<AudioEffectInstance> instance();
- void set_treshold(float p_treshold);
- float get_treshold() const;
+ void set_threshold(float p_threshold);
+ float get_threshold() const;
void set_ratio(float p_ratio);
float get_ratio() const;
diff --git a/servers/audio/effects/audio_effect_limiter.cpp b/servers/audio/effects/audio_effect_limiter.cpp
index e049e5d53a..9f39db0440 100644
--- a/servers/audio/effects/audio_effect_limiter.cpp
+++ b/servers/audio/effects/audio_effect_limiter.cpp
@@ -31,8 +31,8 @@
void AudioEffectLimiterInstance::process(const AudioFrame *p_src_frames, AudioFrame *p_dst_frames, int p_frame_count) {
- float thresh = Math::db2linear(base->treshold);
- float threshdb = base->treshold;
+ float thresh = Math::db2linear(base->threshold);
+ float threshdb = base->threshold;
float ceiling = Math::db2linear(base->ceiling);
float ceildb = base->ceiling;
float makeup = Math::db2linear(ceildb - threshdb);
@@ -81,14 +81,14 @@ Ref<AudioEffectInstance> AudioEffectLimiter::instance() {
return ins;
}
-void AudioEffectLimiter::set_treshold_db(float p_treshold) {
+void AudioEffectLimiter::set_threshold_db(float p_threshold) {
- treshold = p_treshold;
+ threshold = p_threshold;
}
-float AudioEffectLimiter::get_treshold_db() const {
+float AudioEffectLimiter::get_threshold_db() const {
- return treshold;
+ return threshold;
}
void AudioEffectLimiter::set_ceiling_db(float p_ceiling) {
@@ -123,8 +123,8 @@ void AudioEffectLimiter::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_ceiling_db", "ceiling"), &AudioEffectLimiter::set_ceiling_db);
ClassDB::bind_method(D_METHOD("get_ceiling_db"), &AudioEffectLimiter::get_ceiling_db);
- ClassDB::bind_method(D_METHOD("set_treshold_db", "treshold"), &AudioEffectLimiter::set_treshold_db);
- ClassDB::bind_method(D_METHOD("get_treshold_db"), &AudioEffectLimiter::get_treshold_db);
+ ClassDB::bind_method(D_METHOD("set_threshold_db", "threshold"), &AudioEffectLimiter::set_threshold_db);
+ ClassDB::bind_method(D_METHOD("get_threshold_db"), &AudioEffectLimiter::get_threshold_db);
ClassDB::bind_method(D_METHOD("set_soft_clip_db", "soft_clip"), &AudioEffectLimiter::set_soft_clip_db);
ClassDB::bind_method(D_METHOD("get_soft_clip_db"), &AudioEffectLimiter::get_soft_clip_db);
@@ -133,13 +133,13 @@ void AudioEffectLimiter::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_soft_clip_ratio"), &AudioEffectLimiter::get_soft_clip_ratio);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "ceiling_db", PROPERTY_HINT_RANGE, "-20,-0.1,0.1"), "set_ceiling_db", "get_ceiling_db");
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "treshold_db", PROPERTY_HINT_RANGE, "-30,0,0.1"), "set_treshold_db", "get_treshold_db");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "threshold_db", PROPERTY_HINT_RANGE, "-30,0,0.1"), "set_threshold_db", "get_threshold_db");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "soft_clip_db", PROPERTY_HINT_RANGE, "0,6,0.1"), "set_soft_clip_db", "get_soft_clip_db");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "soft_clip_ratio", PROPERTY_HINT_RANGE, "3,20,0.1"), "set_soft_clip_ratio", "get_soft_clip_ratio");
}
AudioEffectLimiter::AudioEffectLimiter() {
- treshold = 0;
+ threshold = 0;
ceiling = -0.1;
soft_clip = 2;
soft_clip_ratio = 10;
diff --git a/servers/audio/effects/audio_effect_limiter.h b/servers/audio/effects/audio_effect_limiter.h
index a684eccbfa..e15ffe5b34 100644
--- a/servers/audio/effects/audio_effect_limiter.h
+++ b/servers/audio/effects/audio_effect_limiter.h
@@ -49,7 +49,7 @@ class AudioEffectLimiter : public AudioEffect {
GDCLASS(AudioEffectLimiter, AudioEffect)
friend class AudioEffectLimiterInstance;
- float treshold;
+ float threshold;
float ceiling;
float soft_clip;
float soft_clip_ratio;
@@ -58,8 +58,8 @@ protected:
static void _bind_methods();
public:
- void set_treshold_db(float p_treshold);
- float get_treshold_db() const;
+ void set_threshold_db(float p_threshold);
+ float get_threshold_db() const;
void set_ceiling_db(float p_ceiling);
float get_ceiling_db() const;
diff --git a/servers/audio_server.cpp b/servers/audio_server.cpp
index 095e66ed37..5303aea6d0 100644
--- a/servers/audio_server.cpp
+++ b/servers/audio_server.cpp
@@ -28,10 +28,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "audio_server.h"
-#include "global_config.h"
#include "io/resource_loader.h"
#include "os/file_access.h"
#include "os/os.h"
+#include "project_settings.h"
#include "servers/audio/effects/audio_effect_compressor.h"
#ifdef TOOLS_ENABLED
@@ -252,7 +252,7 @@ void AudioServer::_mix_step() {
if (!bus->channels[k].used) {
//see if any audio is contained, because channel was not used
- if (MAX(peak.r, peak.l) > Math::db2linear(channel_disable_treshold_db)) {
+ if (MAX(peak.r, peak.l) > Math::db2linear(channel_disable_threshold_db)) {
bus->channels[k].last_mix_with_audio = mix_frames;
} else if (mix_frames - bus->channels[k].last_mix_with_audio > channel_disable_frames) {
bus->channels[k].active = false;
@@ -515,6 +515,15 @@ String AudioServer::get_bus_name(int p_bus) const {
return buses[p_bus]->name;
}
+int AudioServer::get_bus_index(const StringName &p_bus_name) const {
+ for (int i = 0; i < buses.size(); ++i) {
+ if (buses[i]->name == p_bus_name) {
+ return i;
+ }
+ }
+ return -1;
+}
+
void AudioServer::set_bus_volume_db(int p_bus, float p_volume_db) {
ERR_FAIL_INDEX(p_bus, buses.size());
@@ -713,7 +722,7 @@ bool AudioServer::is_bus_channel_active(int p_bus, int p_channel) const {
void AudioServer::init() {
- channel_disable_treshold_db = GLOBAL_DEF("audio/channel_disable_treshold_db", -60.0);
+ channel_disable_threshold_db = GLOBAL_DEF("audio/channel_disable_threshold_db", -60.0);
channel_disable_frames = float(GLOBAL_DEF("audio/channel_disable_time", 2.0)) * get_mix_rate();
buffer_size = 1024; //harcoded for now
switch (get_speaker_mode()) {
@@ -958,6 +967,7 @@ void AudioServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_bus_name", "bus_idx", "name"), &AudioServer::set_bus_name);
ClassDB::bind_method(D_METHOD("get_bus_name", "bus_idx"), &AudioServer::get_bus_name);
+ ClassDB::bind_method(D_METHOD("get_bus_index", "bus_name"), &AudioServer::get_bus_index);
ClassDB::bind_method(D_METHOD("set_bus_volume_db", "bus_idx", "volume_db"), &AudioServer::set_bus_volume_db);
ClassDB::bind_method(D_METHOD("get_bus_volume_db", "bus_idx"), &AudioServer::get_bus_volume_db);
@@ -974,10 +984,10 @@ void AudioServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_bus_bypass_effects", "bus_idx", "enable"), &AudioServer::set_bus_bypass_effects);
ClassDB::bind_method(D_METHOD("is_bus_bypassing_effects", "bus_idx"), &AudioServer::is_bus_bypassing_effects);
- ClassDB::bind_method(D_METHOD("add_bus_effect", "bus_idx", "effect:AudioEffect"), &AudioServer::add_bus_effect, DEFVAL(-1));
+ ClassDB::bind_method(D_METHOD("add_bus_effect", "bus_idx", "effect:AudioEffect", "at_pos"), &AudioServer::add_bus_effect, DEFVAL(-1));
ClassDB::bind_method(D_METHOD("remove_bus_effect", "bus_idx", "effect_idx"), &AudioServer::remove_bus_effect);
- ClassDB::bind_method(D_METHOD("get_bus_effect_count", "bus_idx"), &AudioServer::add_bus_effect);
+ ClassDB::bind_method(D_METHOD("get_bus_effect_count", "bus_idx"), &AudioServer::get_bus_effect_count);
ClassDB::bind_method(D_METHOD("get_bus_effect:AudioEffect", "bus_idx", "effect_idx"), &AudioServer::get_bus_effect);
ClassDB::bind_method(D_METHOD("swap_bus_effects", "bus_idx", "effect_idx", "by_effect_idx"), &AudioServer::swap_bus_effects);
diff --git a/servers/audio_server.h b/servers/audio_server.h
index f4c22c0b33..caa07891f7 100644
--- a/servers/audio_server.h
+++ b/servers/audio_server.h
@@ -113,7 +113,7 @@ private:
uint64_t mix_count;
uint64_t mix_frames;
- float channel_disable_treshold_db;
+ float channel_disable_threshold_db;
uint32_t channel_disable_frames;
int to_mix;
@@ -215,6 +215,7 @@ public:
void set_bus_name(int p_bus, const String &p_name);
String get_bus_name(int p_bus) const;
+ int get_bus_index(const StringName &p_bus_name) const;
void set_bus_volume_db(int p_bus, float p_volume_db);
float get_bus_volume_db(int p_bus) const;
diff --git a/servers/physics/area_pair_sw.cpp b/servers/physics/area_pair_sw.cpp
index 8ec001709d..5c418c473f 100644
--- a/servers/physics/area_pair_sw.cpp
+++ b/servers/physics/area_pair_sw.cpp
@@ -32,12 +32,13 @@
bool AreaPairSW::setup(real_t p_step) {
- if (!area->test_collision_mask(body)) {
- colliding = false;
- return false;
- }
+ bool result = false;
- bool result = CollisionSolverSW::solve_static(body->get_shape(body_shape), body->get_transform() * body->get_shape_transform(body_shape), area->get_shape(area_shape), area->get_transform() * area->get_shape_transform(area_shape), NULL, this);
+ if (area->is_shape_set_as_disabled(area_shape) || body->is_shape_set_as_disabled(body_shape)) {
+ result = false;
+ } else if (area->test_collision_mask(body) && CollisionSolverSW::solve_static(body->get_shape(body_shape), body->get_transform() * body->get_shape_transform(body_shape), area->get_shape(area_shape), area->get_transform() * area->get_shape_transform(area_shape), NULL, this)) {
+ result = true;
+ }
if (result != colliding) {
@@ -95,14 +96,13 @@ AreaPairSW::~AreaPairSW() {
bool Area2PairSW::setup(real_t p_step) {
- if (!area_a->test_collision_mask(area_b)) {
- colliding = false;
- return false;
+ bool result = false;
+ if (area_a->is_shape_set_as_disabled(shape_a) || area_b->is_shape_set_as_disabled(shape_b)) {
+ result = false;
+ } else if (area_a->test_collision_mask(area_b) && CollisionSolverSW::solve_static(area_a->get_shape(shape_a), area_a->get_transform() * area_a->get_shape_transform(shape_a), area_b->get_shape(shape_b), area_b->get_transform() * area_b->get_shape_transform(shape_b), NULL, this)) {
+ result = true;
}
- //bool result = area_a->test_collision_mask(area_b) && CollisionSolverSW::solve(area_a->get_shape(shape_a),area_a->get_transform() * area_a->get_shape_transform(shape_a),Vector2(),area_b->get_shape(shape_b),area_b->get_transform() * area_b->get_shape_transform(shape_b),Vector2(),NULL,this);
- bool result = CollisionSolverSW::solve_static(area_a->get_shape(shape_a), area_a->get_transform() * area_a->get_shape_transform(shape_a), area_b->get_shape(shape_b), area_b->get_transform() * area_b->get_shape_transform(shape_b), NULL, this);
-
if (result != colliding) {
if (result) {
diff --git a/servers/physics/body_pair_sw.cpp b/servers/physics/body_pair_sw.cpp
index d740d3c384..9ada1fbc50 100644
--- a/servers/physics/body_pair_sw.cpp
+++ b/servers/physics/body_pair_sw.cpp
@@ -214,6 +214,11 @@ bool BodyPairSW::setup(real_t p_step) {
return false;
}
+ if (A->is_shape_set_as_disabled(shape_A) || B->is_shape_set_as_disabled(shape_B)) {
+ collided = false;
+ return false;
+ }
+
offset_B = B->get_transform().get_origin() - A->get_transform().get_origin();
validate_contacts();
@@ -313,12 +318,6 @@ bool BodyPairSW::setup(real_t p_step) {
B->add_contact(global_B, c.normal, depth, shape_B, global_A, shape_A, A->get_instance_id(), A->get_self(), crB);
}
- if (A->is_shape_set_as_trigger(shape_A) || B->is_shape_set_as_trigger(shape_B) || (A->get_mode() <= PhysicsServer::BODY_MODE_KINEMATIC && B->get_mode() <= PhysicsServer::BODY_MODE_KINEMATIC)) {
- c.active = false;
- collided = false;
- continue;
- }
-
c.active = true;
// Precompute normal mass, tangent mass, and bias.
diff --git a/servers/physics/body_sw.cpp b/servers/physics/body_sw.cpp
index 715f93c1c1..1f32c059a8 100644
--- a/servers/physics/body_sw.cpp
+++ b/servers/physics/body_sw.cpp
@@ -706,7 +706,7 @@ bool BodySW::sleep_test(real_t p_step) {
else if (!can_sleep)
return false;
- if (Math::abs(angular_velocity.length()) < get_space()->get_body_angular_velocity_sleep_treshold() && Math::abs(linear_velocity.length_squared()) < get_space()->get_body_linear_velocity_sleep_treshold() * get_space()->get_body_linear_velocity_sleep_treshold()) {
+ if (Math::abs(angular_velocity.length()) < get_space()->get_body_angular_velocity_sleep_threshold() && Math::abs(linear_velocity.length_squared()) < get_space()->get_body_linear_velocity_sleep_threshold() * get_space()->get_body_linear_velocity_sleep_threshold()) {
still_time += p_step;
diff --git a/servers/physics/broad_phase_basic.cpp b/servers/physics/broad_phase_basic.cpp
index 77d8538574..679b9a31fc 100644
--- a/servers/physics/broad_phase_basic.cpp
+++ b/servers/physics/broad_phase_basic.cpp
@@ -105,6 +105,26 @@ int BroadPhaseBasic::get_subindex(ID p_id) const {
return E->get().subindex;
}
+int BroadPhaseBasic::cull_point(const Vector3 &p_point, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices) {
+
+ int rc = 0;
+
+ for (Map<ID, Element>::Element *E = element_map.front(); E; E = E->next()) {
+
+ const Rect3 aabb = E->get().aabb;
+ if (aabb.has_point(p_point)) {
+
+ p_results[rc] = E->get().owner;
+ p_result_indices[rc] = E->get().subindex;
+ rc++;
+ if (rc >= p_max_results)
+ break;
+ }
+ }
+
+ return rc;
+}
+
int BroadPhaseBasic::cull_segment(const Vector3 &p_from, const Vector3 &p_to, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices) {
int rc = 0;
diff --git a/servers/physics/broad_phase_basic.h b/servers/physics/broad_phase_basic.h
index a285204a32..8dabf72f11 100644
--- a/servers/physics/broad_phase_basic.h
+++ b/servers/physics/broad_phase_basic.h
@@ -91,6 +91,7 @@ public:
virtual bool is_static(ID p_id) const;
virtual int get_subindex(ID p_id) const;
+ virtual int cull_point(const Vector3 &p_point, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL);
virtual int cull_segment(const Vector3 &p_from, const Vector3 &p_to, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL);
virtual int cull_aabb(const Rect3 &p_aabb, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL);
diff --git a/servers/physics/broad_phase_octree.cpp b/servers/physics/broad_phase_octree.cpp
index d18da1b238..2439fbeae9 100644
--- a/servers/physics/broad_phase_octree.cpp
+++ b/servers/physics/broad_phase_octree.cpp
@@ -66,6 +66,11 @@ int BroadPhaseOctree::get_subindex(ID p_id) const {
return octree.get_subindex(p_id);
}
+int BroadPhaseOctree::cull_point(const Vector3 &p_point, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices) {
+
+ return octree.cull_point(p_point, p_results, p_max_results, p_result_indices);
+}
+
int BroadPhaseOctree::cull_segment(const Vector3 &p_from, const Vector3 &p_to, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices) {
return octree.cull_segment(p_from, p_to, p_results, p_max_results, p_result_indices);
diff --git a/servers/physics/broad_phase_octree.h b/servers/physics/broad_phase_octree.h
index 086fb0a1a3..88d72a2bd8 100644
--- a/servers/physics/broad_phase_octree.h
+++ b/servers/physics/broad_phase_octree.h
@@ -56,6 +56,7 @@ public:
virtual bool is_static(ID p_id) const;
virtual int get_subindex(ID p_id) const;
+ virtual int cull_point(const Vector3 &p_point, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL);
virtual int cull_segment(const Vector3 &p_from, const Vector3 &p_to, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL);
virtual int cull_aabb(const Rect3 &p_aabb, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL);
diff --git a/servers/physics/broad_phase_sw.h b/servers/physics/broad_phase_sw.h
index 8fe901c8ef..5564cf5077 100644
--- a/servers/physics/broad_phase_sw.h
+++ b/servers/physics/broad_phase_sw.h
@@ -57,6 +57,7 @@ public:
virtual bool is_static(ID p_id) const = 0;
virtual int get_subindex(ID p_id) const = 0;
+ virtual int cull_point(const Vector3 &p_point, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL) = 0;
virtual int cull_segment(const Vector3 &p_from, const Vector3 &p_to, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL) = 0;
virtual int cull_aabb(const Rect3 &p_aabb, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL) = 0;
diff --git a/servers/physics/collision_object_sw.h b/servers/physics/collision_object_sw.h
index 15082a0551..a56253e33d 100644
--- a/servers/physics/collision_object_sw.h
+++ b/servers/physics/collision_object_sw.h
@@ -64,9 +64,9 @@ private:
Rect3 aabb_cache; //for rayqueries
real_t area_cache;
ShapeSW *shape;
- bool trigger;
+ bool disabled;
- Shape() { trigger = false; }
+ Shape() { disabled = false; }
};
Vector<Shape> shapes;
@@ -131,8 +131,8 @@ public:
_FORCE_INLINE_ void set_ray_pickable(bool p_enable) { ray_pickable = p_enable; }
_FORCE_INLINE_ bool is_ray_pickable() const { return ray_pickable; }
- _FORCE_INLINE_ void set_shape_as_trigger(int p_idx, bool p_enable) { shapes[p_idx].trigger = p_enable; }
- _FORCE_INLINE_ bool is_shape_set_as_trigger(int p_idx) const { return shapes[p_idx].trigger; }
+ _FORCE_INLINE_ void set_shape_as_disabled(int p_idx, bool p_enable) { shapes[p_idx].disabled = p_enable; }
+ _FORCE_INLINE_ bool is_shape_set_as_disabled(int p_idx) const { return shapes[p_idx].disabled; }
_FORCE_INLINE_ void set_collision_layer(uint32_t p_layer) { collision_layer = p_layer; }
_FORCE_INLINE_ uint32_t get_collision_layer() const { return collision_layer; }
diff --git a/servers/physics/collision_solver_sat.cpp b/servers/physics/collision_solver_sat.cpp
index 427a75cf93..128f78e46e 100644
--- a/servers/physics/collision_solver_sat.cpp
+++ b/servers/physics/collision_solver_sat.cpp
@@ -30,7 +30,7 @@
#include "collision_solver_sat.h"
#include "geometry.h"
-#define _EDGE_IS_VALID_SUPPORT_TRESHOLD 0.02
+#define _EDGE_IS_VALID_SUPPORT_THRESHOLD 0.02
struct _CollectorCallback {
diff --git a/servers/physics/physics_server_sw.cpp b/servers/physics/physics_server_sw.cpp
index 455863da91..101bd4b185 100644
--- a/servers/physics/physics_server_sw.cpp
+++ b/servers/physics/physics_server_sw.cpp
@@ -330,6 +330,14 @@ void PhysicsServerSW::area_clear_shapes(RID p_area) {
area->remove_shape(0);
}
+void PhysicsServerSW::area_set_shape_disabled(RID p_area, int p_shape_idx, bool p_disabled) {
+
+ AreaSW *area = area_owner.get(p_area);
+ ERR_FAIL_COND(!area);
+ ERR_FAIL_INDEX(p_shape_idx, area->get_shape_count());
+ area->set_shape_as_disabled(p_shape_idx, p_disabled);
+}
+
void PhysicsServerSW::area_attach_object_instance_ID(RID p_area, ObjectID p_ID) {
if (space_owner.owns(p_area)) {
@@ -551,21 +559,12 @@ RID PhysicsServerSW::body_get_shape(RID p_body, int p_shape_idx) const {
return shape->get_self();
}
-void PhysicsServerSW::body_set_shape_as_trigger(RID p_body, int p_shape_idx, bool p_enable) {
+void PhysicsServerSW::body_set_shape_disabled(RID p_body, int p_shape_idx, bool p_disabled) {
BodySW *body = body_owner.get(p_body);
ERR_FAIL_COND(!body);
ERR_FAIL_INDEX(p_shape_idx, body->get_shape_count());
- body->set_shape_as_trigger(p_shape_idx, p_enable);
-}
-
-bool PhysicsServerSW::body_is_shape_set_as_trigger(RID p_body, int p_shape_idx) const {
-
- BodySW *body = body_owner.get(p_body);
- ERR_FAIL_COND_V(!body, false);
- ERR_FAIL_INDEX_V(p_shape_idx, body->get_shape_count(), false);
-
- return body->is_shape_set_as_trigger(p_shape_idx);
+ body->set_shape_as_disabled(p_shape_idx, p_disabled);
}
Transform PhysicsServerSW::body_get_shape_transform(RID p_body, int p_shape_idx) const {
@@ -812,13 +811,13 @@ void PhysicsServerSW::body_get_collision_exceptions(RID p_body, List<RID> *p_exc
}
};
-void PhysicsServerSW::body_set_contacts_reported_depth_treshold(RID p_body, real_t p_treshold) {
+void PhysicsServerSW::body_set_contacts_reported_depth_threshold(RID p_body, real_t p_threshold) {
BodySW *body = body_owner.get(p_body);
ERR_FAIL_COND(!body);
};
-real_t PhysicsServerSW::body_get_contacts_reported_depth_treshold(RID p_body) const {
+real_t PhysicsServerSW::body_get_contacts_reported_depth_threshold(RID p_body) const {
BodySW *body = body_owner.get(p_body);
ERR_FAIL_COND_V(!body, 0);
@@ -875,6 +874,16 @@ bool PhysicsServerSW::body_is_ray_pickable(RID p_body) const {
return body->is_ray_pickable();
}
+bool PhysicsServerSW::body_test_motion(RID p_body, const Transform &p_from, const Vector3 &p_motion, float p_margin, MotionResult *r_result) {
+
+ BodySW *body = body_owner.get(p_body);
+ ERR_FAIL_COND_V(!body, false);
+ ERR_FAIL_COND_V(!body->get_space(), false);
+ ERR_FAIL_COND_V(body->get_space()->is_locked(), false);
+
+ return body->get_space()->test_body_motion(body, p_from, p_motion, p_margin, r_result);
+}
+
/* JOINT API */
RID PhysicsServerSW::joint_create_pin(RID p_body_A, const Vector3 &p_local_A, RID p_body_B, const Vector3 &p_local_B) {
@@ -1530,8 +1539,9 @@ void PhysicsServerSW::_shape_col_cbk(const Vector3 &p_point_A, const Vector3 &p_
}
}
+PhysicsServerSW *PhysicsServerSW::singleton = NULL;
PhysicsServerSW::PhysicsServerSW() {
-
+ singleton = this;
BroadPhaseSW::create_func = BroadPhaseOctree::_create;
island_count = 0;
active_objects = 0;
diff --git a/servers/physics/physics_server_sw.h b/servers/physics/physics_server_sw.h
index 559e9aeb51..591fe4af46 100644
--- a/servers/physics/physics_server_sw.h
+++ b/servers/physics/physics_server_sw.h
@@ -63,6 +63,8 @@ class PhysicsServerSW : public PhysicsServer {
//void _clear_query(QuerySW *p_query);
public:
+ static PhysicsServerSW *singleton;
+
struct CollCbkData {
int max;
@@ -117,6 +119,8 @@ public:
virtual void area_remove_shape(RID p_area, int p_shape_idx);
virtual void area_clear_shapes(RID p_area);
+ virtual void area_set_shape_disabled(RID p_area, int p_shape_idx, bool p_disabled);
+
virtual void area_attach_object_instance_ID(RID p_area, ObjectID p_ID);
virtual ObjectID area_get_object_instance_ID(RID p_area) const;
@@ -156,8 +160,7 @@ public:
virtual RID body_get_shape(RID p_body, int p_shape_idx) const;
virtual Transform body_get_shape_transform(RID p_body, int p_shape_idx) const;
- virtual void body_set_shape_as_trigger(RID p_body, int p_shape_idx, bool p_enable);
- virtual bool body_is_shape_set_as_trigger(RID p_body, int p_shape_idx) const;
+ virtual void body_set_shape_disabled(RID p_body, int p_shape_idx, bool p_disabled);
virtual void body_remove_shape(RID p_body, int p_shape_idx);
virtual void body_clear_shapes(RID p_body);
@@ -200,8 +203,8 @@ public:
virtual void body_remove_collision_exception(RID p_body, RID p_body_b);
virtual void body_get_collision_exceptions(RID p_body, List<RID> *p_exceptions);
- virtual void body_set_contacts_reported_depth_treshold(RID p_body, real_t p_treshold);
- virtual real_t body_get_contacts_reported_depth_treshold(RID p_body) const;
+ virtual void body_set_contacts_reported_depth_threshold(RID p_body, real_t p_threshold);
+ virtual real_t body_get_contacts_reported_depth_threshold(RID p_body) const;
virtual void body_set_omit_force_integration(RID p_body, bool p_omit);
virtual bool body_is_omitting_force_integration(RID p_body) const;
@@ -214,6 +217,8 @@ public:
virtual void body_set_ray_pickable(RID p_body, bool p_enable);
virtual bool body_is_ray_pickable(RID p_body) const;
+ virtual bool body_test_motion(RID p_body, const Transform &p_from, const Vector3 &p_motion, float p_margin = 0.001, MotionResult *r_result = NULL);
+
/* JOINT API */
virtual RID joint_create_pin(RID p_body_A, const Vector3 &p_local_A, RID p_body_B, const Vector3 &p_local_B);
diff --git a/servers/physics/shape_sw.cpp b/servers/physics/shape_sw.cpp
index 7b3df37a63..b4004c8c94 100644
--- a/servers/physics/shape_sw.cpp
+++ b/servers/physics/shape_sw.cpp
@@ -32,8 +32,8 @@
#include "quick_hull.h"
#include "sort.h"
#define _POINT_SNAP 0.001953125
-#define _EDGE_IS_VALID_SUPPORT_TRESHOLD 0.0002
-#define _FACE_IS_VALID_SUPPORT_TRESHOLD 0.9998
+#define _EDGE_IS_VALID_SUPPORT_THRESHOLD 0.0002
+#define _FACE_IS_VALID_SUPPORT_THRESHOLD 0.9998
void ShapeSW::configure(const Rect3 &p_aabb) {
aabb = p_aabb;
@@ -117,6 +117,20 @@ bool PlaneShapeSW::intersect_segment(const Vector3 &p_begin, const Vector3 &p_en
return inters;
}
+bool PlaneShapeSW::intersect_point(const Vector3 &p_point) const {
+
+ return plane.distance_to(p_point) < 0;
+}
+
+Vector3 PlaneShapeSW::get_closest_point_to(const Vector3 &p_point) const {
+
+ if (plane.is_point_over(p_point)) {
+ return plane.project(p_point);
+ } else {
+ return p_point;
+ }
+}
+
Vector3 PlaneShapeSW::get_moment_of_inertia(real_t p_mass) const {
return Vector3(); //wtf
@@ -165,7 +179,7 @@ Vector3 RayShapeSW::get_support(const Vector3 &p_normal) const {
void RayShapeSW::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount) const {
- if (Math::abs(p_normal.z) < _EDGE_IS_VALID_SUPPORT_TRESHOLD) {
+ if (Math::abs(p_normal.z) < _EDGE_IS_VALID_SUPPORT_THRESHOLD) {
r_amount = 2;
r_supports[0] = Vector3(0, 0, 0);
@@ -184,6 +198,21 @@ bool RayShapeSW::intersect_segment(const Vector3 &p_begin, const Vector3 &p_end,
return false; //simply not possible
}
+bool RayShapeSW::intersect_point(const Vector3 &p_point) const {
+
+ return false; //simply not possible
+}
+
+Vector3 RayShapeSW::get_closest_point_to(const Vector3 &p_point) const {
+
+ Vector3 s[2] = {
+ Vector3(0, 0, 0),
+ Vector3(0, 0, length)
+ };
+
+ return Geometry::get_closest_point_to_segment(p_point, s);
+}
+
Vector3 RayShapeSW::get_moment_of_inertia(real_t p_mass) const {
return Vector3();
@@ -245,6 +274,20 @@ bool SphereShapeSW::intersect_segment(const Vector3 &p_begin, const Vector3 &p_e
return Geometry::segment_intersects_sphere(p_begin, p_end, Vector3(), radius, &r_result, &r_normal);
}
+bool SphereShapeSW::intersect_point(const Vector3 &p_point) const {
+
+ return p_point.length() < radius;
+}
+
+Vector3 SphereShapeSW::get_closest_point_to(const Vector3 &p_point) const {
+
+ Vector3 p = p_point;
+ float l = p.length();
+ if (l < radius)
+ return p_point;
+ return (p / l) * radius;
+}
+
Vector3 SphereShapeSW::get_moment_of_inertia(real_t p_mass) const {
real_t s = 0.4 * p_mass * radius * radius;
@@ -306,7 +349,7 @@ void BoxShapeSW::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_sup
Vector3 axis;
axis[i] = 1.0;
real_t dot = p_normal.dot(axis);
- if (Math::abs(dot) > _FACE_IS_VALID_SUPPORT_TRESHOLD) {
+ if (Math::abs(dot) > _FACE_IS_VALID_SUPPORT_THRESHOLD) {
//Vector3 axis_b;
@@ -350,7 +393,7 @@ void BoxShapeSW::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_sup
Vector3 axis;
axis[i] = 1.0;
- if (Math::abs(p_normal.dot(axis)) < _EDGE_IS_VALID_SUPPORT_TRESHOLD) {
+ if (Math::abs(p_normal.dot(axis)) < _EDGE_IS_VALID_SUPPORT_THRESHOLD) {
r_amount = 2;
@@ -390,6 +433,62 @@ bool BoxShapeSW::intersect_segment(const Vector3 &p_begin, const Vector3 &p_end,
return aabb.intersects_segment(p_begin, p_end, &r_result, &r_normal);
}
+bool BoxShapeSW::intersect_point(const Vector3 &p_point) const {
+
+ return (Math::abs(p_point.x) < half_extents.x && Math::abs(p_point.y) < half_extents.y && Math::abs(p_point.z) < half_extents.z);
+}
+
+Vector3 BoxShapeSW::get_closest_point_to(const Vector3 &p_point) const {
+
+ int outside = 0;
+ Vector3 min_point;
+
+ for (int i = 0; i < 3; i++) {
+
+ if (Math::abs(p_point[i]) > half_extents[i]) {
+ outside++;
+ if (outside == 1) {
+ //use plane if only one side matches
+ Vector3 n;
+ n[i] = SGN(p_point[i]);
+
+ Plane p(n, half_extents[i]);
+ min_point = p.project(p_point);
+ }
+ }
+ }
+
+ if (!outside)
+ return p_point; //it's inside, don't do anything else
+
+ if (outside == 1) //if only above one plane, this plane clearly wins
+ return min_point;
+
+ //check segments
+ float min_distance = 1e20;
+ Vector3 closest_vertex = half_extents * p_point.sign();
+ Vector3 s[2] = {
+ closest_vertex,
+ closest_vertex
+ };
+
+ for (int i = 0; i < 3; i++) {
+
+ s[1] = closest_vertex;
+ s[1][i] = -s[1][i]; //edge
+
+ Vector3 closest_edge = Geometry::get_closest_point_to_segment(p_point, s);
+
+ float d = p_point.distance_to(closest_edge);
+ if (d < min_distance) {
+ min_point = closest_edge;
+ min_distance = d;
+ }
+ }
+
+ return min_point;
+}
+
Vector3 BoxShapeSW::get_moment_of_inertia(real_t p_mass) const {
real_t lx = half_extents.x;
@@ -460,7 +559,7 @@ void CapsuleShapeSW::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r
real_t d = n.z;
- if (Math::abs(d) < _EDGE_IS_VALID_SUPPORT_TRESHOLD) {
+ if (Math::abs(d) < _EDGE_IS_VALID_SUPPORT_THRESHOLD) {
// make it flat
n.z = 0.0;
@@ -542,6 +641,32 @@ bool CapsuleShapeSW::intersect_segment(const Vector3 &p_begin, const Vector3 &p_
return collision;
}
+bool CapsuleShapeSW::intersect_point(const Vector3 &p_point) const {
+
+ if (Math::abs(p_point.z) < height * 0.5) {
+ return Vector3(p_point.x, p_point.y, 0).length() < radius;
+ } else {
+ Vector3 p = p_point;
+ p.z = Math::abs(p.z) - height * 0.5;
+ return p.length() < radius;
+ }
+}
+
+Vector3 CapsuleShapeSW::get_closest_point_to(const Vector3 &p_point) const {
+
+ Vector3 s[2] = {
+ Vector3(0, 0, -height * 0.5),
+ Vector3(0, 0, height * 0.5),
+ };
+
+ Vector3 p = Geometry::get_closest_point_to_segment(p_point, s);
+
+ if (p.distance_to(p_point) < radius)
+ return p_point;
+
+ return p + (p_point - p).normalized() * radius;
+}
+
Vector3 CapsuleShapeSW::get_moment_of_inertia(real_t p_mass) const {
// use crappy AABB approximation
@@ -655,7 +780,7 @@ void ConvexPolygonShapeSW::get_supports(const Vector3 &p_normal, int p_max, Vect
for (int i = 0; i < fc; i++) {
- if (faces[i].plane.normal.dot(p_normal) > _FACE_IS_VALID_SUPPORT_TRESHOLD) {
+ if (faces[i].plane.normal.dot(p_normal) > _FACE_IS_VALID_SUPPORT_THRESHOLD) {
int ic = faces[i].indices.size();
const int *ind = faces[i].indices.ptr();
@@ -685,7 +810,7 @@ void ConvexPolygonShapeSW::get_supports(const Vector3 &p_normal, int p_max, Vect
real_t dot = (vertices[edges[i].a] - vertices[edges[i].b]).normalized().dot(p_normal);
dot = ABS(dot);
- if (dot < _EDGE_IS_VALID_SUPPORT_TRESHOLD && (edges[i].a == vtx || edges[i].b == vtx)) {
+ if (dot < _EDGE_IS_VALID_SUPPORT_THRESHOLD && (edges[i].a == vtx || edges[i].b == vtx)) {
r_amount = 2;
r_supports[0] = vertices[edges[i].a];
@@ -738,6 +863,81 @@ bool ConvexPolygonShapeSW::intersect_segment(const Vector3 &p_begin, const Vecto
return col;
}
+bool ConvexPolygonShapeSW::intersect_point(const Vector3 &p_point) const {
+
+ const Geometry::MeshData::Face *faces = mesh.faces.ptr();
+ int fc = mesh.faces.size();
+
+ for (int i = 0; i < fc; i++) {
+
+ if (faces[i].plane.distance_to(p_point) >= 0)
+ return false;
+ }
+
+ return true;
+}
+
+Vector3 ConvexPolygonShapeSW::get_closest_point_to(const Vector3 &p_point) const {
+
+ const Geometry::MeshData::Face *faces = mesh.faces.ptr();
+ int fc = mesh.faces.size();
+ const Vector3 *vertices = mesh.vertices.ptr();
+
+ bool all_inside = true;
+ for (int i = 0; i < fc; i++) {
+
+ if (!faces[i].plane.is_point_over(p_point))
+ continue;
+
+ all_inside = false;
+ bool is_inside = true;
+ int ic = faces[i].indices.size();
+ const int *indices = faces[i].indices.ptr();
+
+ for (int j = 0; j < ic; j++) {
+
+ Vector3 a = vertices[indices[j]];
+ Vector3 b = vertices[indices[(j + 1) % ic]];
+ Vector3 n = (a - b).cross(faces[i].plane.normal).normalized();
+ if (Plane(a, n).is_point_over(p_point)) {
+ is_inside = false;
+ break;
+ }
+ }
+
+ if (is_inside) {
+ return faces[i].plane.project(p_point);
+ }
+ }
+
+ if (all_inside) {
+ return p_point;
+ }
+
+ float min_distance = 1e20;
+ Vector3 min_point;
+
+ //check edges
+ const Geometry::MeshData::Edge *edges = mesh.edges.ptr();
+ int ec = mesh.edges.size();
+ for (int i = 0; i < ec; i++) {
+
+ Vector3 s[2] = {
+ vertices[edges[i].a],
+ vertices[edges[i].b]
+ };
+
+ Vector3 closest = Geometry::get_closest_point_to_segment(p_point, s);
+ float d = closest.distance_to(p_point);
+ if (d < min_distance) {
+ min_distance = d;
+ min_point = closest;
+ }
+ }
+
+ return min_point;
+}
+
Vector3 ConvexPolygonShapeSW::get_moment_of_inertia(real_t p_mass) const {
// use crappy AABB approximation
@@ -818,7 +1018,7 @@ void FaceShapeSW::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_su
Vector3 n = p_normal;
/** TEST FACE AS SUPPORT **/
- if (normal.dot(n) > _FACE_IS_VALID_SUPPORT_TRESHOLD) {
+ if (normal.dot(n) > _FACE_IS_VALID_SUPPORT_THRESHOLD) {
r_amount = 3;
for (int i = 0; i < 3; i++) {
@@ -854,7 +1054,7 @@ void FaceShapeSW::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_su
// check if edge is valid as a support
real_t dot = (vertex[i] - vertex[nx]).normalized().dot(n);
dot = ABS(dot);
- if (dot < _EDGE_IS_VALID_SUPPORT_TRESHOLD) {
+ if (dot < _EDGE_IS_VALID_SUPPORT_THRESHOLD) {
r_amount = 2;
r_supports[0] = vertex[i];
@@ -880,6 +1080,16 @@ bool FaceShapeSW::intersect_segment(const Vector3 &p_begin, const Vector3 &p_end
return c;
}
+bool FaceShapeSW::intersect_point(const Vector3 &p_point) const {
+
+ return false; //face is flat
+}
+
+Vector3 FaceShapeSW::get_closest_point_to(const Vector3 &p_point) const {
+
+ return Face3(vertex[0], vertex[1], vertex[2]).get_closest_point_to(p_point);
+}
+
Vector3 FaceShapeSW::get_moment_of_inertia(real_t p_mass) const {
return Vector3(); // Sorry, but i don't think anyone cares, FaceShape!
@@ -1046,6 +1256,16 @@ bool ConcavePolygonShapeSW::intersect_segment(const Vector3 &p_begin, const Vect
}
}
+bool ConcavePolygonShapeSW::intersect_point(const Vector3 &p_point) const {
+
+ return false; //face is flat
+}
+
+Vector3 ConcavePolygonShapeSW::get_closest_point_to(const Vector3 &p_point) const {
+
+ return Vector3();
+}
+
void ConcavePolygonShapeSW::_cull(int p_idx, _CullParams *p_params) const {
const BVH *bvh = &p_params->bvh[p_idx];
@@ -1471,6 +1691,15 @@ bool HeightMapShapeSW::intersect_segment(const Vector3 &p_begin, const Vector3 &
return false;
}
+bool HeightMapShapeSW::intersect_point(const Vector3 &p_point) const {
+ return false;
+}
+
+Vector3 HeightMapShapeSW::get_closest_point_to(const Vector3 &p_point) const {
+
+ return Vector3();
+}
+
void HeightMapShapeSW::cull(const Rect3 &p_local_aabb, Callback p_callback, void *p_userdata) const {
}
diff --git a/servers/physics/shape_sw.h b/servers/physics/shape_sw.h
index 808ff0a3a1..aa1975b655 100644
--- a/servers/physics/shape_sw.h
+++ b/servers/physics/shape_sw.h
@@ -87,8 +87,9 @@ public:
virtual void project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const = 0;
virtual Vector3 get_support(const Vector3 &p_normal) const;
virtual void get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount) const = 0;
-
+ virtual Vector3 get_closest_point_to(const Vector3 &p_point) const = 0;
virtual bool intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_point, Vector3 &r_normal) const = 0;
+ virtual bool intersect_point(const Vector3 &p_point) const = 0;
virtual Vector3 get_moment_of_inertia(real_t p_mass) const = 0;
virtual void set_data(const Variant &p_data) = 0;
@@ -134,7 +135,8 @@ public:
virtual void get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount) const { r_amount = 0; }
virtual bool intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const;
-
+ virtual bool intersect_point(const Vector3 &p_point) const;
+ virtual Vector3 get_closest_point_to(const Vector3 &p_point) const;
virtual Vector3 get_moment_of_inertia(real_t p_mass) const;
virtual void set_data(const Variant &p_data);
@@ -159,6 +161,8 @@ public:
virtual void get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount) const;
virtual bool intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const;
+ virtual bool intersect_point(const Vector3 &p_point) const;
+ virtual Vector3 get_closest_point_to(const Vector3 &p_point) const;
virtual Vector3 get_moment_of_inertia(real_t p_mass) const;
@@ -185,6 +189,8 @@ public:
virtual Vector3 get_support(const Vector3 &p_normal) const;
virtual void get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount) const;
virtual bool intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const;
+ virtual bool intersect_point(const Vector3 &p_point) const;
+ virtual Vector3 get_closest_point_to(const Vector3 &p_point) const;
virtual Vector3 get_moment_of_inertia(real_t p_mass) const;
@@ -209,6 +215,8 @@ public:
virtual Vector3 get_support(const Vector3 &p_normal) const;
virtual void get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount) const;
virtual bool intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const;
+ virtual bool intersect_point(const Vector3 &p_point) const;
+ virtual Vector3 get_closest_point_to(const Vector3 &p_point) const;
virtual Vector3 get_moment_of_inertia(real_t p_mass) const;
@@ -237,6 +245,8 @@ public:
virtual Vector3 get_support(const Vector3 &p_normal) const;
virtual void get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount) const;
virtual bool intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const;
+ virtual bool intersect_point(const Vector3 &p_point) const;
+ virtual Vector3 get_closest_point_to(const Vector3 &p_point) const;
virtual Vector3 get_moment_of_inertia(real_t p_mass) const;
@@ -261,6 +271,8 @@ public:
virtual Vector3 get_support(const Vector3 &p_normal) const;
virtual void get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount) const;
virtual bool intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const;
+ virtual bool intersect_point(const Vector3 &p_point) const;
+ virtual Vector3 get_closest_point_to(const Vector3 &p_point) const;
virtual Vector3 get_moment_of_inertia(real_t p_mass) const;
@@ -338,6 +350,8 @@ public:
virtual Vector3 get_support(const Vector3 &p_normal) const;
virtual bool intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const;
+ virtual bool intersect_point(const Vector3 &p_point) const;
+ virtual Vector3 get_closest_point_to(const Vector3 &p_point) const;
virtual void cull(const Rect3 &p_local_aabb, Callback p_callback, void *p_userdata) const;
@@ -372,7 +386,9 @@ public:
virtual void project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const;
virtual Vector3 get_support(const Vector3 &p_normal) const;
virtual bool intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const;
+ virtual bool intersect_point(const Vector3 &p_point) const;
+ virtual Vector3 get_closest_point_to(const Vector3 &p_point) const;
virtual void cull(const Rect3 &p_local_aabb, Callback p_callback, void *p_userdata) const;
virtual Vector3 get_moment_of_inertia(real_t p_mass) const;
@@ -397,6 +413,8 @@ struct FaceShapeSW : public ShapeSW {
Vector3 get_support(const Vector3 &p_normal) const;
virtual void get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount) const;
bool intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const;
+ virtual bool intersect_point(const Vector3 &p_point) const;
+ virtual Vector3 get_closest_point_to(const Vector3 &p_point) const;
Vector3 get_moment_of_inertia(real_t p_mass) const;
@@ -436,6 +454,8 @@ struct MotionShapeSW : public ShapeSW {
}
virtual void get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount) const { r_amount = 0; }
bool intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const { return false; }
+ virtual bool intersect_point(const Vector3 &p_point) const { return false; }
+ virtual Vector3 get_closest_point_to(const Vector3 &p_point) const { return p_point; }
Vector3 get_moment_of_inertia(real_t p_mass) const { return Vector3(); }
diff --git a/servers/physics/space_sw.cpp b/servers/physics/space_sw.cpp
index 67ac21e4f9..5679fc8f60 100644
--- a/servers/physics/space_sw.cpp
+++ b/servers/physics/space_sw.cpp
@@ -29,8 +29,8 @@
/*************************************************************************/
#include "space_sw.h"
#include "collision_solver_sw.h"
-#include "global_config.h"
#include "physics_server_sw.h"
+#include "project_settings.h"
_FORCE_INLINE_ static bool _match_object_type_query(CollisionObjectSW *p_object, uint32_t p_collision_layer, uint32_t p_type_mask) {
@@ -45,6 +45,50 @@ _FORCE_INLINE_ static bool _match_object_type_query(CollisionObjectSW *p_object,
return (1 << body->get_mode()) & p_type_mask;
}
+int PhysicsDirectSpaceStateSW::intersect_point(const Vector3 &p_point, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude, uint32_t p_collision_layer, uint32_t p_object_type_mask) {
+
+ ERR_FAIL_COND_V(space->locked, false);
+ int amount = space->broadphase->cull_point(p_point, space->intersection_query_results, SpaceSW::INTERSECTION_QUERY_MAX, space->intersection_query_subindex_results);
+ int cc = 0;
+
+ //Transform ai = p_xform.affine_inverse();
+
+ for (int i = 0; i < amount; i++) {
+
+ if (cc >= p_result_max)
+ break;
+
+ if (!_match_object_type_query(space->intersection_query_results[i], p_collision_layer, p_object_type_mask))
+ continue;
+
+ //area can't be picked by ray (default)
+
+ if (p_exclude.has(space->intersection_query_results[i]->get_self()))
+ continue;
+
+ const CollisionObjectSW *col_obj = space->intersection_query_results[i];
+ int shape_idx = space->intersection_query_subindex_results[i];
+
+ Transform inv_xform = col_obj->get_transform() * col_obj->get_shape_transform(shape_idx);
+ inv_xform.affine_invert();
+
+ if (!col_obj->get_shape(shape_idx)->intersect_point(inv_xform.xform(p_point)))
+ continue;
+
+ r_results[cc].collider_id = col_obj->get_instance_id();
+ if (r_results[cc].collider_id != 0)
+ r_results[cc].collider = ObjectDB::get_instance(r_results[cc].collider_id);
+ else
+ r_results[cc].collider = NULL;
+ r_results[cc].rid = col_obj->get_self();
+ r_results[cc].shape = shape_idx;
+
+ cc++;
+ }
+
+ return cc;
+}
+
bool PhysicsDirectSpaceStateSW::intersect_ray(const Vector3 &p_from, const Vector3 &p_to, RayResult &r_result, const Set<RID> &p_exclude, uint32_t p_collision_layer, uint32_t p_object_type_mask, bool p_pick_ray) {
ERR_FAIL_COND_V(space->locked, false);
@@ -428,6 +472,48 @@ bool PhysicsDirectSpaceStateSW::rest_info(RID p_shape, const Transform &p_shape_
return true;
}
+Vector3 PhysicsDirectSpaceStateSW::get_closest_point_to_object_volume(RID p_object, const Vector3 p_point) const {
+
+ CollisionObjectSW *obj = NULL;
+ obj = PhysicsServerSW::singleton->area_owner.getornull(p_object);
+ if (!obj) {
+ obj = PhysicsServerSW::singleton->body_owner.getornull(p_object);
+ }
+ ERR_FAIL_COND_V(!obj, Vector3());
+
+ ERR_FAIL_COND_V(obj->get_space() != space, Vector3());
+
+ float min_distance = 1e20;
+ Vector3 min_point;
+
+ bool shapes_found = false;
+
+ for (int i = 0; i < obj->get_shape_count(); i++) {
+
+ if (obj->is_shape_set_as_disabled(i))
+ continue;
+
+ Transform shape_xform = obj->get_transform() * obj->get_shape_transform(i);
+ ShapeSW *shape = obj->get_shape(i);
+
+ Vector3 point = shape->get_closest_point_to(shape_xform.affine_inverse().xform(p_point));
+ point = shape_xform.xform(point);
+
+ float dist = point.distance_to(p_point);
+ if (dist < min_distance) {
+ min_distance = dist;
+ min_point = point;
+ }
+ shapes_found = true;
+ }
+
+ if (!shapes_found) {
+ return obj->get_transform().origin; //no shapes found, use distance to origin.
+ } else {
+ return min_point;
+ }
+}
+
PhysicsDirectSpaceStateSW::PhysicsDirectSpaceStateSW() {
space = NULL;
@@ -435,6 +521,337 @@ PhysicsDirectSpaceStateSW::PhysicsDirectSpaceStateSW() {
////////////////////////////////////////////////////////////////////////////////////////////////////////////
+int SpaceSW::_cull_aabb_for_body(BodySW *p_body, const Rect3 &p_aabb) {
+
+ int amount = broadphase->cull_aabb(p_aabb, intersection_query_results, INTERSECTION_QUERY_MAX, intersection_query_subindex_results);
+
+ for (int i = 0; i < amount; i++) {
+
+ bool keep = true;
+
+ if (intersection_query_results[i] == p_body)
+ keep = false;
+ else if (intersection_query_results[i]->get_type() == CollisionObjectSW::TYPE_AREA)
+ keep = false;
+ else if ((static_cast<BodySW *>(intersection_query_results[i])->test_collision_mask(p_body)) == 0)
+ keep = false;
+ else if (static_cast<BodySW *>(intersection_query_results[i])->has_exception(p_body->get_self()) || p_body->has_exception(intersection_query_results[i]->get_self()))
+ keep = false;
+ else if (static_cast<BodySW *>(intersection_query_results[i])->is_shape_set_as_disabled(intersection_query_subindex_results[i]))
+ keep = false;
+
+ if (!keep) {
+
+ if (i < amount - 1) {
+ SWAP(intersection_query_results[i], intersection_query_results[amount - 1]);
+ SWAP(intersection_query_subindex_results[i], intersection_query_subindex_results[amount - 1]);
+ }
+
+ amount--;
+ i--;
+ }
+ }
+
+ return amount;
+}
+
+bool SpaceSW::test_body_motion(BodySW *p_body, const Transform &p_from, const Vector3 &p_motion, real_t p_margin, PhysicsServer::MotionResult *r_result) {
+
+ //give me back regular physics engine logic
+ //this is madness
+ //and most people using this function will think
+ //what it does is simpler than using physics
+ //this took about a week to get right..
+ //but is it right? who knows at this point..
+
+ if (r_result) {
+ r_result->collider_id = 0;
+ r_result->collider_shape = 0;
+ }
+ Rect3 body_aabb;
+
+ for (int i = 0; i < p_body->get_shape_count(); i++) {
+
+ if (i == 0)
+ body_aabb = p_body->get_shape_aabb(i);
+ else
+ body_aabb = body_aabb.merge(p_body->get_shape_aabb(i));
+ }
+
+ // Undo the currently transform the physics server is aware of and apply the provided one
+ body_aabb = p_from.xform(p_body->get_inv_transform().xform(body_aabb));
+ body_aabb = body_aabb.grow(p_margin);
+
+ Transform body_transform = p_from;
+
+ {
+ //STEP 1, FREE BODY IF STUCK
+
+ const int max_results = 32;
+ int recover_attempts = 4;
+ Vector3 sr[max_results * 2];
+
+ do {
+
+ PhysicsServerSW::CollCbkData cbk;
+ cbk.max = max_results;
+ cbk.amount = 0;
+ cbk.ptr = sr;
+
+ CollisionSolverSW::CallbackResult cbkres = NULL;
+
+ PhysicsServerSW::CollCbkData *cbkptr = NULL;
+ cbkptr = &cbk;
+ cbkres = PhysicsServerSW::_shape_col_cbk;
+
+ bool collided = false;
+
+ int amount = _cull_aabb_for_body(p_body, body_aabb);
+
+ for (int j = 0; j < p_body->get_shape_count(); j++) {
+ if (p_body->is_shape_set_as_disabled(j))
+ continue;
+
+ Transform body_shape_xform = body_transform * p_body->get_shape_transform(j);
+ ShapeSW *body_shape = p_body->get_shape(j);
+ for (int i = 0; i < amount; i++) {
+
+ const CollisionObjectSW *col_obj = intersection_query_results[i];
+ int shape_idx = intersection_query_subindex_results[i];
+
+ if (CollisionSolverSW::solve_static(body_shape, body_shape_xform, col_obj->get_shape(shape_idx), col_obj->get_transform() * col_obj->get_shape_transform(shape_idx), cbkres, cbkptr, NULL, p_margin)) {
+ collided = cbk.amount > 0;
+ }
+ }
+ }
+
+ if (!collided) {
+ break;
+ }
+
+ Vector3 recover_motion;
+
+ for (int i = 0; i < cbk.amount; i++) {
+
+ Vector3 a = sr[i * 2 + 0];
+ Vector3 b = sr[i * 2 + 1];
+
+#if 0
+ Vector3 rel = b-a;
+ real_t d = rel.length();
+ if (d==0)
+ continue;
+
+ Vector3 n = rel/d;
+ real_t traveled = n.dot(recover_motion);
+ a+=n*traveled;
+
+ real_t d = a.distance_to(b);
+ if (d<margin)
+ continue;
+#endif
+ recover_motion += (b - a) * 0.4;
+ }
+
+ if (recover_motion == Vector3()) {
+ collided = false;
+ break;
+ }
+
+ body_transform.origin += recover_motion;
+ body_aabb.position += recover_motion;
+
+ recover_attempts--;
+
+ } while (recover_attempts);
+ }
+
+ real_t safe = 1.0;
+ real_t unsafe = 1.0;
+ int best_shape = -1;
+
+ {
+ // STEP 2 ATTEMPT MOTION
+
+ Rect3 motion_aabb = body_aabb;
+ motion_aabb.position += p_motion;
+ motion_aabb = motion_aabb.merge(body_aabb);
+
+ int amount = _cull_aabb_for_body(p_body, motion_aabb);
+
+ for (int j = 0; j < p_body->get_shape_count(); j++) {
+
+ if (p_body->is_shape_set_as_disabled(j))
+ continue;
+
+ Transform body_shape_xform = body_transform * p_body->get_shape_transform(j);
+ ShapeSW *body_shape = p_body->get_shape(j);
+
+ Transform body_shape_xform_inv = body_shape_xform.affine_inverse();
+ MotionShapeSW mshape;
+ mshape.shape = body_shape;
+ mshape.motion = body_shape_xform_inv.basis.xform(p_motion);
+
+ bool stuck = false;
+
+ real_t best_safe = 1;
+ real_t best_unsafe = 1;
+
+ for (int i = 0; i < amount; i++) {
+
+ const CollisionObjectSW *col_obj = intersection_query_results[i];
+ int shape_idx = intersection_query_subindex_results[i];
+
+ //test initial overlap, does it collide if going all the way?
+ Vector3 point_A, point_B;
+ Vector3 sep_axis = p_motion.normalized();
+
+ Transform col_obj_xform = col_obj->get_transform() * col_obj->get_shape_transform(shape_idx);
+ //test initial overlap, does it collide if going all the way?
+ if (CollisionSolverSW::solve_distance(&mshape, body_shape_xform, col_obj->get_shape(shape_idx), col_obj_xform, point_A, point_B, motion_aabb, &sep_axis)) {
+ //print_line("failed motion cast (no collision)");
+ continue;
+ }
+ sep_axis = p_motion.normalized();
+
+ if (!CollisionSolverSW::solve_distance(body_shape, body_shape_xform, col_obj->get_shape(shape_idx), col_obj_xform, point_A, point_B, motion_aabb, &sep_axis)) {
+ //print_line("failed motion cast (no collision)");
+ stuck = true;
+ break;
+ }
+
+ //just do kinematic solving
+ real_t low = 0;
+ real_t hi = 1;
+ Vector3 mnormal = p_motion.normalized();
+
+ for (int i = 0; i < 8; i++) { //steps should be customizable..
+
+ real_t ofs = (low + hi) * 0.5;
+
+ Vector3 sep = mnormal; //important optimization for this to work fast enough
+
+ mshape.motion = body_shape_xform_inv.basis.xform(p_motion * ofs);
+
+ Vector3 lA, lB;
+
+ bool collided = !CollisionSolverSW::solve_distance(&mshape, body_shape_xform, col_obj->get_shape(shape_idx), col_obj_xform, lA, lB, motion_aabb, &sep);
+
+ if (collided) {
+
+ //print_line(itos(i)+": "+rtos(ofs));
+ hi = ofs;
+ } else {
+
+ point_A = lA;
+ point_B = lB;
+ low = ofs;
+ }
+ }
+
+ if (low < best_safe) {
+ best_safe = low;
+ best_unsafe = hi;
+ }
+ }
+
+ if (stuck) {
+
+ safe = 0;
+ unsafe = 0;
+ best_shape = j; //sadly it's the best
+ break;
+ }
+ if (best_safe == 1.0) {
+ continue;
+ }
+ if (best_safe < safe) {
+
+ safe = best_safe;
+ unsafe = best_unsafe;
+ best_shape = j;
+ }
+ }
+ }
+
+ bool collided = false;
+ if (safe >= 1) {
+ //not collided
+ collided = false;
+ if (r_result) {
+
+ r_result->motion = p_motion;
+ r_result->remainder = Vector3();
+ r_result->motion += (body_transform.get_origin() - p_from.get_origin());
+ }
+
+ } else {
+
+ //it collided, let's get the rest info in unsafe advance
+ Transform ugt = body_transform;
+ ugt.origin += p_motion * unsafe;
+
+ _RestCallbackData rcd;
+ rcd.best_len = 0;
+ rcd.best_object = NULL;
+ rcd.best_shape = 0;
+
+ Transform body_shape_xform = ugt * p_body->get_shape_transform(best_shape);
+ ShapeSW *body_shape = p_body->get_shape(best_shape);
+
+ body_aabb.position += p_motion * unsafe;
+
+ int amount = _cull_aabb_for_body(p_body, body_aabb);
+
+ for (int i = 0; i < amount; i++) {
+
+ const CollisionObjectSW *col_obj = intersection_query_results[i];
+ int shape_idx = intersection_query_subindex_results[i];
+
+ rcd.object = col_obj;
+ rcd.shape = shape_idx;
+ bool sc = CollisionSolverSW::solve_static(body_shape, body_shape_xform, col_obj->get_shape(shape_idx), col_obj->get_transform() * col_obj->get_shape_transform(shape_idx), _rest_cbk_result, &rcd, NULL, p_margin);
+ if (!sc)
+ continue;
+ }
+
+ if (rcd.best_len != 0) {
+
+ if (r_result) {
+ r_result->collider = rcd.best_object->get_self();
+ r_result->collider_id = rcd.best_object->get_instance_id();
+ r_result->collider_shape = rcd.best_shape;
+ r_result->collision_local_shape = best_shape;
+ r_result->collision_normal = rcd.best_normal;
+ r_result->collision_point = rcd.best_contact;
+ //r_result->collider_metadata = rcd.best_object->get_shape_metadata(rcd.best_shape);
+
+ const BodySW *body = static_cast<const BodySW *>(rcd.best_object);
+ //Vector3 rel_vec = r_result->collision_point - body->get_transform().get_origin();
+ // r_result->collider_velocity = Vector3(-body->get_angular_velocity() * rel_vec.y, body->get_angular_velocity() * rel_vec.x) + body->get_linear_velocity();
+ r_result->collider_velocity = body->get_linear_velocity() + (body->get_angular_velocity()).cross(body->get_transform().origin - rcd.best_contact); // * mPos);
+
+ r_result->motion = safe * p_motion;
+ r_result->remainder = p_motion - safe * p_motion;
+ r_result->motion += (body_transform.get_origin() - p_from.get_origin());
+ }
+
+ collided = true;
+ } else {
+ if (r_result) {
+
+ r_result->motion = p_motion;
+ r_result->remainder = Vector3();
+ r_result->motion += (body_transform.get_origin() - p_from.get_origin());
+ }
+
+ collided = false;
+ }
+ }
+
+ return collided;
+}
+
void *SpaceSW::_broadphase_pair(CollisionObjectSW *A, int p_subindex_A, CollisionObjectSW *B, int p_subindex_B, void *p_self) {
CollisionObjectSW::Type type_A = A->get_type();
@@ -597,8 +1014,8 @@ void SpaceSW::set_param(PhysicsServer::SpaceParameter p_param, real_t p_value) {
case PhysicsServer::SPACE_PARAM_CONTACT_RECYCLE_RADIUS: contact_recycle_radius = p_value; break;
case PhysicsServer::SPACE_PARAM_CONTACT_MAX_SEPARATION: contact_max_separation = p_value; break;
case PhysicsServer::SPACE_PARAM_BODY_MAX_ALLOWED_PENETRATION: contact_max_allowed_penetration = p_value; break;
- case PhysicsServer::SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_TRESHOLD: body_linear_velocity_sleep_threshold = p_value; break;
- case PhysicsServer::SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_TRESHOLD: body_angular_velocity_sleep_threshold = p_value; break;
+ case PhysicsServer::SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD: body_linear_velocity_sleep_threshold = p_value; break;
+ case PhysicsServer::SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD: body_angular_velocity_sleep_threshold = p_value; break;
case PhysicsServer::SPACE_PARAM_BODY_TIME_TO_SLEEP: body_time_to_sleep = p_value; break;
case PhysicsServer::SPACE_PARAM_BODY_ANGULAR_VELOCITY_DAMP_RATIO: body_angular_velocity_damp_ratio = p_value; break;
case PhysicsServer::SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS: constraint_bias = p_value; break;
@@ -612,8 +1029,8 @@ real_t SpaceSW::get_param(PhysicsServer::SpaceParameter p_param) const {
case PhysicsServer::SPACE_PARAM_CONTACT_RECYCLE_RADIUS: return contact_recycle_radius;
case PhysicsServer::SPACE_PARAM_CONTACT_MAX_SEPARATION: return contact_max_separation;
case PhysicsServer::SPACE_PARAM_BODY_MAX_ALLOWED_PENETRATION: return contact_max_allowed_penetration;
- case PhysicsServer::SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_TRESHOLD: return body_linear_velocity_sleep_threshold;
- case PhysicsServer::SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_TRESHOLD: return body_angular_velocity_sleep_threshold;
+ case PhysicsServer::SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD: return body_linear_velocity_sleep_threshold;
+ case PhysicsServer::SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD: return body_angular_velocity_sleep_threshold;
case PhysicsServer::SPACE_PARAM_BODY_TIME_TO_SLEEP: return body_time_to_sleep;
case PhysicsServer::SPACE_PARAM_BODY_ANGULAR_VELOCITY_DAMP_RATIO: return body_angular_velocity_damp_ratio;
case PhysicsServer::SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS: return constraint_bias;
diff --git a/servers/physics/space_sw.h b/servers/physics/space_sw.h
index 782bacbd65..dc7799d992 100644
--- a/servers/physics/space_sw.h
+++ b/servers/physics/space_sw.h
@@ -36,8 +36,8 @@
#include "body_sw.h"
#include "broad_phase_sw.h"
#include "collision_object_sw.h"
-#include "global_config.h"
#include "hash_map.h"
+#include "project_settings.h"
#include "typedefs.h"
class PhysicsDirectSpaceStateSW : public PhysicsDirectSpaceState {
@@ -47,11 +47,13 @@ class PhysicsDirectSpaceStateSW : public PhysicsDirectSpaceState {
public:
SpaceSW *space;
+ virtual int intersect_point(const Vector3 &p_point, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_layer = 0xFFFFFFFF, uint32_t p_object_type_mask = TYPE_MASK_COLLISION);
virtual bool intersect_ray(const Vector3 &p_from, const Vector3 &p_to, RayResult &r_result, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_layer = 0xFFFFFFFF, uint32_t p_object_type_mask = TYPE_MASK_COLLISION, bool p_pick_ray = false);
virtual int intersect_shape(const RID &p_shape, const Transform &p_xform, real_t p_margin, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_layer = 0xFFFFFFFF, uint32_t p_object_type_mask = TYPE_MASK_COLLISION);
virtual bool cast_motion(const RID &p_shape, const Transform &p_xform, const Vector3 &p_motion, real_t p_margin, real_t &p_closest_safe, real_t &p_closest_unsafe, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_layer = 0xFFFFFFFF, uint32_t p_object_type_mask = TYPE_MASK_COLLISION, ShapeRestInfo *r_info = NULL);
virtual bool collide_shape(RID p_shape, const Transform &p_shape_xform, real_t p_margin, Vector3 *r_results, int p_result_max, int &r_result_count, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_layer = 0xFFFFFFFF, uint32_t p_object_type_mask = TYPE_MASK_COLLISION);
virtual bool rest_info(RID p_shape, const Transform &p_shape_xform, real_t p_margin, ShapeRestInfo *r_info, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_layer = 0xFFFFFFFF, uint32_t p_object_type_mask = TYPE_MASK_COLLISION);
+ virtual Vector3 get_closest_point_to_object_volume(RID p_object, const Vector3 p_point) const;
PhysicsDirectSpaceStateSW();
};
@@ -120,6 +122,8 @@ private:
friend class PhysicsDirectSpaceStateSW;
+ int _cull_aabb_for_body(BodySW *p_body, const Rect3 &p_aabb);
+
public:
_FORCE_INLINE_ void set_self(const RID &p_self) { self = p_self; }
_FORCE_INLINE_ RID get_self() const { return self; }
@@ -152,8 +156,8 @@ public:
_FORCE_INLINE_ real_t get_contact_max_separation() const { return contact_max_separation; }
_FORCE_INLINE_ real_t get_contact_max_allowed_penetration() const { return contact_max_allowed_penetration; }
_FORCE_INLINE_ real_t get_constraint_bias() const { return constraint_bias; }
- _FORCE_INLINE_ real_t get_body_linear_velocity_sleep_treshold() const { return body_linear_velocity_sleep_threshold; }
- _FORCE_INLINE_ real_t get_body_angular_velocity_sleep_treshold() const { return body_angular_velocity_sleep_threshold; }
+ _FORCE_INLINE_ real_t get_body_linear_velocity_sleep_threshold() const { return body_linear_velocity_sleep_threshold; }
+ _FORCE_INLINE_ real_t get_body_angular_velocity_sleep_threshold() const { return body_angular_velocity_sleep_threshold; }
_FORCE_INLINE_ real_t get_body_time_to_sleep() const { return body_time_to_sleep; }
_FORCE_INLINE_ real_t get_body_angular_velocity_damp_ratio() const { return body_angular_velocity_damp_ratio; }
@@ -192,6 +196,8 @@ public:
void set_elapsed_time(ElapsedTime p_time, uint64_t p_msec) { elapsed_time[p_time] = p_msec; }
uint64_t get_elapsed_time(ElapsedTime p_time) const { return elapsed_time[p_time]; }
+ bool test_body_motion(BodySW *p_body, const Transform &p_from, const Vector3 &p_motion, real_t p_margin, PhysicsServer::MotionResult *r_result);
+
SpaceSW();
~SpaceSW();
};
diff --git a/servers/physics_2d/body_2d_sw.cpp b/servers/physics_2d/body_2d_sw.cpp
index 538ea10211..91b5646ef5 100644
--- a/servers/physics_2d/body_2d_sw.cpp
+++ b/servers/physics_2d/body_2d_sw.cpp
@@ -621,7 +621,7 @@ bool Body2DSW::sleep_test(real_t p_step) {
else if (!can_sleep)
return false;
- if (Math::abs(angular_velocity) < get_space()->get_body_angular_velocity_sleep_treshold() && Math::abs(linear_velocity.length_squared()) < get_space()->get_body_linear_velocity_sleep_treshold() * get_space()->get_body_linear_velocity_sleep_treshold()) {
+ if (Math::abs(angular_velocity) < get_space()->get_body_angular_velocity_sleep_threshold() && Math::abs(linear_velocity.length_squared()) < get_space()->get_body_linear_velocity_sleep_threshold() * get_space()->get_body_linear_velocity_sleep_threshold()) {
still_time += p_step;
diff --git a/servers/physics_2d/broad_phase_2d_hash_grid.cpp b/servers/physics_2d/broad_phase_2d_hash_grid.cpp
index 438cd416f6..5b6c7e2f38 100644
--- a/servers/physics_2d/broad_phase_2d_hash_grid.cpp
+++ b/servers/physics_2d/broad_phase_2d_hash_grid.cpp
@@ -28,7 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "broad_phase_2d_hash_grid.h"
-#include "global_config.h"
+#include "project_settings.h"
#define LARGE_ELEMENT_FI 1.01239812
@@ -636,7 +636,7 @@ BroadPhase2DHashGrid::BroadPhase2DHashGrid() {
hash_table = memnew_arr(PosBin *, hash_table_size);
cell_size = GLOBAL_DEF("physics/2d/cell_size", 128);
- large_object_min_surface = GLOBAL_DEF("physics/2d/large_object_surface_treshold_in_cells", 512);
+ large_object_min_surface = GLOBAL_DEF("physics/2d/large_object_surface_threshold_in_cells", 512);
for (int i = 0; i < hash_table_size; i++)
hash_table[i] = NULL;
diff --git a/servers/physics_2d/physics_2d_server_sw.cpp b/servers/physics_2d/physics_2d_server_sw.cpp
index 1d88710f1a..c20d0d14a2 100644
--- a/servers/physics_2d/physics_2d_server_sw.cpp
+++ b/servers/physics_2d/physics_2d_server_sw.cpp
@@ -31,8 +31,8 @@
#include "broad_phase_2d_basic.h"
#include "broad_phase_2d_hash_grid.h"
#include "collision_solver_2d_sw.h"
-#include "global_config.h"
#include "os/os.h"
+#include "project_settings.h"
#include "script_language.h"
RID Physics2DServerSW::shape_create(ShapeType p_shape) {
@@ -853,13 +853,13 @@ void Physics2DServerSW::body_get_collision_exceptions(RID p_body, List<RID> *p_e
}
};
-void Physics2DServerSW::body_set_contacts_reported_depth_treshold(RID p_body, real_t p_treshold) {
+void Physics2DServerSW::body_set_contacts_reported_depth_threshold(RID p_body, real_t p_threshold) {
Body2DSW *body = body_owner.get(p_body);
ERR_FAIL_COND(!body);
};
-real_t Physics2DServerSW::body_get_contacts_reported_depth_treshold(RID p_body) const {
+real_t Physics2DServerSW::body_get_contacts_reported_depth_threshold(RID p_body) const {
Body2DSW *body = body_owner.get(p_body);
ERR_FAIL_COND_V(!body, 0);
@@ -1264,7 +1264,7 @@ Physics2DServerSW::Physics2DServerSW() {
island_count = 0;
active_objects = 0;
collision_pairs = 0;
- using_threads = int(GlobalConfig::get_singleton()->get("physics/2d/thread_model")) == 2;
+ using_threads = int(ProjectSettings::get_singleton()->get("physics/2d/thread_model")) == 2;
};
Physics2DServerSW::~Physics2DServerSW(){
diff --git a/servers/physics_2d/physics_2d_server_sw.h b/servers/physics_2d/physics_2d_server_sw.h
index 9cbdfc598f..da72784b6f 100644
--- a/servers/physics_2d/physics_2d_server_sw.h
+++ b/servers/physics_2d/physics_2d_server_sw.h
@@ -205,8 +205,8 @@ public:
virtual void body_remove_collision_exception(RID p_body, RID p_body_b);
virtual void body_get_collision_exceptions(RID p_body, List<RID> *p_exceptions);
- virtual void body_set_contacts_reported_depth_treshold(RID p_body, real_t p_treshold);
- virtual real_t body_get_contacts_reported_depth_treshold(RID p_body) const;
+ virtual void body_set_contacts_reported_depth_threshold(RID p_body, real_t p_threshold);
+ virtual real_t body_get_contacts_reported_depth_threshold(RID p_body) const;
virtual void body_set_omit_force_integration(RID p_body, bool p_omit);
virtual bool body_is_omitting_force_integration(RID p_body) const;
diff --git a/servers/physics_2d/physics_2d_server_wrap_mt.cpp b/servers/physics_2d/physics_2d_server_wrap_mt.cpp
index d92c033e35..d39231b161 100644
--- a/servers/physics_2d/physics_2d_server_wrap_mt.cpp
+++ b/servers/physics_2d/physics_2d_server_wrap_mt.cpp
@@ -161,12 +161,12 @@ Physics2DServerWrapMT::Physics2DServerWrapMT(Physics2DServer *p_contained, bool
step_thread_up = false;
alloc_mutex = Mutex::create();
- shape_pool_max_size = GLOBAL_GET("memory/multithread/thread_rid_pool_prealloc");
- area_pool_max_size = GLOBAL_GET("memory/multithread/thread_rid_pool_prealloc");
- body_pool_max_size = GLOBAL_GET("memory/multithread/thread_rid_pool_prealloc");
- pin_joint_pool_max_size = GLOBAL_GET("memory/multithread/thread_rid_pool_prealloc");
- groove_joint_pool_max_size = GLOBAL_GET("memory/multithread/thread_rid_pool_prealloc");
- damped_spring_joint_pool_max_size = GLOBAL_GET("memory/multithread/thread_rid_pool_prealloc");
+ shape_pool_max_size = GLOBAL_GET("memory/limits/multithreaded_server/rid_pool_prealloc");
+ area_pool_max_size = GLOBAL_GET("memory/limits/multithreaded_server/rid_pool_prealloc");
+ body_pool_max_size = GLOBAL_GET("memory/limits/multithreaded_server/rid_pool_prealloc");
+ pin_joint_pool_max_size = GLOBAL_GET("memory/limits/multithreaded_server/rid_pool_prealloc");
+ groove_joint_pool_max_size = GLOBAL_GET("memory/limits/multithreaded_server/rid_pool_prealloc");
+ damped_spring_joint_pool_max_size = GLOBAL_GET("memory/limits/multithreaded_server/rid_pool_prealloc");
if (!p_create_thread) {
server_thread = Thread::get_caller_ID();
diff --git a/servers/physics_2d/physics_2d_server_wrap_mt.h b/servers/physics_2d/physics_2d_server_wrap_mt.h
index 9fcfebef6b..8b6609d119 100644
--- a/servers/physics_2d/physics_2d_server_wrap_mt.h
+++ b/servers/physics_2d/physics_2d_server_wrap_mt.h
@@ -31,8 +31,8 @@
#define PHYSICS2DSERVERWRAPMT_H
#include "command_queue_mt.h"
-#include "global_config.h"
#include "os/thread.h"
+#include "project_settings.h"
#include "servers/physics_2d_server.h"
#ifdef DEBUG_SYNC
@@ -233,8 +233,8 @@ public:
FUNC2(body_set_max_contacts_reported, RID, int);
FUNC1RC(int, body_get_max_contacts_reported, RID);
- FUNC2(body_set_contacts_reported_depth_treshold, RID, real_t);
- FUNC1RC(real_t, body_get_contacts_reported_depth_treshold, RID);
+ FUNC2(body_set_contacts_reported_depth_threshold, RID, real_t);
+ FUNC1RC(real_t, body_get_contacts_reported_depth_threshold, RID);
FUNC2(body_set_omit_force_integration, RID, bool);
FUNC1RC(bool, body_is_omitting_force_integration, RID);
diff --git a/servers/physics_2d/shape_2d_sw.cpp b/servers/physics_2d/shape_2d_sw.cpp
index 245b4e15bc..e153ee985c 100644
--- a/servers/physics_2d/shape_2d_sw.cpp
+++ b/servers/physics_2d/shape_2d_sw.cpp
@@ -197,7 +197,7 @@ Variant RayShape2DSW::get_data() const {
void SegmentShape2DSW::get_supports(const Vector2 &p_normal, Vector2 *r_supports, int &r_amount) const {
- if (Math::abs(p_normal.dot(n)) > _SEGMENT_IS_VALID_SUPPORT_TRESHOLD) {
+ if (Math::abs(p_normal.dot(n)) > _SEGMENT_IS_VALID_SUPPORT_THRESHOLD) {
r_supports[0] = a;
r_supports[1] = b;
r_amount = 2;
@@ -337,7 +337,7 @@ void RectangleShape2DSW::get_supports(const Vector2 &p_normal, Vector2 *r_suppor
Vector2 ag;
ag[i] = 1.0;
real_t dp = ag.dot(p_normal);
- if (Math::abs(dp) < _SEGMENT_IS_VALID_SUPPORT_TRESHOLD)
+ if (Math::abs(dp) < _SEGMENT_IS_VALID_SUPPORT_THRESHOLD)
continue;
real_t sgn = dp > 0 ? 1.0 : -1.0;
@@ -400,7 +400,7 @@ void CapsuleShape2DSW::get_supports(const Vector2 &p_normal, Vector2 *r_supports
real_t d = n.y;
- if (Math::abs(d) < (1.0 - _SEGMENT_IS_VALID_SUPPORT_TRESHOLD)) {
+ if (Math::abs(d) < (1.0 - _SEGMENT_IS_VALID_SUPPORT_THRESHOLD)) {
// make it flat
n.y = 0.0;
@@ -547,7 +547,7 @@ void ConvexPolygonShape2DSW::get_supports(const Vector2 &p_normal, Vector2 *r_su
}
//test segment
- if (points[i].normal.dot(p_normal) > _SEGMENT_IS_VALID_SUPPORT_TRESHOLD) {
+ if (points[i].normal.dot(p_normal) > _SEGMENT_IS_VALID_SUPPORT_THRESHOLD) {
r_amount = 2;
r_supports[0] = points[i].pos;
diff --git a/servers/physics_2d/shape_2d_sw.h b/servers/physics_2d/shape_2d_sw.h
index 4cc98b7f1e..a75a4338e7 100644
--- a/servers/physics_2d/shape_2d_sw.h
+++ b/servers/physics_2d/shape_2d_sw.h
@@ -31,7 +31,7 @@
#define SHAPE_2D_2DSW_H
#include "servers/physics_2d_server.h"
-#define _SEGMENT_IS_VALID_SUPPORT_TRESHOLD 0.99998
+#define _SEGMENT_IS_VALID_SUPPORT_THRESHOLD 0.99998
/*
@@ -106,7 +106,7 @@ public:
if (r_amount == 1) {
- if (Math::abs(p_normal.dot(p_cast.normalized())) < (1.0 - _SEGMENT_IS_VALID_SUPPORT_TRESHOLD)) {
+ if (Math::abs(p_normal.dot(p_cast.normalized())) < (1.0 - _SEGMENT_IS_VALID_SUPPORT_THRESHOLD)) {
//make line because they are parallel
r_amount = 2;
r_supports[1] = r_supports[0] + p_cast;
@@ -117,7 +117,7 @@ public:
} else {
- if (Math::abs(p_normal.dot(p_cast.normalized())) < (1.0 - _SEGMENT_IS_VALID_SUPPORT_TRESHOLD)) {
+ if (Math::abs(p_normal.dot(p_cast.normalized())) < (1.0 - _SEGMENT_IS_VALID_SUPPORT_THRESHOLD)) {
//optimize line and make it larger because they are parallel
if ((r_supports[1] - r_supports[0]).dot(p_cast) > 0) {
//larger towards 1
diff --git a/servers/physics_2d/space_2d_sw.cpp b/servers/physics_2d/space_2d_sw.cpp
index 0b31ff144b..a17d1f6a12 100644
--- a/servers/physics_2d/space_2d_sw.cpp
+++ b/servers/physics_2d/space_2d_sw.cpp
@@ -553,7 +553,7 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
const CollisionObject2DSW *col_obj = intersection_query_results[i];
int shape_idx = intersection_query_subindex_results[i];
- if (col_obj->is_shape_set_as_one_way_collision(j)) {
+ if (col_obj->is_shape_set_as_one_way_collision(shape_idx)) {
cbk.valid_dir = body_shape_xform.get_axis(1).normalized();
cbk.valid_depth = p_margin; //only valid depth is the collision margin
@@ -809,162 +809,6 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
}
return collided;
-
-#if 0
- //give me back regular physics engine logic
- //this is madness
- //and most people using this function will think
- //what it does is simpler than using physics
- //this took about a week to get right..
- //but is it right? who knows at this point..
-
-
- colliding=false;
- ERR_FAIL_COND_V(!is_inside_tree(),Vector2());
- Physics2DDirectSpaceState *dss = Physics2DServer::get_singleton()->space_get_direct_state(get_world_2d()->get_space());
- ERR_FAIL_COND_V(!dss,Vector2());
- const int max_shapes=32;
- Vector2 sr[max_shapes*2];
- int res_shapes;
-
- Set<RID> exclude;
- exclude.insert(get_rid());
-
-
- //recover first
- int recover_attempts=4;
-
- bool collided=false;
- uint32_t mask=0;
- if (collide_static)
- mask|=Physics2DDirectSpaceState::TYPE_MASK_STATIC_BODY;
- if (collide_kinematic)
- mask|=Physics2DDirectSpaceState::TYPE_MASK_KINEMATIC_BODY;
- if (collide_rigid)
- mask|=Physics2DDirectSpaceState::TYPE_MASK_RIGID_BODY;
- if (collide_character)
- mask|=Physics2DDirectSpaceState::TYPE_MASK_CHARACTER_BODY;
-
- //print_line("motion: "+p_motion+" margin: "+rtos(margin));
-
- //print_line("margin: "+rtos(margin));
- do {
-
- //motion recover
- for(int i=0;i<get_shape_count();i++) {
-
- if (is_shape_set_as_trigger(i))
- continue;
- if (dss->collide_shape(get_shape(i)->get_rid(), get_global_transform() * get_shape_transform(i),Vector2(),margin,sr,max_shapes,res_shapes,exclude,get_layer_mask(),mask))
- collided=true;
-
- }
-
- if (!collided)
- break;
-
- Vector2 recover_motion;
-
- for(int i=0;i<res_shapes;i++) {
-
- Vector2 a = sr[i*2+0];
- Vector2 b = sr[i*2+1];
-
- real_t d = a.distance_to(b);
-
- /*
- if (d<margin)
- continue;
- */
- recover_motion+=(b-a)*0.4;
- }
-
- if (recover_motion==Vector2()) {
- collided=false;
- break;
- }
-
- Matrix32 gt = get_global_transform();
- gt.elements[2]+=recover_motion;
- set_global_transform(gt);
-
- recover_attempts--;
-
- } while (recover_attempts);
-
-
- //move second
- real_t safe = 1.0;
- real_t unsafe = 1.0;
- int best_shape=-1;
-
- for(int i=0;i<get_shape_count();i++) {
-
- if (is_shape_set_as_trigger(i))
- continue;
-
- real_t lsafe,lunsafe;
- bool valid = dss->cast_motion(get_shape(i)->get_rid(), get_global_transform() * get_shape_transform(i), p_motion, 0,lsafe,lunsafe,exclude,get_layer_mask(),mask);
- //print_line("shape: "+itos(i)+" travel:"+rtos(ltravel));
- if (!valid) {
-
- safe=0;
- unsafe=0;
- best_shape=i; //sadly it's the best
- break;
- }
- if (lsafe==1.0) {
- continue;
- }
- if (lsafe < safe) {
-
- safe=lsafe;
- unsafe=lunsafe;
- best_shape=i;
- }
- }
-
-
- //print_line("best shape: "+itos(best_shape)+" motion "+p_motion);
-
- if (safe>=1) {
- //not collided
- colliding=false;
- } else {
-
- //it collided, let's get the rest info in unsafe advance
- Matrix32 ugt = get_global_transform();
- ugt.elements[2]+=p_motion*unsafe;
- Physics2DDirectSpaceState::ShapeRestInfo rest_info;
- bool c2 = dss->rest_info(get_shape(best_shape)->get_rid(), ugt*get_shape_transform(best_shape), Vector2(), margin,&rest_info,exclude,get_layer_mask(),mask);
- if (!c2) {
- //should not happen, but floating point precision is so weird..
-
- colliding=false;
- } else {
-
-
- //print_line("Travel: "+rtos(travel));
- colliding=true;
- collision=rest_info.point;
- normal=rest_info.normal;
- collider=rest_info.collider_id;
- collider_vel=rest_info.linear_velocity;
- collider_shape=rest_info.shape;
- collider_metadata=rest_info.metadata;
- }
-
- }
-
- Vector2 motion=p_motion*safe;
- Matrix32 gt = get_global_transform();
- gt.elements[2]+=motion;
- set_global_transform(gt);
-
- return p_motion-motion;
-
-#endif
- return false;
}
void *Space2DSW::_broadphase_pair(CollisionObject2DSW *A, int p_subindex_A, CollisionObject2DSW *B, int p_subindex_B, void *p_self) {
@@ -1130,8 +974,8 @@ void Space2DSW::set_param(Physics2DServer::SpaceParameter p_param, real_t p_valu
case Physics2DServer::SPACE_PARAM_CONTACT_RECYCLE_RADIUS: contact_recycle_radius = p_value; break;
case Physics2DServer::SPACE_PARAM_CONTACT_MAX_SEPARATION: contact_max_separation = p_value; break;
case Physics2DServer::SPACE_PARAM_BODY_MAX_ALLOWED_PENETRATION: contact_max_allowed_penetration = p_value; break;
- case Physics2DServer::SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_TRESHOLD: body_linear_velocity_sleep_treshold = p_value; break;
- case Physics2DServer::SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_TRESHOLD: body_angular_velocity_sleep_treshold = p_value; break;
+ case Physics2DServer::SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD: body_linear_velocity_sleep_threshold = p_value; break;
+ case Physics2DServer::SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD: body_angular_velocity_sleep_threshold = p_value; break;
case Physics2DServer::SPACE_PARAM_BODY_TIME_TO_SLEEP: body_time_to_sleep = p_value; break;
case Physics2DServer::SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS: constraint_bias = p_value; break;
}
@@ -1144,8 +988,8 @@ real_t Space2DSW::get_param(Physics2DServer::SpaceParameter p_param) const {
case Physics2DServer::SPACE_PARAM_CONTACT_RECYCLE_RADIUS: return contact_recycle_radius;
case Physics2DServer::SPACE_PARAM_CONTACT_MAX_SEPARATION: return contact_max_separation;
case Physics2DServer::SPACE_PARAM_BODY_MAX_ALLOWED_PENETRATION: return contact_max_allowed_penetration;
- case Physics2DServer::SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_TRESHOLD: return body_linear_velocity_sleep_treshold;
- case Physics2DServer::SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_TRESHOLD: return body_angular_velocity_sleep_treshold;
+ case Physics2DServer::SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD: return body_linear_velocity_sleep_threshold;
+ case Physics2DServer::SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD: return body_angular_velocity_sleep_threshold;
case Physics2DServer::SPACE_PARAM_BODY_TIME_TO_SLEEP: return body_time_to_sleep;
case Physics2DServer::SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS: return constraint_bias;
}
@@ -1186,8 +1030,8 @@ Space2DSW::Space2DSW() {
contact_max_allowed_penetration = 0.3;
constraint_bias = 0.2;
- body_linear_velocity_sleep_treshold = GLOBAL_DEF("physics/2d/sleep_threashold_linear", 2.0);
- body_angular_velocity_sleep_treshold = GLOBAL_DEF("physics/2d/sleep_threshold_angular", (8.0 / 180.0 * Math_PI));
+ body_linear_velocity_sleep_threshold = GLOBAL_DEF("physics/2d/sleep_threshold_linear", 2.0);
+ body_angular_velocity_sleep_threshold = GLOBAL_DEF("physics/2d/sleep_threshold_angular", (8.0 / 180.0 * Math_PI));
body_time_to_sleep = GLOBAL_DEF("physics/2d/time_before_sleep", 0.5);
broadphase = BroadPhase2DSW::create_func();
diff --git a/servers/physics_2d/space_2d_sw.h b/servers/physics_2d/space_2d_sw.h
index 64841c4328..4bd81c054f 100644
--- a/servers/physics_2d/space_2d_sw.h
+++ b/servers/physics_2d/space_2d_sw.h
@@ -36,8 +36,8 @@
#include "body_pair_2d_sw.h"
#include "broad_phase_2d_sw.h"
#include "collision_object_2d_sw.h"
-#include "global_config.h"
#include "hash_map.h"
+#include "project_settings.h"
#include "typedefs.h"
class Physics2DDirectSpaceStateSW : public Physics2DDirectSpaceState {
@@ -103,8 +103,8 @@ private:
CollisionObject2DSW *intersection_query_results[INTERSECTION_QUERY_MAX];
int intersection_query_subindex_results[INTERSECTION_QUERY_MAX];
- real_t body_linear_velocity_sleep_treshold;
- real_t body_angular_velocity_sleep_treshold;
+ real_t body_linear_velocity_sleep_threshold;
+ real_t body_angular_velocity_sleep_threshold;
real_t body_time_to_sleep;
bool locked;
@@ -152,8 +152,8 @@ public:
_FORCE_INLINE_ real_t get_contact_max_separation() const { return contact_max_separation; }
_FORCE_INLINE_ real_t get_contact_max_allowed_penetration() const { return contact_max_allowed_penetration; }
_FORCE_INLINE_ real_t get_constraint_bias() const { return constraint_bias; }
- _FORCE_INLINE_ real_t get_body_linear_velocity_sleep_treshold() const { return body_linear_velocity_sleep_treshold; }
- _FORCE_INLINE_ real_t get_body_angular_velocity_sleep_treshold() const { return body_angular_velocity_sleep_treshold; }
+ _FORCE_INLINE_ real_t get_body_linear_velocity_sleep_threshold() const { return body_linear_velocity_sleep_threshold; }
+ _FORCE_INLINE_ real_t get_body_angular_velocity_sleep_threshold() const { return body_angular_velocity_sleep_threshold; }
_FORCE_INLINE_ real_t get_body_time_to_sleep() const { return body_time_to_sleep; }
void update();
diff --git a/servers/physics_2d_server.cpp b/servers/physics_2d_server.cpp
index 55ea2b41e7..fb7e89bd9e 100644
--- a/servers/physics_2d_server.cpp
+++ b/servers/physics_2d_server.cpp
@@ -607,8 +607,8 @@ void Physics2DServer::_bind_methods() {
BIND_CONSTANT(SPACE_PARAM_CONTACT_RECYCLE_RADIUS);
BIND_CONSTANT(SPACE_PARAM_CONTACT_MAX_SEPARATION);
BIND_CONSTANT(SPACE_PARAM_BODY_MAX_ALLOWED_PENETRATION);
- BIND_CONSTANT(SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_TRESHOLD);
- BIND_CONSTANT(SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_TRESHOLD);
+ BIND_CONSTANT(SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD);
+ BIND_CONSTANT(SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD);
BIND_CONSTANT(SPACE_PARAM_BODY_TIME_TO_SLEEP);
BIND_CONSTANT(SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS);
diff --git a/servers/physics_2d_server.h b/servers/physics_2d_server.h
index f50faa42eb..e396424707 100644
--- a/servers/physics_2d_server.h
+++ b/servers/physics_2d_server.h
@@ -272,8 +272,8 @@ public:
SPACE_PARAM_CONTACT_RECYCLE_RADIUS,
SPACE_PARAM_CONTACT_MAX_SEPARATION,
SPACE_PARAM_BODY_MAX_ALLOWED_PENETRATION,
- SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_TRESHOLD,
- SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_TRESHOLD,
+ SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD,
+ SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD,
SPACE_PARAM_BODY_TIME_TO_SLEEP,
SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS,
};
@@ -454,8 +454,8 @@ public:
virtual int body_get_max_contacts_reported(RID p_body) const = 0;
//missing remove
- virtual void body_set_contacts_reported_depth_treshold(RID p_body, float p_treshold) = 0;
- virtual float body_get_contacts_reported_depth_treshold(RID p_body) const = 0;
+ virtual void body_set_contacts_reported_depth_threshold(RID p_body, float p_threshold) = 0;
+ virtual float body_get_contacts_reported_depth_threshold(RID p_body) const = 0;
virtual void body_set_omit_force_integration(RID p_body, bool p_omit) = 0;
virtual bool body_is_omitting_force_integration(RID p_body) const = 0;
diff --git a/servers/physics_server.h b/servers/physics_server.h
index 3d1a2aec7a..0f07fca637 100644
--- a/servers/physics_server.h
+++ b/servers/physics_server.h
@@ -156,26 +156,28 @@ protected:
static void _bind_methods();
public:
- struct RayResult {
+ struct ShapeResult {
- Vector3 position;
- Vector3 normal;
RID rid;
ObjectID collider_id;
Object *collider;
int shape;
};
- virtual bool intersect_ray(const Vector3 &p_from, const Vector3 &p_to, RayResult &r_result, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_layer = 0xFFFFFFFF, uint32_t p_object_type_mask = TYPE_MASK_COLLISION, bool p_pick_ray = false) = 0;
+ virtual int intersect_point(const Vector3 &p_point, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_layer = 0xFFFFFFFF, uint32_t p_object_type_mask = TYPE_MASK_COLLISION) = 0;
- struct ShapeResult {
+ struct RayResult {
+ Vector3 position;
+ Vector3 normal;
RID rid;
ObjectID collider_id;
Object *collider;
int shape;
};
+ virtual bool intersect_ray(const Vector3 &p_from, const Vector3 &p_to, RayResult &r_result, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_layer = 0xFFFFFFFF, uint32_t p_object_type_mask = TYPE_MASK_COLLISION, bool p_pick_ray = false) = 0;
+
virtual int intersect_shape(const RID &p_shape, const Transform &p_xform, float p_margin, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_layer = 0xFFFFFFFF, uint32_t p_object_type_mask = TYPE_MASK_COLLISION) = 0;
struct ShapeRestInfo {
@@ -194,6 +196,8 @@ public:
virtual bool rest_info(RID p_shape, const Transform &p_shape_xform, float p_margin, ShapeRestInfo *r_info, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_layer = 0xFFFFFFFF, uint32_t p_object_type_mask = TYPE_MASK_COLLISION) = 0;
+ virtual Vector3 get_closest_point_to_object_volume(RID p_object, const Vector3 p_point) const = 0;
+
PhysicsDirectSpaceState();
};
@@ -261,8 +265,8 @@ public:
SPACE_PARAM_CONTACT_RECYCLE_RADIUS,
SPACE_PARAM_CONTACT_MAX_SEPARATION,
SPACE_PARAM_BODY_MAX_ALLOWED_PENETRATION,
- SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_TRESHOLD,
- SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_TRESHOLD,
+ SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD,
+ SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD,
SPACE_PARAM_BODY_TIME_TO_SLEEP,
SPACE_PARAM_BODY_ANGULAR_VELOCITY_DAMP_RATIO,
SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS,
@@ -322,6 +326,8 @@ public:
virtual void area_remove_shape(RID p_area, int p_shape_idx) = 0;
virtual void area_clear_shapes(RID p_area) = 0;
+ virtual void area_set_shape_disabled(RID p_area, int p_shape_idx, bool p_disabled) = 0;
+
virtual void area_attach_object_instance_ID(RID p_area, ObjectID p_ID) = 0;
virtual ObjectID area_get_object_instance_ID(RID p_area) const = 0;
@@ -370,12 +376,11 @@ public:
virtual RID body_get_shape(RID p_body, int p_shape_idx) const = 0;
virtual Transform body_get_shape_transform(RID p_body, int p_shape_idx) const = 0;
- virtual void body_set_shape_as_trigger(RID p_body, int p_shape_idx, bool p_enable) = 0;
- virtual bool body_is_shape_set_as_trigger(RID p_body, int p_shape_idx) const = 0;
-
virtual void body_remove_shape(RID p_body, int p_shape_idx) = 0;
virtual void body_clear_shapes(RID p_body) = 0;
+ virtual void body_set_shape_disabled(RID p_body, int p_shape_idx, bool p_disabled) = 0;
+
virtual void body_attach_object_instance_ID(RID p_body, uint32_t p_ID) = 0;
virtual uint32_t body_get_object_instance_ID(RID p_body) const = 0;
@@ -447,8 +452,8 @@ public:
virtual int body_get_max_contacts_reported(RID p_body) const = 0;
//missing remove
- virtual void body_set_contacts_reported_depth_treshold(RID p_body, float p_treshold) = 0;
- virtual float body_get_contacts_reported_depth_treshold(RID p_body) const = 0;
+ virtual void body_set_contacts_reported_depth_threshold(RID p_body, float p_threshold) = 0;
+ virtual float body_get_contacts_reported_depth_threshold(RID p_body) const = 0;
virtual void body_set_omit_force_integration(RID p_body, bool p_omit) = 0;
virtual bool body_is_omitting_force_integration(RID p_body) const = 0;
@@ -458,6 +463,23 @@ public:
virtual void body_set_ray_pickable(RID p_body, bool p_enable) = 0;
virtual bool body_is_ray_pickable(RID p_body) const = 0;
+ struct MotionResult {
+
+ Vector3 motion;
+ Vector3 remainder;
+
+ Vector3 collision_point;
+ Vector3 collision_normal;
+ Vector3 collider_velocity;
+ int collision_local_shape;
+ ObjectID collider_id;
+ RID collider;
+ int collider_shape;
+ Variant collider_metadata;
+ };
+
+ virtual bool body_test_motion(RID p_body, const Transform &p_from, const Vector3 &p_motion, float p_margin = 0.001, MotionResult *r_result = NULL) = 0;
+
/* JOINT API */
enum JointType {
diff --git a/servers/register_server_types.cpp b/servers/register_server_types.cpp
index 79b994dd27..092f445c13 100644
--- a/servers/register_server_types.cpp
+++ b/servers/register_server_types.cpp
@@ -28,8 +28,12 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "register_server_types.h"
-#include "global_config.h"
+#include "project_settings.h"
+#include "arvr/arvr_interface.h"
+#include "arvr/arvr_positional_tracker.h"
+#include "arvr/arvr_script_interface.h"
+#include "arvr_server.h"
#include "audio/audio_effect.h"
#include "audio/audio_stream.h"
#include "audio/effects/audio_effect_amplify.h"
@@ -70,20 +74,26 @@ static void _debugger_get_resource_usage(List<ScriptDebuggerRemote::ResourceUsag
}
ShaderTypes *shader_types = NULL;
+ARVRServer *arvr_server = NULL;
void register_server_types() {
+ arvr_server = memnew(ARVRServer);
- GLOBAL_DEF("memory/multithread/thread_rid_pool_prealloc", 20);
-
- GlobalConfig::get_singleton()->add_singleton(GlobalConfig::Singleton("VisualServer", VisualServer::get_singleton()));
- GlobalConfig::get_singleton()->add_singleton(GlobalConfig::Singleton("AudioServer", AudioServer::get_singleton()));
- GlobalConfig::get_singleton()->add_singleton(GlobalConfig::Singleton("PhysicsServer", PhysicsServer::get_singleton()));
- GlobalConfig::get_singleton()->add_singleton(GlobalConfig::Singleton("Physics2DServer", Physics2DServer::get_singleton()));
+ ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("VisualServer", VisualServer::get_singleton()));
+ ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("AudioServer", AudioServer::get_singleton()));
+ ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("PhysicsServer", PhysicsServer::get_singleton()));
+ ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("Physics2DServer", Physics2DServer::get_singleton()));
+ ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("ARVRServer", ARVRServer::get_singleton()));
shader_types = memnew(ShaderTypes);
+ ClassDB::register_virtual_class<ARVRInterface>();
+ ClassDB::register_class<ARVRPositionalTracker>();
+ ClassDB::register_class<ARVRScriptInterface>();
+
ClassDB::register_virtual_class<AudioStream>();
ClassDB::register_virtual_class<AudioStreamPlayback>();
+ ClassDB::register_class<AudioStreamRandomPitch>();
ClassDB::register_virtual_class<AudioEffect>();
ClassDB::register_class<AudioBusLayout>();
@@ -134,5 +144,9 @@ void register_server_types() {
void unregister_server_types() {
+ //@TODO move this into iPhone/Android implementation? just have this here for testing...
+ // mobile_interface = NULL;
+
memdelete(shader_types);
+ memdelete(arvr_server);
}
diff --git a/servers/visual/rasterizer.h b/servers/visual/rasterizer.h
index 5b60a46ade..9c264ead49 100644
--- a/servers/visual/rasterizer.h
+++ b/servers/visual/rasterizer.h
@@ -61,7 +61,7 @@ public:
virtual void environment_set_dof_blur_near(RID p_env, bool p_enable, float p_distance, float p_transition, float p_far_amount, VS::EnvironmentDOFBlurQuality p_quality) = 0;
virtual void environment_set_dof_blur_far(RID p_env, bool p_enable, float p_distance, float p_transition, float p_far_amount, VS::EnvironmentDOFBlurQuality p_quality) = 0;
- virtual void environment_set_glow(RID p_env, bool p_enable, int p_level_flags, float p_intensity, float p_strength, float p_bloom_treshold, VS::EnvironmentGlowBlendMode p_blend_mode, float p_hdr_bleed_treshold, float p_hdr_bleed_scale, bool p_bicubic_upscale) = 0;
+ virtual void environment_set_glow(RID p_env, bool p_enable, int p_level_flags, float p_intensity, float p_strength, float p_bloom_threshold, VS::EnvironmentGlowBlendMode p_blend_mode, float p_hdr_bleed_threshold, float p_hdr_bleed_scale, bool p_bicubic_upscale) = 0;
virtual void environment_set_fog(RID p_env, bool p_enable, float p_begin, float p_end, RID p_gradient_texture) = 0;
virtual void environment_set_ssr(RID p_env, bool p_enable, int p_max_steps, float p_fade_int, float p_fade_out, float p_depth_tolerance, bool p_roughness) = 0;
@@ -109,19 +109,20 @@ public:
bool mirror : 8;
bool receive_shadows : 8;
bool visible : 8;
+ bool baked_light : 8; //this flag is only to know if it actually did use baked light
float depth; //used for sorting
SelfList<InstanceBase> dependency_item;
- InstanceBase *baked_light; //baked light to use
- SelfList<InstanceBase> baked_light_item;
+ //InstanceBase *baked_light; //baked light to use
+ //SelfList<InstanceBase> baked_light_item;
virtual void base_removed() = 0;
virtual void base_changed() = 0;
virtual void base_material_changed() = 0;
InstanceBase()
- : dependency_item(this), baked_light_item(this) {
+ : dependency_item(this) {
base_type = VS::INSTANCE_NONE;
cast_shadows = VS::SHADOW_CASTING_SETTING_ON;
@@ -129,7 +130,7 @@ public:
visible = true;
depth_layer = 0;
layer_mask = 1;
- baked_light = NULL;
+ baked_light = false;
}
};
@@ -225,6 +226,8 @@ public:
virtual void material_set_line_width(RID p_material, float p_width) = 0;
+ virtual void material_set_next_pass(RID p_material, RID p_next_material) = 0;
+
virtual bool material_is_animated(RID p_material) = 0;
virtual bool material_casts_shadows(RID p_material) = 0;
@@ -420,6 +423,9 @@ public:
virtual void gi_probe_set_bias(RID p_probe, float p_range) = 0;
virtual float gi_probe_get_bias(RID p_probe) const = 0;
+ virtual void gi_probe_set_normal_bias(RID p_probe, float p_range) = 0;
+ virtual float gi_probe_get_normal_bias(RID p_probe) const = 0;
+
virtual void gi_probe_set_propagation(RID p_probe, float p_range) = 0;
virtual float gi_probe_get_propagation(RID p_probe) const = 0;
@@ -612,6 +618,7 @@ public:
enum Type {
TYPE_LINE,
+ TYPE_POLYLINE,
TYPE_RECT,
TYPE_NINEPATCH,
TYPE_PRIMITIVE,
@@ -636,6 +643,18 @@ public:
bool antialiased;
CommandLine() { type = TYPE_LINE; }
};
+ struct CommandPolyLine : public Command {
+
+ bool antialiased;
+ Vector<Point2> triangles;
+ Vector<Color> triangle_colors;
+ Vector<Point2> lines;
+ Vector<Color> line_colors;
+ CommandPolyLine() {
+ type = TYPE_POLYLINE;
+ antialiased = false;
+ }
+ };
struct CommandRect : public Command {
@@ -815,6 +834,31 @@ public:
r.position = line->from;
r.expand_to(line->to);
} break;
+ case Item::Command::TYPE_POLYLINE: {
+
+ const Item::CommandPolyLine *pline = static_cast<const Item::CommandPolyLine *>(c);
+ if (pline->triangles.size()) {
+ for (int j = 0; j < pline->triangles.size(); j++) {
+
+ if (j == 0) {
+ r.position = pline->triangles[j];
+ } else {
+ r.expand_to(pline->triangles[j]);
+ }
+ }
+ } else {
+
+ for (int j = 0; j < pline->lines.size(); j++) {
+
+ if (j == 0) {
+ r.position = pline->lines[j];
+ } else {
+ r.expand_to(pline->lines[j]);
+ }
+ }
+ }
+
+ } break;
case Item::Command::TYPE_RECT: {
const Item::CommandRect *crect = static_cast<const Item::CommandRect *>(c);
diff --git a/servers/visual/shader_language.cpp b/servers/visual/shader_language.cpp
index 96d56dfc56..49f9e161fa 100644
--- a/servers/visual/shader_language.cpp
+++ b/servers/visual/shader_language.cpp
@@ -1357,11 +1357,8 @@ const ShaderLanguage::BuiltinFuncDef ShaderLanguage::builtin_func_defs[] = {
{ "tanh", TYPE_FLOAT, { TYPE_FLOAT, TYPE_VOID } },
//builtins - exponential
{ "pow", TYPE_FLOAT, { TYPE_FLOAT, TYPE_FLOAT, TYPE_VOID } },
- { "pow", TYPE_VEC2, { TYPE_VEC2, TYPE_FLOAT, TYPE_VOID } },
{ "pow", TYPE_VEC2, { TYPE_VEC2, TYPE_VEC2, TYPE_VOID } },
- { "pow", TYPE_VEC3, { TYPE_VEC3, TYPE_FLOAT, TYPE_VOID } },
{ "pow", TYPE_VEC3, { TYPE_VEC3, TYPE_VEC3, TYPE_VOID } },
- { "pow", TYPE_VEC4, { TYPE_VEC4, TYPE_FLOAT, TYPE_VOID } },
{ "pow", TYPE_VEC4, { TYPE_VEC4, TYPE_VEC4, TYPE_VOID } },
{ "exp", TYPE_FLOAT, { TYPE_FLOAT, TYPE_VOID } },
{ "exp", TYPE_VEC2, { TYPE_VEC2, TYPE_VOID } },
diff --git a/servers/visual/shader_types.cpp b/servers/visual/shader_types.cpp
index b04c8716fb..3de0841f2a 100644
--- a/servers/visual/shader_types.cpp
+++ b/servers/visual/shader_types.cpp
@@ -66,6 +66,7 @@ ShaderTypes::ShaderTypes() {
shader_modes[VS::SHADER_SPATIAL].functions["vertex"]["POINT_SIZE"] = ShaderLanguage::TYPE_FLOAT;
shader_modes[VS::SHADER_SPATIAL].functions["vertex"]["INSTANCE_ID"] = ShaderLanguage::TYPE_INT;
shader_modes[VS::SHADER_SPATIAL].functions["vertex"]["INSTANCE_CUSTOM"] = ShaderLanguage::TYPE_VEC4;
+ shader_modes[VS::SHADER_SPATIAL].functions["vertex"]["ROUGHNESS"] = ShaderLanguage::TYPE_FLOAT;
//builtins
shader_modes[VS::SHADER_SPATIAL].functions["vertex"]["WORLD_MATRIX"] = ShaderLanguage::TYPE_MAT4;
@@ -136,8 +137,18 @@ ShaderTypes::ShaderTypes() {
shader_modes[VS::SHADER_SPATIAL].modes.insert("diffuse_half_lambert");
shader_modes[VS::SHADER_SPATIAL].modes.insert("diffuse_oren_nayar");
shader_modes[VS::SHADER_SPATIAL].modes.insert("diffuse_burley");
+ shader_modes[VS::SHADER_SPATIAL].modes.insert("diffuse_toon");
- shader_modes[VS::SHADER_SPATIAL].modes.insert("skip_default_transform");
+ shader_modes[VS::SHADER_SPATIAL].modes.insert("specular_schlick_ggx");
+ shader_modes[VS::SHADER_SPATIAL].modes.insert("specular_blinn");
+ shader_modes[VS::SHADER_SPATIAL].modes.insert("specular_phong");
+ shader_modes[VS::SHADER_SPATIAL].modes.insert("specular_toon");
+ shader_modes[VS::SHADER_SPATIAL].modes.insert("specular_disabled");
+
+ shader_modes[VS::SHADER_SPATIAL].modes.insert("skip_vertex_transform");
+ shader_modes[VS::SHADER_SPATIAL].modes.insert("world_vertex_coords");
+
+ shader_modes[VS::SHADER_SPATIAL].modes.insert("vertex_lighting");
/************ CANVAS ITEM **************************/
@@ -188,7 +199,7 @@ ShaderTypes::ShaderTypes() {
shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"]["POINT_COORD"] = ShaderLanguage::TYPE_VEC2;
shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"]["TIME"] = ShaderLanguage::TYPE_FLOAT;
- shader_modes[VS::SHADER_CANVAS_ITEM].modes.insert("skip_transform");
+ shader_modes[VS::SHADER_CANVAS_ITEM].modes.insert("skip_vertex_transform");
shader_modes[VS::SHADER_CANVAS_ITEM].modes.insert("blend_mix");
shader_modes[VS::SHADER_CANVAS_ITEM].modes.insert("blend_add");
diff --git a/servers/visual/visual_server_canvas.cpp b/servers/visual/visual_server_canvas.cpp
index 1227863b72..584f45412e 100644
--- a/servers/visual/visual_server_canvas.cpp
+++ b/servers/visual/visual_server_canvas.cpp
@@ -392,14 +392,14 @@ void VisualServerCanvas::canvas_item_set_draw_behind_parent(RID p_item, bool p_e
canvas_item->behind = p_enable;
}
-void VisualServerCanvas::canvas_item_add_line(RID p_item, const Point2 &p_from, const Point2 &p_to, const Color &p_color, float p_width, bool p_antialiased) {
+void VisualServerCanvas::canvas_item_add_line(RID p_item, const Point2 &p_from, const Point2 &p_to, const Color &p_colors, float p_width, bool p_antialiased) {
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
Item::CommandLine *line = memnew(Item::CommandLine);
ERR_FAIL_COND(!line);
- line->color = p_color;
+ line->color = p_colors;
line->from = p_from;
line->to = p_to;
line->width = p_width;
@@ -409,6 +409,86 @@ void VisualServerCanvas::canvas_item_add_line(RID p_item, const Point2 &p_from,
canvas_item->commands.push_back(line);
}
+void VisualServerCanvas::canvas_item_add_polyline(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, float p_width, bool p_antialiased) {
+
+ ERR_FAIL_COND(p_points.size() < 2);
+ Item *canvas_item = canvas_item_owner.getornull(p_item);
+ ERR_FAIL_COND(!canvas_item);
+
+ Item::CommandPolyLine *pline = memnew(Item::CommandPolyLine);
+ ERR_FAIL_COND(!pline);
+
+ pline->antialiased = p_antialiased;
+
+ if (p_width <= 1) {
+ pline->lines = p_points;
+ pline->line_colors = p_colors;
+ if (pline->line_colors.size() == 0) {
+ pline->line_colors.push_back(Color(1, 1, 1, 1));
+ } else if (pline->line_colors.size() > 1 && pline->line_colors.size() != pline->lines.size()) {
+ pline->line_colors.resize(1);
+ }
+ } else {
+ //make a trianglestrip for drawing the line...
+ Vector2 prev_t;
+ pline->triangles.resize(p_points.size() * 2);
+ if (p_antialiased) {
+ pline->lines.resize(p_points.size() * 2);
+ }
+
+ if (p_colors.size() == 0) {
+ pline->triangle_colors.push_back(Color(1, 1, 1, 1));
+ if (p_antialiased) {
+ pline->line_colors.push_back(Color(1, 1, 1, 1));
+ }
+ }
+ if (p_colors.size() == 1) {
+ pline->triangle_colors = p_colors;
+ pline->line_colors = p_colors;
+ } else {
+ pline->triangle_colors.resize(pline->triangles.size());
+ pline->line_colors.resize(pline->lines.size());
+ }
+
+ for (int i = 0; i < p_points.size(); i++) {
+
+ Vector2 t;
+ if (i == p_points.size() - 1) {
+ t = prev_t;
+ } else {
+ t = (p_points[i + 1] - p_points[i]).normalized().tangent();
+ if (i == 0) {
+ prev_t = t;
+ }
+ }
+
+ Vector2 tangent = ((t + prev_t).normalized()) * p_width * 0.5;
+
+ if (p_antialiased) {
+ pline->lines[i] = p_points[i] + tangent;
+ pline->lines[p_points.size() * 2 - i - 1] = p_points[i] - tangent;
+ if (pline->line_colors.size() > 1) {
+ pline->line_colors[i] = p_colors[i];
+ pline->line_colors[p_points.size() * 2 - i - 1] = p_colors[i];
+ }
+ }
+
+ pline->triangles[i * 2 + 0] = p_points[i] + tangent;
+ pline->triangles[i * 2 + 1] = p_points[i] - tangent;
+
+ if (pline->triangle_colors.size() > 1) {
+
+ pline->triangle_colors[i * 2 + 0] = p_colors[i];
+ pline->triangle_colors[i * 2 + 1] = p_colors[i];
+ }
+
+ prev_t = t;
+ }
+ }
+ canvas_item->rect_dirty = true;
+ canvas_item->commands.push_back(pline);
+}
+
void VisualServerCanvas::canvas_item_add_rect(RID p_item, const Rect2 &p_rect, const Color &p_color) {
Item *canvas_item = canvas_item_owner.getornull(p_item);
diff --git a/servers/visual/visual_server_canvas.h b/servers/visual/visual_server_canvas.h
index 57c7515367..48e3186ece 100644
--- a/servers/visual/visual_server_canvas.h
+++ b/servers/visual/visual_server_canvas.h
@@ -171,6 +171,7 @@ public:
void canvas_item_set_draw_behind_parent(RID p_item, bool p_enable);
void canvas_item_add_line(RID p_item, const Point2 &p_from, const Point2 &p_to, const Color &p_color, float p_width = 1.0, bool p_antialiased = false);
+ void canvas_item_add_polyline(RID p_item, const Vector<Point2> &p_line, const Vector<Color> &p_colors, float p_width = 1.0, bool p_antialiased = false);
void canvas_item_add_rect(RID p_item, const Rect2 &p_rect, const Color &p_color);
void canvas_item_add_circle(RID p_item, const Point2 &p_pos, float p_radius, const Color &p_color);
void canvas_item_add_texture_rect(RID p_item, const Rect2 &p_rect, RID p_texture, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, RID p_normal_map = RID());
diff --git a/servers/visual/visual_server_raster.cpp b/servers/visual/visual_server_raster.cpp
index 8d332b3e6c..f17411f11a 100644
--- a/servers/visual/visual_server_raster.cpp
+++ b/servers/visual/visual_server_raster.cpp
@@ -29,9 +29,9 @@
/*************************************************************************/
#include "visual_server_raster.h"
#include "default_mouse_cursor.xpm"
-#include "global_config.h"
#include "io/marshalls.h"
#include "os/os.h"
+#include "project_settings.h"
#include "sort.h"
#include "visual_server_canvas.h"
#include "visual_server_global.h"
diff --git a/servers/visual/visual_server_raster.h b/servers/visual/visual_server_raster.h
index e201f6a8c0..b13bb904ab 100644
--- a/servers/visual/visual_server_raster.h
+++ b/servers/visual/visual_server_raster.h
@@ -685,6 +685,7 @@ public:
BIND2RC(Variant, material_get_param, RID, const StringName &)
BIND2(material_set_line_width, RID, float)
+ BIND2(material_set_next_pass, RID, RID)
/* MESH API */
@@ -843,6 +844,9 @@ public:
BIND2(gi_probe_set_bias, RID, float)
BIND1RC(float, gi_probe_get_bias, RID)
+ BIND2(gi_probe_set_normal_bias, RID, float)
+ BIND1RC(float, gi_probe_get_normal_bias, RID)
+
BIND2(gi_probe_set_propagation, RID, float)
BIND1RC(float, gi_probe_get_propagation, RID)
@@ -904,6 +908,7 @@ public:
BIND0R(RID, viewport_create)
+ BIND2(viewport_set_use_arvr, RID, bool)
BIND3(viewport_set_size, RID, int, int)
BIND2(viewport_set_active, RID, bool)
@@ -1042,6 +1047,7 @@ public:
BIND2(canvas_item_set_draw_behind_parent, RID, bool)
BIND6(canvas_item_add_line, RID, const Point2 &, const Point2 &, const Color &, float, bool)
+ BIND5(canvas_item_add_polyline, RID, const Vector<Point2> &, const Vector<Color> &, float, bool)
BIND3(canvas_item_add_rect, RID, const Rect2 &, const Color &)
BIND4(canvas_item_add_circle, RID, const Point2 &, float, const Color &)
BIND7(canvas_item_add_texture_rect, RID, const Rect2 &, RID, bool, const Color &, bool, RID)
diff --git a/servers/visual/visual_server_scene.cpp b/servers/visual/visual_server_scene.cpp
index fb1c66d0b9..87431a2ce4 100644
--- a/servers/visual/visual_server_scene.cpp
+++ b/servers/visual/visual_server_scene.cpp
@@ -993,6 +993,11 @@ void VisualServerScene::instance_geometry_set_flag(RID p_instance, VS::InstanceF
instance->visible_in_all_rooms = p_enabled;
} break;
+ case VS::INSTANCE_FLAG_USE_BAKED_LIGHT: {
+
+ instance->baked_light = p_enabled;
+
+ } break;
}
}
void VisualServerScene::instance_geometry_set_cast_shadows_setting(RID p_instance, VS::ShadowCastingSetting p_shadow_casting_setting) {
@@ -1482,6 +1487,8 @@ void VisualServerScene::_light_instance_update_shadow(Instance *p_instance, cons
// a pre pass will need to be needed to determine the actual z-near to be used
+ Plane near_plane(p_instance->transform.origin, -p_instance->transform.basis.get_axis(2));
+
for (int j = 0; j < cull_count; j++) {
float min, max;
@@ -1494,6 +1501,8 @@ void VisualServerScene::_light_instance_update_shadow(Instance *p_instance, cons
}
instance->transformed_aabb.project_range_in_plane(Plane(z_vec, 0), min, max);
+ instance->depth = near_plane.distance_to(instance->transform.origin);
+ instance->depth_layer = 0;
if (max > z_max)
z_max = max;
}
@@ -1539,6 +1548,7 @@ void VisualServerScene::_light_instance_update_shadow(Instance *p_instance, cons
planes[4] = p_instance->transform.xform(Plane(Vector3(0, -1, z).normalized(), radius));
int cull_count = p_scenario->octree.cull_convex(planes, instance_shadow_cull_result, MAX_INSTANCE_CULL, VS::INSTANCE_GEOMETRY_MASK);
+ Plane near_plane(p_instance->transform.origin, p_instance->transform.basis.get_axis(2) * z);
for (int j = 0; j < cull_count; j++) {
@@ -1547,6 +1557,9 @@ void VisualServerScene::_light_instance_update_shadow(Instance *p_instance, cons
cull_count--;
SWAP(instance_shadow_cull_result[j], instance_shadow_cull_result[cull_count]);
j--;
+ } else {
+ instance->depth = near_plane.distance_to(instance->transform.origin);
+ instance->depth_layer = 0;
}
}
@@ -1587,6 +1600,7 @@ void VisualServerScene::_light_instance_update_shadow(Instance *p_instance, cons
int cull_count = p_scenario->octree.cull_convex(planes, instance_shadow_cull_result, MAX_INSTANCE_CULL, VS::INSTANCE_GEOMETRY_MASK);
+ Plane near_plane(xform.origin, -xform.basis.get_axis(2));
for (int j = 0; j < cull_count; j++) {
Instance *instance = instance_shadow_cull_result[j];
@@ -1594,6 +1608,9 @@ void VisualServerScene::_light_instance_update_shadow(Instance *p_instance, cons
cull_count--;
SWAP(instance_shadow_cull_result[j], instance_shadow_cull_result[cull_count]);
j--;
+ } else {
+ instance->depth = near_plane.distance_to(instance->transform.origin);
+ instance->depth_layer = 0;
}
}
@@ -1619,6 +1636,7 @@ void VisualServerScene::_light_instance_update_shadow(Instance *p_instance, cons
Vector<Plane> planes = cm.get_projection_planes(p_instance->transform);
int cull_count = p_scenario->octree.cull_convex(planes, instance_shadow_cull_result, MAX_INSTANCE_CULL, VS::INSTANCE_GEOMETRY_MASK);
+ Plane near_plane(p_instance->transform.origin, -p_instance->transform.basis.get_axis(2));
for (int j = 0; j < cull_count; j++) {
Instance *instance = instance_shadow_cull_result[j];
@@ -1626,6 +1644,9 @@ void VisualServerScene::_light_instance_update_shadow(Instance *p_instance, cons
cull_count--;
SWAP(instance_shadow_cull_result[j], instance_shadow_cull_result[cull_count]);
j--;
+ } else {
+ instance->depth = near_plane.distance_to(instance->transform.origin);
+ instance->depth_layer = 0;
}
}
@@ -1637,6 +1658,7 @@ void VisualServerScene::_light_instance_update_shadow(Instance *p_instance, cons
}
void VisualServerScene::render_camera(RID p_camera, RID p_scenario, Size2 p_viewport_size, RID p_shadow_atlas) {
+ // render to mono camera
Camera *camera = camera_owner.getornull(p_camera);
ERR_FAIL_COND(!camera);
@@ -1676,6 +1698,25 @@ void VisualServerScene::render_camera(RID p_camera, RID p_scenario, Size2 p_view
_render_scene(camera->transform, camera_matrix, ortho, camera->env, camera->visible_layers, p_scenario, p_shadow_atlas, RID(), -1);
}
+void VisualServerScene::render_camera(Ref<ARVRInterface> &p_interface, ARVRInterface::Eyes p_eye, RID p_camera, RID p_scenario, Size2 p_viewport_size, RID p_shadow_atlas) {
+ // render for AR/VR interface
+
+ Camera *camera = camera_owner.getornull(p_camera);
+ ERR_FAIL_COND(!camera);
+
+ /* SETUP CAMERA, we are ignoring type and FOV here */
+ bool ortho = false;
+ float aspect = p_viewport_size.width / (float)p_viewport_size.height;
+ CameraMatrix camera_matrix = p_interface->get_projection_for_eye(p_eye, aspect, camera->znear, camera->zfar);
+
+ // We also ignore our camera position, it will have been positioned with a slightly old tracking position.
+ // Instead we take our origin point and have our ar/vr interface add fresh tracking data! Whoohoo!
+ Transform world_origin = ARVRServer::get_singleton()->get_world_origin();
+ Transform cam_transform = p_interface->get_transform_for_eye(p_eye, world_origin);
+
+ _render_scene(cam_transform, camera_matrix, ortho, camera->env, camera->visible_layers, p_scenario, p_shadow_atlas, RID(), -1);
+};
+
void VisualServerScene::_render_scene(const Transform p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_orthogonal, RID p_force_environment, uint32_t p_visible_layers, RID p_scenario, RID p_shadow_atlas, RID p_reflection_probe, int p_reflection_probe_pass) {
Scenario *scenario = scenario_owner.getornull(p_scenario);
@@ -1833,7 +1874,7 @@ void VisualServerScene::_render_scene(const Transform p_cam_transform, const Cam
if (reflection_probe->reflection_dirty || VSG::scene_render->reflection_probe_instance_needs_redraw(reflection_probe->instance)) {
if (!reflection_probe->update_list.in_list()) {
reflection_probe->render_step = 0;
- reflection_probe_render_list.add(&reflection_probe->update_list);
+ reflection_probe_render_list.add_last(&reflection_probe->update_list);
}
reflection_probe->reflection_dirty = false;
@@ -2695,8 +2736,8 @@ void VisualServerScene::_bake_gi_probe_light(const GIProbeDataHeader *header, co
success_count++;
}
}
- print_line("BAKE TIME: " + rtos((OS::get_singleton()->get_ticks_usec() - us) / 1000000.0));
- print_line("valid cells: " + itos(success_count));
+ //print_line("BAKE TIME: " + rtos((OS::get_singleton()->get_ticks_usec() - us) / 1000000.0));
+ //print_line("valid cells: " + itos(success_count));
} break;
case VS::LIGHT_OMNI:
@@ -2801,7 +2842,7 @@ void VisualServerScene::_bake_gi_probe_light(const GIProbeDataHeader *header, co
light->energy[2] += int32_t(light_b * att * ((cell->albedo) & 0xFF) / 255.0);
}
}
- print_line("BAKE TIME: " + rtos((OS::get_singleton()->get_ticks_usec() - us) / 1000000.0));
+ //print_line("BAKE TIME: " + rtos((OS::get_singleton()->get_ticks_usec() - us) / 1000000.0));
} break;
}
@@ -2900,7 +2941,7 @@ void VisualServerScene::_bake_gi_probe(Instance *p_gi_probe) {
if (stage >= probe_data->dynamic.mipmaps_3d.size())
continue; //no mipmap for this one
- print_line("generating mipmap stage: " + itos(stage));
+ //print_line("generating mipmap stage: " + itos(stage));
int level_cell_count = probe_data->dynamic.level_cell_lists[i].size();
const uint32_t *level_cells = probe_data->dynamic.level_cell_lists[i].ptr();
@@ -3344,6 +3385,8 @@ void VisualServerScene::_update_dirty_instance(Instance *p_instance) {
for (int i = 0; i < dp; i++) {
RID mesh = VSG::storage->particles_get_draw_pass_mesh(p_instance->base, i);
+ if (!mesh.is_valid())
+ continue;
int sc = VSG::storage->mesh_get_surface_count(mesh);
for (int j = 0; j < sc; j++) {
diff --git a/servers/visual/visual_server_scene.h b/servers/visual/visual_server_scene.h
index d13c24ae24..17b95946b3 100644
--- a/servers/visual/visual_server_scene.h
+++ b/servers/visual/visual_server_scene.h
@@ -36,9 +36,9 @@
#include "geometry.h"
#include "octree.h"
#include "os/semaphore.h"
-#include "os/semaphore.h"
#include "os/thread.h"
#include "self_list.h"
+#include "servers/arvr/arvr_interface.h"
class VisualServerScene {
public:
@@ -522,6 +522,7 @@ public:
void render_empty_scene(RID p_scenario, RID p_shadow_atlas);
void render_camera(RID p_camera, RID p_scenario, Size2 p_viewport_size, RID p_shadow_atlas);
+ void render_camera(Ref<ARVRInterface> &p_interface, ARVRInterface::Eyes p_eye, RID p_camera, RID p_scenario, Size2 p_viewport_size, RID p_shadow_atlas);
void update_dirty_instances();
//probes
diff --git a/servers/visual/visual_server_viewport.cpp b/servers/visual/visual_server_viewport.cpp
index 2c2bd2b167..ad9dec090a 100644
--- a/servers/visual/visual_server_viewport.cpp
+++ b/servers/visual/visual_server_viewport.cpp
@@ -28,12 +28,12 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "visual_server_viewport.h"
-#include "global_config.h"
+#include "project_settings.h"
#include "visual_server_canvas.h"
#include "visual_server_global.h"
#include "visual_server_scene.h"
-void VisualServerViewport::_draw_viewport(Viewport *p_viewport) {
+void VisualServerViewport::_draw_viewport(Viewport *p_viewport, ARVRInterface::Eyes p_eye) {
/* Camera should always be BEFORE any other 3D */
@@ -90,8 +90,13 @@ void VisualServerViewport::_draw_viewport(Viewport *p_viewport) {
}
if (!scenario_draw_canvas_bg && can_draw_3d) {
+ Ref<ARVRInterface> arvr_interface = ARVRServer::get_singleton()->get_primary_interface();
- VSG::scene->render_camera(p_viewport->camera, p_viewport->scenario, p_viewport->size, p_viewport->shadow_atlas);
+ if (p_viewport->use_arvr && arvr_interface.is_valid()) {
+ VSG::scene->render_camera(arvr_interface, p_eye, p_viewport->camera, p_viewport->scenario, p_viewport->size, p_viewport->shadow_atlas);
+ } else {
+ VSG::scene->render_camera(p_viewport->camera, p_viewport->scenario, p_viewport->size, p_viewport->shadow_atlas);
+ }
}
if (!p_viewport->hide_canvas) {
@@ -260,15 +265,19 @@ void VisualServerViewport::_draw_viewport(Viewport *p_viewport) {
}
void VisualServerViewport::draw_viewports() {
+ // get our arvr interface in case we need it
+ Ref<ARVRInterface> arvr_interface = ARVRServer::get_singleton()->get_primary_interface();
+ if (arvr_interface.is_valid()) {
+ // update our positioning information as late as possible...
+ arvr_interface->process();
+ }
- //sort viewports
-
- //draw viewports
-
- clear_color = GLOBAL_GET("rendering/viewport/default_clear_color");
+ clear_color = GLOBAL_GET("rendering/environment/default_clear_color");
+ //sort viewports
active_viewports.sort_custom<ViewportSort>();
+ //draw viewports
for (int i = 0; i < active_viewports.size(); i++) {
Viewport *vp = active_viewports[i];
@@ -279,31 +288,54 @@ void VisualServerViewport::draw_viewports() {
ERR_CONTINUE(!vp->render_target.is_valid());
bool visible = vp->viewport_to_screen_rect != Rect2() || vp->update_mode == VS::VIEWPORT_UPDATE_ALWAYS || vp->update_mode == VS::VIEWPORT_UPDATE_ONCE || (vp->update_mode == VS::VIEWPORT_UPDATE_WHEN_VISIBLE && VSG::storage->render_target_was_used(vp->render_target));
+ visible = visible && vp->size.x > 0 && vp->size.y > 0;
if (!visible)
continue;
VSG::storage->render_target_clear_used(vp->render_target);
- VSG::rasterizer->set_current_render_target(vp->render_target);
+ if (vp->use_arvr && arvr_interface.is_valid()) {
+ // override our size, make sure it matches our required size
+ Size2 size = arvr_interface->get_recommended_render_targetsize();
+ VSG::storage->render_target_set_size(vp->render_target, size.x, size.y);
- VSG::scene_render->set_debug_draw_mode(vp->debug_draw);
- VSG::storage->render_info_begin_capture();
+ // render mono or left eye first
+ ARVRInterface::Eyes leftOrMono = arvr_interface->is_stereo() ? ARVRInterface::EYE_LEFT : ARVRInterface::EYE_MONO;
+ VSG::rasterizer->set_current_render_target(vp->render_target);
+ _draw_viewport(vp, leftOrMono);
+ arvr_interface->commit_for_eye(leftOrMono, vp->render_target, vp->viewport_to_screen_rect);
- _draw_viewport(vp);
+ // render right eye
+ if (leftOrMono == ARVRInterface::EYE_LEFT) {
+ // commit for eye may have changed the render target
+ VSG::rasterizer->set_current_render_target(vp->render_target);
- VSG::storage->render_info_end_capture();
- vp->render_info[VS::VIEWPORT_RENDER_INFO_OBJECTS_IN_FRAME] = VSG::storage->get_captured_render_info(VS::INFO_OBJECTS_IN_FRAME);
- vp->render_info[VS::VIEWPORT_RENDER_INFO_VERTICES_IN_FRAME] = VSG::storage->get_captured_render_info(VS::INFO_VERTICES_IN_FRAME);
- vp->render_info[VS::VIEWPORT_RENDER_INFO_MATERIAL_CHANGES_IN_FRAME] = VSG::storage->get_captured_render_info(VS::INFO_MATERIAL_CHANGES_IN_FRAME);
- vp->render_info[VS::VIEWPORT_RENDER_INFO_SHADER_CHANGES_IN_FRAME] = VSG::storage->get_captured_render_info(VS::INFO_SHADER_CHANGES_IN_FRAME);
- vp->render_info[VS::VIEWPORT_RENDER_INFO_SURFACE_CHANGES_IN_FRAME] = VSG::storage->get_captured_render_info(VS::INFO_SURFACE_CHANGES_IN_FRAME);
- vp->render_info[VS::VIEWPORT_RENDER_INFO_DRAW_CALLS_IN_FRAME] = VSG::storage->get_captured_render_info(VS::INFO_DRAW_CALLS_IN_FRAME);
-
- if (vp->viewport_to_screen_rect != Rect2()) {
- //copy to screen if set as such
- VSG::rasterizer->set_current_render_target(RID());
- VSG::rasterizer->blit_render_target_to_screen(vp->render_target, vp->viewport_to_screen_rect, vp->viewport_to_screen);
+ _draw_viewport(vp, ARVRInterface::EYE_RIGHT);
+ arvr_interface->commit_for_eye(ARVRInterface::EYE_RIGHT, vp->render_target, vp->viewport_to_screen_rect);
+ }
+ } else {
+ VSG::rasterizer->set_current_render_target(vp->render_target);
+
+ VSG::scene_render->set_debug_draw_mode(vp->debug_draw);
+ VSG::storage->render_info_begin_capture();
+
+ // render standard mono camera
+ _draw_viewport(vp);
+
+ VSG::storage->render_info_end_capture();
+ vp->render_info[VS::VIEWPORT_RENDER_INFO_OBJECTS_IN_FRAME] = VSG::storage->get_captured_render_info(VS::INFO_OBJECTS_IN_FRAME);
+ vp->render_info[VS::VIEWPORT_RENDER_INFO_VERTICES_IN_FRAME] = VSG::storage->get_captured_render_info(VS::INFO_VERTICES_IN_FRAME);
+ vp->render_info[VS::VIEWPORT_RENDER_INFO_MATERIAL_CHANGES_IN_FRAME] = VSG::storage->get_captured_render_info(VS::INFO_MATERIAL_CHANGES_IN_FRAME);
+ vp->render_info[VS::VIEWPORT_RENDER_INFO_SHADER_CHANGES_IN_FRAME] = VSG::storage->get_captured_render_info(VS::INFO_SHADER_CHANGES_IN_FRAME);
+ vp->render_info[VS::VIEWPORT_RENDER_INFO_SURFACE_CHANGES_IN_FRAME] = VSG::storage->get_captured_render_info(VS::INFO_SURFACE_CHANGES_IN_FRAME);
+ vp->render_info[VS::VIEWPORT_RENDER_INFO_DRAW_CALLS_IN_FRAME] = VSG::storage->get_captured_render_info(VS::INFO_DRAW_CALLS_IN_FRAME);
+
+ if (vp->viewport_to_screen_rect != Rect2()) {
+ //copy to screen if set as such
+ VSG::rasterizer->set_current_render_target(RID());
+ VSG::rasterizer->blit_render_target_to_screen(vp->render_target, vp->viewport_to_screen_rect, vp->viewport_to_screen);
+ }
}
if (vp->update_mode == VS::VIEWPORT_UPDATE_ONCE) {
@@ -328,6 +360,13 @@ RID VisualServerViewport::viewport_create() {
return rid;
}
+void VisualServerViewport::viewport_set_use_arvr(RID p_viewport, bool p_use_arvr) {
+ Viewport *viewport = viewport_owner.getornull(p_viewport);
+ ERR_FAIL_COND(!viewport);
+
+ viewport->use_arvr = p_use_arvr;
+}
+
void VisualServerViewport::viewport_set_size(RID p_viewport, int p_width, int p_height) {
ERR_FAIL_COND(p_width < 0 && p_height < 0);
diff --git a/servers/visual/visual_server_viewport.h b/servers/visual/visual_server_viewport.h
index f963ce4aa3..93227d1c31 100644
--- a/servers/visual/visual_server_viewport.h
+++ b/servers/visual/visual_server_viewport.h
@@ -32,6 +32,7 @@
#include "rasterizer.h"
#include "self_list.h"
+#include "servers/arvr/arvr_interface.h"
#include "servers/visual_server.h"
class VisualServerViewport {
@@ -44,6 +45,8 @@ public:
RID self;
RID parent;
+ bool use_arvr; /* use arvr interface to override camera positioning and projection matrices and control output */
+
Size2i size;
RID camera;
RID scenario;
@@ -107,6 +110,7 @@ public:
for (int i = 0; i < VS::VIEWPORT_RENDER_INFO_MAX; i++) {
render_info[i] = 0;
}
+ use_arvr = false;
}
};
@@ -131,11 +135,13 @@ public:
private:
Color clear_color;
- void _draw_viewport(Viewport *p_viewport);
+ void _draw_viewport(Viewport *p_viewport, ARVRInterface::Eyes p_eye = ARVRInterface::EYE_MONO);
public:
RID viewport_create();
+ void viewport_set_use_arvr(RID p_viewport, bool p_use_arvr);
+
void viewport_set_size(RID p_viewport, int p_width, int p_height);
void viewport_attach_to_screen(RID p_viewport, const Rect2 &p_rect = Rect2(), int p_screen = 0);
diff --git a/servers/visual/visual_server_wrap_mt.cpp b/servers/visual/visual_server_wrap_mt.cpp
index fd15633244..525e3dc2f9 100644
--- a/servers/visual/visual_server_wrap_mt.cpp
+++ b/servers/visual/visual_server_wrap_mt.cpp
@@ -27,8 +27,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "visual_server_wrap_mt.h"
-#include "global_config.h"
#include "os/os.h"
+#include "project_settings.h"
void VisualServerWrapMT::thread_exit() {
@@ -176,7 +176,7 @@ VisualServerWrapMT::VisualServerWrapMT(VisualServer *p_contained, bool p_create_
draw_pending = 0;
draw_thread_up = false;
alloc_mutex = Mutex::create();
- pool_max_size = GLOBAL_DEF("memory/servers/thread_rid_prealloc_amount", 20);
+ pool_max_size = GLOBAL_GET("memory/limits/multithreaded_server/rid_pool_prealloc");
if (!p_create_thread) {
server_thread = Thread::get_caller_ID();
diff --git a/servers/visual/visual_server_wrap_mt.h b/servers/visual/visual_server_wrap_mt.h
index 9f49377fa8..e6ce3f6a54 100644
--- a/servers/visual/visual_server_wrap_mt.h
+++ b/servers/visual/visual_server_wrap_mt.h
@@ -129,6 +129,7 @@ public:
FUNC2RC(Variant, material_get_param, RID, const StringName &)
FUNC2(material_set_line_width, RID, float)
+ FUNC2(material_set_next_pass, RID, RID)
/* MESH API */
@@ -287,6 +288,9 @@ public:
FUNC2(gi_probe_set_bias, RID, float)
FUNC1RC(float, gi_probe_get_bias, RID)
+ FUNC2(gi_probe_set_normal_bias, RID, float)
+ FUNC1RC(float, gi_probe_get_normal_bias, RID)
+
FUNC2(gi_probe_set_propagation, RID, float)
FUNC1RC(float, gi_probe_get_propagation, RID)
@@ -340,6 +344,8 @@ public:
FUNC0R(RID, viewport_create)
+ FUNC2(viewport_set_use_arvr, RID, bool)
+
FUNC3(viewport_set_size, RID, int, int)
FUNC2(viewport_set_active, RID, bool)
@@ -469,6 +475,7 @@ public:
FUNC2(canvas_item_set_draw_behind_parent, RID, bool)
FUNC6(canvas_item_add_line, RID, const Point2 &, const Point2 &, const Color &, float, bool)
+ FUNC5(canvas_item_add_polyline, RID, const Vector<Point2> &, const Vector<Color> &, float, bool)
FUNC3(canvas_item_add_rect, RID, const Rect2 &, const Color &)
FUNC4(canvas_item_add_circle, RID, const Point2 &, float, const Color &)
FUNC7(canvas_item_add_texture_rect, RID, const Rect2 &, RID, bool, const Color &, bool, RID)
diff --git a/servers/visual_server.cpp b/servers/visual_server.cpp
index eb0848ff50..307f4107eb 100644
--- a/servers/visual_server.cpp
+++ b/servers/visual_server.cpp
@@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "visual_server.h"
-#include "global_config.h"
#include "method_bind_ext.gen.inc"
+#include "project_settings.h"
VisualServer *VisualServer::singleton = NULL;
VisualServer *(*VisualServer::create_func)() = NULL;
@@ -1262,9 +1262,9 @@ Array VisualServer::_get_array_from_surface(uint32_t p_format, PoolVector<uint8_
for (int j = 0; j < p_vertex_len; j++) {
- const uint8_t *v = (const uint8_t *)&r[j * total_elem_size + offsets[i]];
+ const int8_t *v = (const int8_t *)&r[j * total_elem_size + offsets[i]];
for (int k = 0; k < 4; k++) {
- w[j * 4 + k] = float(v[k] / 255.0) * 2.0 - 1.0;
+ w[j * 4 + k] = float(v[k] / 127.0);
}
}
} else {
@@ -1475,14 +1475,14 @@ Array VisualServer::mesh_surface_get_arrays(RID p_mesh, int p_surface) const {
void VisualServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("texture_create"), &VisualServer::texture_create);
- ClassDB::bind_method(D_METHOD("texture_create_from_image"), &VisualServer::texture_create_from_image, DEFVAL(TEXTURE_FLAGS_DEFAULT));
+ ClassDB::bind_method(D_METHOD("texture_create_from_image", "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_set_flags"), &VisualServer::texture_set_flags);
- ClassDB::bind_method(D_METHOD("texture_get_flags"), &VisualServer::texture_get_flags);
- ClassDB::bind_method(D_METHOD("texture_get_width"), &VisualServer::texture_get_width);
- ClassDB::bind_method(D_METHOD("texture_get_height"), &VisualServer::texture_get_height);
+ ClassDB::bind_method(D_METHOD("texture_set_flags", "texture"), &VisualServer::texture_set_flags);
+ ClassDB::bind_method(D_METHOD("texture_get_flags", "texture", "flags"), &VisualServer::texture_get_flags);
+ 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_shrink_all_x2_on_set_data", "shrink"), &VisualServer::texture_set_shrink_all_x2_on_set_data);
}
@@ -1567,10 +1567,39 @@ VisualServer::VisualServer() {
//ERR_FAIL_COND(singleton);
singleton = this;
- GLOBAL_DEF("rendering/vram_formats/use_s3tc", true);
- GLOBAL_DEF("rendering/vram_formats/use_etc", false);
- GLOBAL_DEF("rendering/vram_formats/use_etc2", true);
- GLOBAL_DEF("rendering/vram_formats/use_pvrtc", false);
+ GLOBAL_DEF("rendering/vram_compression/import_s3tc", true);
+ GLOBAL_DEF("rendering/vram_compression/import_etc", false);
+ GLOBAL_DEF("rendering/vram_compression/import_etc2", true);
+ GLOBAL_DEF("rendering/vram_compression/import_pvrtc", false);
+
+ GLOBAL_DEF("rendering/quality/directional_shadow/size", 4096);
+ GLOBAL_DEF("rendering/quality/directional_shadow/size.mobile", 2048);
+ GLOBAL_DEF("rendering/quality/shadow_atlas/size", 4096);
+ GLOBAL_DEF("rendering/quality/shadow_atlas/size.mobile", 2048);
+ ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/shadow_atlas/size", PropertyInfo(Variant::INT, "rendering/quality/shadow_atlas/size", PROPERTY_HINT_RANGE, "256,16384"));
+ GLOBAL_DEF("rendering/quality/shadow_atlas/quadrant_0_subdiv", 1);
+ GLOBAL_DEF("rendering/quality/shadow_atlas/quadrant_1_subdiv", 2);
+ GLOBAL_DEF("rendering/quality/shadow_atlas/quadrant_2_subdiv", 3);
+ GLOBAL_DEF("rendering/quality/shadow_atlas/quadrant_3_subdiv", 4);
+ ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/shadow_atlas/quadrant_0_subdiv", PropertyInfo(Variant::INT, "rendering/quality/shadow_atlas/quadrant_0_subdiv", PROPERTY_HINT_ENUM, "Disabled,1 Shadow,4 Shadows,16 Shadows,64 Shadows,256 Shadows,1024 Shadows"));
+ ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/shadow_atlas/quadrant_1_subdiv", PropertyInfo(Variant::INT, "rendering/quality/shadow_atlas/quadrant_1_subdiv", PROPERTY_HINT_ENUM, "Disabled,1 Shadow,4 Shadows,16 Shadows,64 Shadows,256 Shadows,1024 Shadows"));
+ ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/shadow_atlas/quadrant_2_subdiv", PropertyInfo(Variant::INT, "rendering/quality/shadow_atlas/quadrant_2_subdiv", PROPERTY_HINT_ENUM, "Disabled,1 Shadow,4 Shadows,16 Shadows,64 Shadows,256 Shadows,1024 Shadows"));
+ ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/shadow_atlas/quadrant_3_subdiv", PropertyInfo(Variant::INT, "rendering/quality/shadow_atlas/quadrant_3_subdiv", PROPERTY_HINT_ENUM, "Disabled,1 Shadow,4 Shadows,16 Shadows,64 Shadows,256 Shadows,1024 Shadows"));
+
+ GLOBAL_DEF("rendering/quality/shadows/filter_mode", 1);
+ GLOBAL_DEF("rendering/quality/shadows/filter_mode.mobile", 0);
+ ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/shadows/filter_mode", PropertyInfo(Variant::INT, "rendering/quality/shadows/filter_mode", PROPERTY_HINT_ENUM, "Disabled,PCF5,PCF13"));
+
+ GLOBAL_DEF("rendering/quality/reflections/texture_array_reflections", true);
+ GLOBAL_DEF("rendering/quality/reflections/texture_array_reflections.mobile", false);
+ GLOBAL_DEF("rendering/quality/reflections/high_quality_ggx", true);
+ GLOBAL_DEF("rendering/quality/reflections/high_quality_ggx.mobile", false);
+
+ GLOBAL_DEF("rendering/quality/shading/force_vertex_shading", false);
+ GLOBAL_DEF("rendering/quality/shading/force_vertex_shading.mobile", true);
+
+ GLOBAL_DEF("rendering/quality/depth_prepass/enable", true);
+ GLOBAL_DEF("rendering/quality/depth_prepass/disable_for_vendors", "PowerVR,Mali,Adreno");
}
VisualServer::~VisualServer() {
diff --git a/servers/visual_server.h b/servers/visual_server.h
index 4d2a983751..5c9f4202f9 100644
--- a/servers/visual_server.h
+++ b/servers/visual_server.h
@@ -177,6 +177,7 @@ public:
virtual Variant material_get_param(RID p_material, const StringName &p_param) const = 0;
virtual void material_set_line_width(RID p_material, float p_width) = 0;
+ virtual void material_set_next_pass(RID p_material, RID p_next_material) = 0;
/* MESH API */
@@ -462,6 +463,9 @@ public:
virtual void gi_probe_set_bias(RID p_probe, float p_range) = 0;
virtual float gi_probe_get_bias(RID p_probe) const = 0;
+ virtual void gi_probe_set_normal_bias(RID p_probe, float p_range) = 0;
+ virtual float gi_probe_get_normal_bias(RID p_probe) const = 0;
+
virtual void gi_probe_set_propagation(RID p_probe, float p_range) = 0;
virtual float gi_probe_get_propagation(RID p_probe) const = 0;
@@ -528,6 +532,7 @@ public:
virtual RID viewport_create() = 0;
+ virtual void viewport_set_use_arvr(RID p_viewport, bool p_use_arvr) = 0;
virtual void viewport_set_size(RID p_viewport, int p_width, int p_height) = 0;
virtual void viewport_set_active(RID p_viewport, bool p_active) = 0;
virtual void viewport_set_parent_viewport(RID p_viewport, RID p_parent_viewport) = 0;
@@ -657,7 +662,7 @@ public:
GLOW_BLEND_MODE_SOFTLIGHT,
GLOW_BLEND_MODE_REPLACE,
};
- virtual void environment_set_glow(RID p_env, bool p_enable, int p_level_flags, float p_intensity, float p_strength, float p_bloom_treshold, EnvironmentGlowBlendMode p_blend_mode, float p_hdr_bleed_treshold, float p_hdr_bleed_scale, bool p_bicubic_upscale) = 0;
+ virtual void environment_set_glow(RID p_env, bool p_enable, int p_level_flags, float p_intensity, float p_strength, float p_bloom_threshold, EnvironmentGlowBlendMode p_blend_mode, float p_hdr_bleed_threshold, float p_hdr_bleed_scale, bool p_bicubic_upscale) = 0;
enum EnvironmentToneMapper {
ENV_TONE_MAPPER_LINEAR,
@@ -787,6 +792,7 @@ public:
};
virtual void canvas_item_add_line(RID p_item, const Point2 &p_from, const Point2 &p_to, const Color &p_color, float p_width = 1.0, bool p_antialiased = false) = 0;
+ virtual void canvas_item_add_polyline(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, float p_width = 1.0, bool p_antialiased = false) = 0;
virtual void canvas_item_add_rect(RID p_item, const Rect2 &p_rect, const Color &p_color) = 0;
virtual void canvas_item_add_circle(RID p_item, const Point2 &p_pos, float p_radius, const Color &p_color) = 0;
virtual void canvas_item_add_texture_rect(RID p_item, const Rect2 &p_rect, RID p_texture, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, RID p_normal_map = RID()) = 0;
diff --git a/thirdparty/README.md b/thirdparty/README.md
index ef4f83d4ad..4ed17168e8 100644
--- a/thirdparty/README.md
+++ b/thirdparty/README.md
@@ -107,7 +107,7 @@ Files extracted from upstream source:
## libpng
- Upstream: http://libpng.org/pub/png/libpng.html
-- Version: 1.6.28
+- Version: 1.6.31rc01
- License: libpng/zlib
Files extracted from upstream source:
@@ -371,7 +371,7 @@ Files extracted from upstream source:
## zstd
- Upstream: https://github.com/facebook/zstd
-- Version: 1.2.0
+- Version: 1.3.0
- License: BSD-3-Clause
Files extracted from upstream source:
diff --git a/thirdparty/libpng/arm/filter_neon.S b/thirdparty/libpng/arm/filter_neon.S
index 3b061d6bbf..09267c6030 100644
--- a/thirdparty/libpng/arm/filter_neon.S
+++ b/thirdparty/libpng/arm/filter_neon.S
@@ -1,9 +1,9 @@
/* filter_neon.S - NEON optimised filter functions
*
- * Copyright (c) 2014 Glenn Randers-Pehrson
+ * Copyright (c) 2014,2017 Glenn Randers-Pehrson
* Written by Mans Rullgard, 2011.
- * Last changed in libpng 1.6.16 [December 22, 2014]
+ * Last changed in libpng 1.6.31 [(PENDING RELEASE)]
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
@@ -16,7 +16,7 @@
#define PNG_VERSION_INFO_ONLY
#include "../pngpriv.h"
-#if defined(__linux__) && defined(__ELF__)
+#if (defined(__linux__) || defined(__FreeBSD__)) && defined(__ELF__)
.section .note.GNU-stack,"",%progbits /* mark stack as non-executable */
#endif
diff --git a/thirdparty/libpng/png.c b/thirdparty/libpng/png.c
index 2c9fea2123..87fda0b306 100644
--- a/thirdparty/libpng/png.c
+++ b/thirdparty/libpng/png.c
@@ -1,7 +1,7 @@
/* png.c - location for general purpose libpng functions
*
- * Last changed in libpng 1.6.29 [March 16, 2017]
+ * Last changed in libpng 1.6.31 [(PENDING RELEASE)]
* Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -14,7 +14,27 @@
#include "pngpriv.h"
/* Generate a compiler error if there is an old png.h in the search path. */
-typedef png_libpng_version_1_6_29 Your_png_h_is_not_version_1_6_29;
+typedef png_libpng_version_1_6_31rc01 Your_png_h_is_not_version_1_6_31rc01;
+
+#ifdef __GNUC__
+/* The version tests may need to be added to, but the problem warning has
+ * consistently been fixed in GCC versions which obtain wide-spread release.
+ * The problem is that many versions of GCC rearrange comparison expressions in
+ * the optimizer in such a way that the results of the comparison will change
+ * if signed integer overflow occurs. Such comparisons are not permitted in
+ * ANSI C90, however GCC isn't clever enough to work out that that do not occur
+ * below in png_ascii_from_fp and png_muldiv, so it produces a warning with
+ * -Wextra. Unfortunately this is highly dependent on the optimizer and the
+ * machine architecture so the warning comes and goes unpredictably and is
+ * impossible to "fix", even were that a good idea.
+ */
+#if __GNUC__ == 7 && __GNUC_MINOR__ == 1
+#define GCC_STRICT_OVERFLOW 1
+#endif /* GNU 7.1.x */
+#endif /* GNU */
+#ifndef GCC_STRICT_OVERFLOW
+#define GCC_STRICT_OVERFLOW 0
+#endif
/* Tells libpng that we have already handled the first "num_bytes" bytes
* of the PNG file signature. If the PNG data is embedded into another
@@ -595,6 +615,16 @@ png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask,
}
#endif
+#ifdef PNG_eXIf_SUPPORTED
+ /* Free any eXIf entry */
+ if (((mask & PNG_FREE_EXIF) & info_ptr->free_me) != 0)
+ {
+ png_free(png_ptr, info_ptr->exif);
+ info_ptr->exif = NULL;
+ info_ptr->valid &= ~PNG_INFO_eXIf;
+ }
+#endif
+
#ifdef PNG_hIST_SUPPORTED
/* Free any hIST entry */
if (((mask & PNG_FREE_HIST) & info_ptr->free_me) != 0)
@@ -776,14 +806,14 @@ png_get_copyright(png_const_structrp png_ptr)
#else
# ifdef __STDC__
return PNG_STRING_NEWLINE \
- "libpng version 1.6.29 - March 16, 2017" PNG_STRING_NEWLINE \
+ "libpng version 1.6.31rc01 - July 19, 2017" PNG_STRING_NEWLINE \
"Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson" \
PNG_STRING_NEWLINE \
"Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \
"Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \
PNG_STRING_NEWLINE;
# else
- return "libpng version 1.6.29 - March 16, 2017\
+ return "libpng version 1.6.31rc01 - July 19, 2017\
Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson\
Copyright (c) 1996-1997 Andreas Dilger\
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.";
@@ -2832,7 +2862,7 @@ png_pow10(int power)
if (power < 0)
{
if (power < DBL_MIN_10_EXP) return 0;
- recip = 1, power = -power;
+ recip = 1; power = -power;
}
if (power > 0)
@@ -2857,6 +2887,14 @@ png_pow10(int power)
/* Function to format a floating point value in ASCII with a given
* precision.
*/
+#if GCC_STRICT_OVERFLOW
+#pragma GCC diagnostic push
+/* The problem arises below with exp_b10, which can never overflow because it
+ * comes, originally, from frexp and is therefore limited to a range which is
+ * typically +/-710 (log2(DBL_MAX)/log2(DBL_MIN)).
+ */
+#pragma GCC diagnostic warning "-Wstrict-overflow=2"
+#endif /* GCC_STRICT_OVERFLOW */
void /* PRIVATE */
png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size,
double fp, unsigned int precision)
@@ -2910,7 +2948,9 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size,
double test = png_pow10(exp_b10+1);
if (test <= DBL_MAX)
- ++exp_b10, base = test;
+ {
+ ++exp_b10; base = test;
+ }
else
break;
@@ -2924,7 +2964,10 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size,
* test on DBL_MAX above.
*/
fp /= base;
- while (fp >= 1) fp /= 10, ++exp_b10;
+ while (fp >= 1)
+ {
+ fp /= 10; ++exp_b10;
+ }
/* Because of the code above fp may, at this point, be
* less than .1, this is ok because the code below can
@@ -2941,7 +2984,7 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size,
*/
if (exp_b10 < 0 && exp_b10 > -3) /* PLUS 3 TOTAL 4 */
{
- czero = (unsigned int)(-exp_b10); /* PLUS 2 digits: TOTAL 3 */
+ czero = 0U-exp_b10; /* PLUS 2 digits: TOTAL 3 */
exp_b10 = 0; /* Dot added below before first output. */
}
else
@@ -2975,7 +3018,7 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size,
/* Rounding up to 10, handle that here. */
if (czero > 0)
{
- --czero, d = 1;
+ --czero; d = 1;
if (cdigits == 0) --clead;
}
else
@@ -2989,7 +3032,7 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size,
else if (ch == 46)
{
- ch = *--ascii, ++size;
+ ch = *--ascii; ++size;
/* Advance exp_b10 to '1', so that the
* decimal point happens after the
* previous digit.
@@ -3016,7 +3059,9 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size,
int ch = *--ascii;
if (ch == 46)
- ++size, exp_b10 = 1;
+ {
+ ++size; exp_b10 = 1;
+ }
/* Else lost a leading zero, so 'exp_b10' is
* still ok at (-1)
@@ -3052,21 +3097,26 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size,
*/
if (exp_b10 != (-1))
{
- if (exp_b10 == 0) *ascii++ = 46, --size;
+ if (exp_b10 == 0)
+ {
+ *ascii++ = 46; --size;
+ }
/* PLUS 1: TOTAL 4 */
--exp_b10;
}
- *ascii++ = 48, --czero;
+ *ascii++ = 48; --czero;
}
if (exp_b10 != (-1))
{
if (exp_b10 == 0)
- *ascii++ = 46, --size; /* counted above */
+ {
+ *ascii++ = 46; --size; /* counted above */
+ }
--exp_b10;
}
- *ascii++ = (char)(48 + (int)d), ++cdigits;
+ *ascii++ = (char)(48 + (int)d); ++cdigits;
}
}
while (cdigits+czero < precision+clead && fp > DBL_MIN);
@@ -3075,7 +3125,7 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size,
/* Check for an exponent, if we don't need one we are
* done and just need to terminate the string. At
- * this point exp_b10==(-1) is effectively if flag - it got
+ * this point exp_b10==(-1) is effectively a flag - it got
* to '-1' because of the decrement after outputting
* the decimal point above (the exponent required is
* *not* -1!)
@@ -3089,7 +3139,7 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size,
* zeros were *not* output, so this doesn't increase
* the output count.
*/
- while (--exp_b10 >= 0) *ascii++ = 48;
+ while (exp_b10-- > 0) *ascii++ = 48;
*ascii = 0;
@@ -3107,7 +3157,7 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size,
*/
size -= cdigits;
- *ascii++ = 69, --size; /* 'E': PLUS 1 TOTAL 2+precision */
+ *ascii++ = 69; --size; /* 'E': PLUS 1 TOTAL 2+precision */
/* The following use of an unsigned temporary avoids ambiguities in
* the signed arithmetic on exp_b10 and permits GCC at least to do
@@ -3118,12 +3168,12 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size,
if (exp_b10 < 0)
{
- *ascii++ = 45, --size; /* '-': PLUS 1 TOTAL 3+precision */
- uexp_b10 = (unsigned int)(-exp_b10);
+ *ascii++ = 45; --size; /* '-': PLUS 1 TOTAL 3+precision */
+ uexp_b10 = 0U-exp_b10;
}
else
- uexp_b10 = (unsigned int)exp_b10;
+ uexp_b10 = 0U+exp_b10;
cdigits = 0;
@@ -3166,6 +3216,9 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size,
/* Here on buffer too small. */
png_error(png_ptr, "ASCII conversion buffer too small");
}
+#if GCC_STRICT_OVERFLOW
+#pragma GCC diagnostic pop
+#endif /* GCC_STRICT_OVERFLOW */
# endif /* FLOATING_POINT */
@@ -3185,7 +3238,9 @@ png_ascii_from_fixed(png_const_structrp png_ptr, png_charp ascii,
/* Avoid overflow here on the minimum integer. */
if (fp < 0)
- *ascii++ = 45, num = (png_uint_32)(-fp);
+ {
+ *ascii++ = 45; num = (png_uint_32)(-fp);
+ }
else
num = (png_uint_32)fp;
@@ -3223,7 +3278,10 @@ png_ascii_from_fixed(png_const_structrp png_ptr, png_charp ascii,
* then ndigits digits to first:
*/
i = 5;
- while (ndigits < i) *ascii++ = 48, --i;
+ while (ndigits < i)
+ {
+ *ascii++ = 48; --i;
+ }
while (ndigits >= first) *ascii++ = digits[--ndigits];
/* Don't output the trailing zeros! */
}
@@ -3274,6 +3332,15 @@ png_fixed(png_const_structrp png_ptr, double fp, png_const_charp text)
* the nearest .00001). Overflow and divide by zero are signalled in
* the result, a boolean - true on success, false on overflow.
*/
+#if GCC_STRICT_OVERFLOW /* from above */
+/* It is not obvious which comparison below gets optimized in such a way that
+ * signed overflow would change the result; looking through the code does not
+ * reveal any tests which have the form GCC complains about, so presumably the
+ * optimizer is moving an add or subtract into the 'if' somewhere.
+ */
+#pragma GCC diagnostic push
+#pragma GCC diagnostic warning "-Wstrict-overflow=2"
+#endif /* GCC_STRICT_OVERFLOW */
int
png_muldiv(png_fixed_point_p res, png_fixed_point a, png_int_32 times,
png_int_32 divisor)
@@ -3388,6 +3455,9 @@ png_muldiv(png_fixed_point_p res, png_fixed_point a, png_int_32 times,
return 0;
}
+#if GCC_STRICT_OVERFLOW
+#pragma GCC diagnostic pop
+#endif /* GCC_STRICT_OVERFLOW */
#endif /* READ_GAMMA || INCH_CONVERSIONS */
#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_INCH_CONVERSIONS_SUPPORTED)
@@ -4278,7 +4348,7 @@ png_set_option(png_structrp png_ptr, int option, int onoff)
defined(PNG_SIMPLIFIED_WRITE_SUPPORTED)
/* sRGB conversion tables; these are machine generated with the code in
* contrib/tools/makesRGB.c. The actual sRGB transfer curve defined in the
- * specification (see the article at http://en.wikipedia.org/wiki/SRGB)
+ * specification (see the article at https://en.wikipedia.org/wiki/SRGB)
* is used, not the gamma=1/2.2 approximation use elsewhere in libpng.
* The sRGB to linear table is exact (to the nearest 16-bit linear fraction).
* The inverse (linear to sRGB) table has accuracies as follows:
diff --git a/thirdparty/libpng/png.h b/thirdparty/libpng/png.h
index 2431e0dfc0..80ecc82c3a 100644
--- a/thirdparty/libpng/png.h
+++ b/thirdparty/libpng/png.h
@@ -1,7 +1,7 @@
/* png.h - header file for PNG reference library
*
- * libpng version 1.6.29, March 16, 2017
+ * libpng version 1.6.31rc01, July 19, 2017
*
* Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@@ -12,7 +12,7 @@
* Authors and maintainers:
* libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
* libpng versions 0.89, June 1996, through 0.96, May 1997: Andreas Dilger
- * libpng versions 0.97, January 1998, through 1.6.29, March 16, 2017:
+ * libpng versions 0.97, January 1998, through 1.6.31rc01, July 19, 2017:
* Glenn Randers-Pehrson.
* See also "Contributing Authors", below.
*/
@@ -25,7 +25,7 @@
*
* This code is released under the libpng license.
*
- * libpng versions 1.0.7, July 1, 2000 through 1.6.29, March 16, 2017 are
+ * libpng versions 1.0.7, July 1, 2000 through 1.6.31rc01, July 19, 2017 are
* Copyright (c) 2000-2002, 2004, 2006-2017 Glenn Randers-Pehrson, are
* derived from libpng-1.0.6, and are distributed according to the same
* disclaimer and license as libpng-1.0.6 with the following individuals
@@ -213,7 +213,7 @@
* ...
* 1.5.28 15 10527 15.so.15.28[.0]
* ...
- * 1.6.29 16 10629 16.so.16.29[.0]
+ * 1.6.31 16 10631 16.so.16.31[.0]
*
* Henceforth the source version will match the shared-library major
* and minor numbers; the shared-library major version number will be
@@ -234,20 +234,20 @@
*
* See libpng.txt or libpng.3 for more information. The PNG specification
* is available as a W3C Recommendation and as an ISO Specification,
- * <http://www.w3.org/TR/2003/REC-PNG-20031110/
+ * <https://www.w3.org/TR/2003/REC-PNG-20031110/
*/
/*
* Y2K compliance in libpng:
* =========================
*
- * March 16, 2017
+ * July 19, 2017
*
* Since the PNG Development group is an ad-hoc body, we can't make
* an official declaration.
*
* This is your unofficial assurance that libpng from version 0.71 and
- * upward through 1.6.29 are Y2K compliant. It is my belief that
+ * upward through 1.6.31rc01 are Y2K compliant. It is my belief that
* earlier versions were also Y2K compliant.
*
* Libpng only has two year fields. One is a 2-byte unsigned integer
@@ -309,8 +309,8 @@
*/
/* Version information for png.h - this should match the version in png.c */
-#define PNG_LIBPNG_VER_STRING "1.6.29"
-#define PNG_HEADER_VERSION_STRING " libpng version 1.6.29 - March 16, 2017\n"
+#define PNG_LIBPNG_VER_STRING "1.6.31rc01"
+#define PNG_HEADER_VERSION_STRING " libpng version 1.6.31rc01 - July 19, 2017\n"
#define PNG_LIBPNG_VER_SONUM 16
#define PNG_LIBPNG_VER_DLLNUM 16
@@ -318,13 +318,13 @@
/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
#define PNG_LIBPNG_VER_MAJOR 1
#define PNG_LIBPNG_VER_MINOR 6
-#define PNG_LIBPNG_VER_RELEASE 29
+#define PNG_LIBPNG_VER_RELEASE 31
/* This should match the numeric part of the final component of
* PNG_LIBPNG_VER_STRING, omitting any leading zero:
*/
-#define PNG_LIBPNG_VER_BUILD 0
+#define PNG_LIBPNG_VER_BUILD 01
/* Release Status */
#define PNG_LIBPNG_BUILD_ALPHA 1
@@ -341,7 +341,7 @@
#define PNG_LIBPNG_BUILD_SPECIAL 32 /* Cannot be OR'ed with
PNG_LIBPNG_BUILD_PRIVATE */
-#define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_STABLE
+#define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_RC
/* Careful here. At one time, Guy wanted to use 082, but that would be octal.
* We must not include leading zeros.
@@ -349,7 +349,7 @@
* version 1.0.0 was mis-numbered 100 instead of 10000). From
* version 1.0.1 it's xxyyzz, where x=major, y=minor, z=release
*/
-#define PNG_LIBPNG_VER 10629 /* 1.6.29 */
+#define PNG_LIBPNG_VER 10631 /* 1.6.31 */
/* Library configuration: these options cannot be changed after
* the library has been built.
@@ -459,7 +459,7 @@ extern "C" {
/* This triggers a compiler error in png.c, if png.c and png.h
* do not agree upon the version number.
*/
-typedef char* png_libpng_version_1_6_29;
+typedef char* png_libpng_version_1_6_31rc01;
/* Basic control structions. Read libpng-manual.txt or libpng.3 for more info.
*
@@ -776,6 +776,7 @@ typedef png_unknown_chunk * * png_unknown_chunkpp;
#define PNG_INFO_sPLT 0x2000U /* ESR, 1.0.6 */
#define PNG_INFO_sCAL 0x4000U /* ESR, 1.0.6 */
#define PNG_INFO_IDAT 0x8000U /* ESR, 1.0.6 */
+#define PNG_INFO_eXIf 0x10000U /* GR-P, 1.6.31 */
/* This is used for the transformation routines, as some of them
* change these values for the row. It also should enable using
@@ -1788,7 +1789,8 @@ PNG_EXPORT(99, void, png_data_freer, (png_const_structrp png_ptr,
#define PNG_FREE_PLTE 0x1000U
#define PNG_FREE_TRNS 0x2000U
#define PNG_FREE_TEXT 0x4000U
-#define PNG_FREE_ALL 0x7fffU
+#define PNG_FREE_EXIF 0x8000U /* Added at libpng-1.6.31 */
+#define PNG_FREE_ALL 0xffffU
#define PNG_FREE_MUL 0x4220U /* PNG_FREE_SPLT|PNG_FREE_TEXT|PNG_FREE_UNKN */
#ifdef PNG_USER_MEM_SUPPORTED
@@ -2007,6 +2009,13 @@ PNG_FIXED_EXPORT(233, void, png_set_cHRM_XYZ_fixed, (png_const_structrp png_ptr,
png_fixed_point int_blue_Z))
#endif
+#ifdef PNG_eXIf_SUPPORTED
+PNG_EXPORT(246, png_uint_32, png_get_eXIf, (png_const_structrp png_ptr,
+ png_inforp info_ptr, png_bytep *exif));
+PNG_EXPORT(247, void, png_set_eXIf, (png_const_structrp png_ptr,
+ png_inforp info_ptr, const png_bytep exif));
+#endif
+
#ifdef PNG_gAMA_SUPPORTED
PNG_FP_EXPORT(137, png_uint_32, png_get_gAMA, (png_const_structrp png_ptr,
png_const_inforp info_ptr, double *file_gamma))
@@ -2025,9 +2034,6 @@ PNG_FIXED_EXPORT(140, void, png_set_gAMA_fixed, (png_const_structrp png_ptr,
#ifdef PNG_hIST_SUPPORTED
PNG_EXPORT(141, png_uint_32, png_get_hIST, (png_const_structrp png_ptr,
png_inforp info_ptr, png_uint_16p *hist));
-#endif
-
-#ifdef PNG_hIST_SUPPORTED
PNG_EXPORT(142, void, png_set_hIST, (png_const_structrp png_ptr,
png_inforp info_ptr, png_const_uint_16p hist));
#endif
@@ -2753,7 +2759,7 @@ typedef struct
*
* When the simplified API needs to convert between sRGB and linear colorspaces,
* the actual sRGB transfer curve defined in the sRGB specification (see the
- * article at http://en.wikipedia.org/wiki/SRGB) is used, not the gamma=1/2.2
+ * article at https://en.wikipedia.org/wiki/SRGB) is used, not the gamma=1/2.2
* approximation used elsewhere in libpng.
*
* When an alpha channel is present it is expected to denote pixel coverage
@@ -3253,7 +3259,7 @@ PNG_EXPORT(244, int, png_set_option, (png_structrp png_ptr, int option,
* one to use is one more than this.)
*/
#ifdef PNG_EXPORT_LAST_ORDINAL
- PNG_EXPORT_LAST_ORDINAL(245);
+ PNG_EXPORT_LAST_ORDINAL(247);
#endif
#ifdef __cplusplus
diff --git a/thirdparty/libpng/pngconf.h b/thirdparty/libpng/pngconf.h
index 78d8b92b0e..9308d6a60a 100644
--- a/thirdparty/libpng/pngconf.h
+++ b/thirdparty/libpng/pngconf.h
@@ -1,7 +1,7 @@
/* pngconf.h - machine configurable file for libpng
*
- * libpng version 1.6.29, March 16, 2017
+ * libpng version 1.6.31rc01, July 19, 2017
*
* Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
diff --git a/thirdparty/libpng/pngerror.c b/thirdparty/libpng/pngerror.c
index 00d76f7c05..37f26c6558 100644
--- a/thirdparty/libpng/pngerror.c
+++ b/thirdparty/libpng/pngerror.c
@@ -1,8 +1,8 @@
/* pngerror.c - stub functions for i/o and memory allocation
*
- * Last changed in libpng 1.6.26 [October 20, 2016]
- * Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
+ * Last changed in libpng 1.6.31 [(PENDING RELEASE)]
+ * Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*
@@ -163,7 +163,7 @@ png_format_number(png_const_charp start, png_charp end, int format,
case PNG_NUMBER_FORMAT_02u:
/* Expects at least 2 digits. */
mincount = 2;
- /* FALL THROUGH */
+ /* FALLTHROUGH */
case PNG_NUMBER_FORMAT_u:
*--end = digits[number % 10];
@@ -173,7 +173,7 @@ png_format_number(png_const_charp start, png_charp end, int format,
case PNG_NUMBER_FORMAT_02x:
/* This format expects at least two digits */
mincount = 2;
- /* FALL THROUGH */
+ /* FALLTHROUGH */
case PNG_NUMBER_FORMAT_x:
*--end = digits[number & 0xf];
diff --git a/thirdparty/libpng/pngget.c b/thirdparty/libpng/pngget.c
index 141c393330..ace9e6351f 100644
--- a/thirdparty/libpng/pngget.c
+++ b/thirdparty/libpng/pngget.c
@@ -773,6 +773,24 @@ png_get_sPLT(png_const_structrp png_ptr, png_inforp info_ptr,
}
#endif
+#ifdef PNG_eXIf_SUPPORTED
+png_uint_32 PNGAPI
+png_get_eXIf(png_const_structrp png_ptr, png_inforp info_ptr,
+ png_bytep *exif)
+{
+ png_debug1(1, "in %s retrieval function", "eXIf");
+
+ if (png_ptr != NULL && info_ptr != NULL &&
+ (info_ptr->valid & PNG_INFO_eXIf) != 0 && exif != NULL)
+ {
+ *exif = info_ptr->exif;
+ return (PNG_INFO_eXIf);
+ }
+
+ return (0);
+}
+#endif
+
#ifdef PNG_hIST_SUPPORTED
png_uint_32 PNGAPI
png_get_hIST(png_const_structrp png_ptr, png_inforp info_ptr,
diff --git a/thirdparty/libpng/pnginfo.h b/thirdparty/libpng/pnginfo.h
index 361ed8be70..6e6d46a62b 100644
--- a/thirdparty/libpng/pnginfo.h
+++ b/thirdparty/libpng/pnginfo.h
@@ -185,6 +185,11 @@ defined(PNG_READ_BACKGROUND_SUPPORTED)
png_byte phys_unit_type; /* resolution type (see PNG_RESOLUTION_ below) */
#endif
+#ifdef PNG_eXIf_SUPPORTED
+ int num_exif;
+ png_bytep exif;
+#endif
+
#ifdef PNG_hIST_SUPPORTED
/* The hIST chunk contains the relative frequency or importance of the
* various palette entries, so that a viewer can intelligently select a
diff --git a/thirdparty/libpng/pnglibconf.h b/thirdparty/libpng/pnglibconf.h
index 82f6ba4619..8738ebdfc2 100644
--- a/thirdparty/libpng/pnglibconf.h
+++ b/thirdparty/libpng/pnglibconf.h
@@ -1,10 +1,10 @@
-/* libpng 1.6.29 STANDARD API DEFINITION */
+/* libpng 1.6.31rc01 STANDARD API DEFINITION */
/* pnglibconf.h - library build configuration */
-/* Libpng version 1.6.29 - March 16, 2017 */
+/* Libpng version 1.6.31rc01 - July 19, 2017 */
-/* Copyright (c) 1998-2015 Glenn Randers-Pehrson */
+/* Copyright (c) 1998-2017 Glenn Randers-Pehrson */
/* This code is released under the libpng license. */
/* For conditions of distribution and use, see the disclaimer */
@@ -84,6 +84,7 @@
#define PNG_READ_USER_TRANSFORM_SUPPORTED
#define PNG_READ_bKGD_SUPPORTED
#define PNG_READ_cHRM_SUPPORTED
+#define PNG_READ_eXIf_SUPPORTED
#define PNG_READ_gAMA_SUPPORTED
#define PNG_READ_hIST_SUPPORTED
#define PNG_READ_iCCP_SUPPORTED
@@ -153,6 +154,7 @@
#define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
#define PNG_WRITE_bKGD_SUPPORTED
#define PNG_WRITE_cHRM_SUPPORTED
+#define PNG_WRITE_eXIf_SUPPORTED
#define PNG_WRITE_gAMA_SUPPORTED
#define PNG_WRITE_hIST_SUPPORTED
#define PNG_WRITE_iCCP_SUPPORTED
@@ -170,6 +172,7 @@
#define PNG_WRITE_zTXt_SUPPORTED
#define PNG_bKGD_SUPPORTED
#define PNG_cHRM_SUPPORTED
+#define PNG_eXIf_SUPPORTED
#define PNG_gAMA_SUPPORTED
#define PNG_hIST_SUPPORTED
#define PNG_iCCP_SUPPORTED
diff --git a/thirdparty/libpng/pngpriv.h b/thirdparty/libpng/pngpriv.h
index 6d2e424d2e..7c273bd5e3 100644
--- a/thirdparty/libpng/pngpriv.h
+++ b/thirdparty/libpng/pngpriv.h
@@ -1,7 +1,7 @@
/* pngpriv.h - private declarations for use inside libpng
*
- * Last changed in libpng 1.6.29 [March 16, 2017]
+ * Last changed in libpng 1.6.31 [(PENDING RELEASE)]
* Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -35,7 +35,9 @@
* Windows/Visual Studio) there is no effect; the OS specific tests below are
* still required (as of 2011-05-02.)
*/
-#define _POSIX_SOURCE 1 /* Just the POSIX 1003.1 and C89 APIs */
+#ifndef _POSIX_SOURCE
+# define _POSIX_SOURCE 1 /* Just the POSIX 1003.1 and C89 APIs */
+#endif
#ifndef PNG_VERSION_INFO_ONLY
/* Standard library headers not required by png.h: */
@@ -452,6 +454,21 @@
# define png_fixed_error(s1,s2) png_err(s1)
#endif
+/* Some fixed point APIs are still required even if not exported because
+ * they get used by the corresponding floating point APIs. This magic
+ * deals with this:
+ */
+#ifdef PNG_FIXED_POINT_SUPPORTED
+# define PNGFAPI PNGAPI
+#else
+# define PNGFAPI /* PRIVATE */
+#endif
+
+#ifndef PNG_VERSION_INFO_ONLY
+/* Other defines specific to compilers can go here. Try to keep
+ * them inside an appropriate ifdef/endif pair for portability.
+ */
+
/* C allows up-casts from (void*) to any pointer and (const void*) to any
* pointer to a const object. C++ regards this as a type error and requires an
* explicit, static, cast and provides the static_cast<> rune to ensure that
@@ -466,25 +483,20 @@
static_cast<type>(static_cast<const void*>(value))
#else
# define png_voidcast(type, value) (value)
-# define png_constcast(type, value) ((type)(value))
+# ifdef _WIN64
+# ifdef __GNUC__
+ typedef unsigned long long png_ptruint;
+# else
+ typedef unsigned __int64 png_ptruint;
+# endif
+# else
+ typedef unsigned long png_ptruint;
+# endif
+# define png_constcast(type, value) ((type)(png_ptruint)(const void*)(value))
# define png_aligncast(type, value) ((void*)(value))
# define png_aligncastconst(type, value) ((const void*)(value))
#endif /* __cplusplus */
-/* Some fixed point APIs are still required even if not exported because
- * they get used by the corresponding floating point APIs. This magic
- * deals with this:
- */
-#ifdef PNG_FIXED_POINT_SUPPORTED
-# define PNGFAPI PNGAPI
-#else
-# define PNGFAPI /* PRIVATE */
-#endif
-
-#ifndef PNG_VERSION_INFO_ONLY
-/* Other defines specific to compilers can go here. Try to keep
- * them inside an appropriate ifdef/endif pair for portability.
- */
#if defined(PNG_FLOATING_POINT_SUPPORTED) ||\
defined(PNG_FLOATING_ARITHMETIC_SUPPORTED)
/* png.c requires the following ANSI-C constants if the conversion of
@@ -830,6 +842,7 @@
#define png_PLTE PNG_U32( 80, 76, 84, 69)
#define png_bKGD PNG_U32( 98, 75, 71, 68)
#define png_cHRM PNG_U32( 99, 72, 82, 77)
+#define png_eXIf PNG_U32(101, 88, 73, 102) /* registered July 2017 */
#define png_fRAc PNG_U32(102, 82, 65, 99) /* registered, not defined */
#define png_gAMA PNG_U32(103, 65, 77, 65)
#define png_gIFg PNG_U32(103, 73, 70, 103)
@@ -1429,6 +1442,11 @@ PNG_INTERNAL_FUNCTION(void,png_handle_cHRM,(png_structrp png_ptr,
png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
#endif
+#ifdef PNG_READ_eXIf_SUPPORTED
+PNG_INTERNAL_FUNCTION(void,png_handle_eXIf,(png_structrp png_ptr,
+ png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
+#endif
+
#ifdef PNG_READ_gAMA_SUPPORTED
PNG_INTERNAL_FUNCTION(void,png_handle_gAMA,(png_structrp png_ptr,
png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
diff --git a/thirdparty/libpng/pngread.c b/thirdparty/libpng/pngread.c
index 106a80588c..b44d4dfbb5 100644
--- a/thirdparty/libpng/pngread.c
+++ b/thirdparty/libpng/pngread.c
@@ -1,8 +1,8 @@
/* pngread.c - read a PNG file
*
- * Last changed in libpng 1.6.26 [October 20, 2016]
- * Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
+ * Last changed in libpng 1.6.31 [(PENDING RELEASE)]
+ * Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*
@@ -1883,7 +1883,7 @@ png_create_colormap_entry(png_image_read_control *display,
{
case 4:
entry[afirst ? 0 : 3] = (png_uint_16)alpha;
- /* FALL THROUGH */
+ /* FALLTHROUGH */
case 3:
if (alpha < 65535)
@@ -1905,7 +1905,7 @@ png_create_colormap_entry(png_image_read_control *display,
case 2:
entry[1 ^ afirst] = (png_uint_16)alpha;
- /* FALL THROUGH */
+ /* FALLTHROUGH */
case 1:
if (alpha < 65535)
@@ -1934,6 +1934,7 @@ png_create_colormap_entry(png_image_read_control *display,
{
case 4:
entry[afirst ? 0 : 3] = (png_byte)alpha;
+ /* FALLTHROUGH */
case 3:
entry[afirst + (2 ^ bgr)] = (png_byte)blue;
entry[afirst + 1] = (png_byte)green;
@@ -1942,6 +1943,7 @@ png_create_colormap_entry(png_image_read_control *display,
case 2:
entry[1 ^ afirst] = (png_byte)alpha;
+ /* FALLTHROUGH */
case 1:
entry[afirst] = (png_byte)green;
break;
@@ -2861,7 +2863,7 @@ png_image_read_colormap(png_voidp argument)
case P_sRGB:
/* Change to 8-bit sRGB */
png_set_alpha_mode_fixed(png_ptr, PNG_ALPHA_PNG, PNG_GAMMA_sRGB);
- /* FALL THROUGH */
+ /* FALLTHROUGH */
case P_FILE:
if (png_ptr->bit_depth > 8)
@@ -3179,8 +3181,7 @@ png_image_read_colormapped(png_voidp argument)
image->colormap_entries == 244 /* 216 + 1 + 27 */)
break;
- /* goto bad_output; */
- /* FALL THROUGH */
+ goto bad_output;
default:
bad_output:
diff --git a/thirdparty/libpng/pngrtran.c b/thirdparty/libpng/pngrtran.c
index 16c1ed6086..9285983848 100644
--- a/thirdparty/libpng/pngrtran.c
+++ b/thirdparty/libpng/pngrtran.c
@@ -1,7 +1,7 @@
/* pngrtran.c - transforms the data in a row for PNG readers
*
- * Last changed in libpng 1.6.29 [March 16, 2017]
+ * Last changed in libpng 1.6.31 [(PENDING RELEASE)]
* Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -49,6 +49,7 @@ png_set_crc_action(png_structrp png_ptr, int crit_action, int ancil_action)
case PNG_CRC_WARN_DISCARD: /* Not a valid action for critical data */
png_warning(png_ptr,
"Can't discard critical data on CRC error");
+ /* FALLTHROUGH */
case PNG_CRC_ERROR_QUIT: /* Error/quit */
case PNG_CRC_DEFAULT:
@@ -1253,7 +1254,7 @@ png_init_rgb_transformations(png_structrp png_ptr)
default:
case 8:
- /* FALL THROUGH (Already 8 bits) */
+ /* FALLTHROUGH */ /* (Already 8 bits) */
case 16:
/* Already a full 16 bits */
@@ -2934,7 +2935,7 @@ png_do_gray_to_rgb(png_row_infop row_info, png_bytep row)
* using the equation given in Poynton's ColorFAQ of 1998-01-04 at
* <http://www.inforamp.net/~poynton/> (THIS LINK IS DEAD June 2008 but
* versions dated 1998 through November 2002 have been archived at
- * http://web.archive.org/web/20000816232553/http://www.inforamp.net/
+ * https://web.archive.org/web/20000816232553/www.inforamp.net/
* ~poynton/notes/colour_and_gamma/ColorFAQ.txt )
* Charles Poynton poynton at poynton.com
*
@@ -4601,7 +4602,9 @@ png_do_expand_16(png_row_infop row_info, png_bytep row)
png_byte *sp = row + row_info->rowbytes; /* source, last byte + 1 */
png_byte *dp = sp + row_info->rowbytes; /* destination, end + 1 */
while (dp > sp)
- dp[-2] = dp[-1] = *--sp, dp -= 2;
+ {
+ dp[-2] = dp[-1] = *--sp; dp -= 2;
+ }
row_info->rowbytes *= 2;
row_info->bit_depth = 16;
diff --git a/thirdparty/libpng/pngrutil.c b/thirdparty/libpng/pngrutil.c
index 76f079a69f..9cde64845c 100644
--- a/thirdparty/libpng/pngrutil.c
+++ b/thirdparty/libpng/pngrutil.c
@@ -1,7 +1,7 @@
/* pngrutil.c - utilities to read a PNG file
*
- * Last changed in libpng 1.6.29 [March 16, 2017]
+ * Last changed in libpng 1.6.31 [(PENDING RELEASE)]
* Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -2009,6 +2009,44 @@ png_handle_bKGD(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
}
#endif
+#ifdef PNG_READ_eXIf_SUPPORTED
+void /* PRIVATE */
+png_handle_eXIf(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
+{
+ unsigned int i;
+ png_bytep eXIf_buf;
+
+ png_debug(1, "in png_handle_eXIf");
+
+ if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
+ png_chunk_error(png_ptr, "missing IHDR");
+
+ else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_eXIf) != 0)
+ {
+ png_crc_finish(png_ptr, length);
+ png_chunk_benign_error(png_ptr, "duplicate");
+ return;
+ }
+
+ eXIf_buf = png_voidcast(png_bytep,
+ png_malloc_warn(png_ptr, length));
+
+ for (i = 0; i < length; i++)
+ {
+ png_byte buf[1];
+ png_crc_read(png_ptr, buf, 1);
+ eXIf_buf[i] = buf[0];
+ }
+
+ if (png_crc_finish(png_ptr, 0) != 0)
+ return;
+
+ info_ptr->num_exif = length;
+
+ png_set_eXIf(png_ptr, info_ptr, eXIf_buf);
+}
+#endif
+
#ifdef PNG_READ_hIST_SUPPORTED
void /* PRIVATE */
png_handle_hIST(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
@@ -2537,6 +2575,9 @@ png_handle_zTXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
if ((png_ptr->mode & PNG_HAVE_IDAT) != 0)
png_ptr->mode |= PNG_AFTER_IDAT;
+ /* Note, "length" is sufficient here; we won't be adding
+ * a null terminator later.
+ */
buffer = png_read_buffer(png_ptr, length, 2/*silent*/);
if (buffer == NULL)
@@ -2975,7 +3016,7 @@ png_handle_unknown(png_structrp png_ptr, png_inforp info_ptr,
case 2:
png_ptr->user_chunk_cache_max = 1;
png_chunk_benign_error(png_ptr, "no space in chunk cache");
- /* FALL THROUGH */
+ /* FALLTHROUGH */
case 1:
/* NOTE: prior to 1.6.0 this case resulted in an unknown critical
* chunk being skipped, now there will be a hard error below.
@@ -2984,7 +3025,7 @@ png_handle_unknown(png_structrp png_ptr, png_inforp info_ptr,
default: /* not at limit */
--(png_ptr->user_chunk_cache_max);
- /* FALL THROUGH */
+ /* FALLTHROUGH */
case 0: /* no limit */
# endif /* USER_LIMITS */
/* Here when the limit isn't reached or when limits are compiled
@@ -3377,7 +3418,7 @@ png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display)
*/
do
{
- dp[0] = sp[0], dp[1] = sp[1];
+ dp[0] = sp[0]; dp[1] = sp[1];
if (row_width <= bytes_to_jump)
return;
@@ -3398,7 +3439,7 @@ png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display)
*/
for (;;)
{
- dp[0] = sp[0], dp[1] = sp[1], dp[2] = sp[2];
+ dp[0] = sp[0]; dp[1] = sp[1]; dp[2] = sp[2];
if (row_width <= bytes_to_jump)
return;
@@ -3887,7 +3928,10 @@ png_read_filter_row_paeth_1byte_pixel(png_row_infop row_info, png_bytep row,
/* Find the best predictor, the least of pa, pb, pc favoring the earlier
* ones in the case of a tie.
*/
- if (pb < pa) pa = pb, a = b;
+ if (pb < pa)
+ {
+ pa = pb; a = b;
+ }
if (pc < pa) a = c;
/* Calculate the current pixel in a, and move the previous row pixel to c
@@ -3939,7 +3983,10 @@ png_read_filter_row_paeth_multibyte_pixel(png_row_infop row_info, png_bytep row,
pc = (p + pc) < 0 ? -(p + pc) : p + pc;
#endif
- if (pb < pa) pa = pb, a = b;
+ if (pb < pa)
+ {
+ pa = pb; a = b;
+ }
if (pc < pa) a = c;
a += *row;
diff --git a/thirdparty/libpng/pngset.c b/thirdparty/libpng/pngset.c
index 28ff3a064d..998473557f 100644
--- a/thirdparty/libpng/pngset.c
+++ b/thirdparty/libpng/pngset.c
@@ -1,8 +1,8 @@
/* pngset.c - storage of image information into info struct
*
- * Last changed in libpng 1.6.26 [October 20, 2016]
- * Copyright (c) 1998-2016 Glenn Randers-Pehrson
+ * Last changed in libpng 1.6.30 [June 28, 2017]
+ * Copyright (c) 1998-2017 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*
@@ -134,6 +134,39 @@ png_set_cHRM_XYZ(png_const_structrp png_ptr, png_inforp info_ptr, double red_X,
#endif /* cHRM */
+#ifdef PNG_eXIf_SUPPORTED
+void PNGAPI
+png_set_eXIf(png_const_structrp png_ptr, png_inforp info_ptr,
+ const png_bytep eXIf_buf)
+{
+ int i;
+
+ png_debug1(1, "in %s storage function", "eXIf");
+
+ if (png_ptr == NULL || info_ptr == NULL)
+ return;
+
+ png_free_data(png_ptr, info_ptr, PNG_FREE_EXIF, 0);
+
+ info_ptr->exif = png_voidcast(png_bytep, png_malloc_warn(png_ptr,
+ info_ptr->num_exif));
+
+ if (info_ptr->exif == NULL)
+ {
+ png_warning(png_ptr, "Insufficient memory for eXIf chunk data");
+
+ return;
+ }
+
+ info_ptr->free_me |= PNG_FREE_EXIF;
+
+ for (i = 0; i < info_ptr->num_exif; i++)
+ info_ptr->exif[i] = eXIf_buf[i];
+
+ info_ptr->valid |= PNG_INFO_eXIf;
+}
+#endif /* eXIf */
+
#ifdef PNG_gAMA_SUPPORTED
void PNGFAPI
png_set_gAMA_fixed(png_const_structrp png_ptr, png_inforp info_ptr,
@@ -1102,8 +1135,9 @@ png_set_sPLT(png_const_structrp png_ptr,
info_ptr->valid |= PNG_INFO_sPLT;
++(info_ptr->splt_palettes_num);
++np;
+ ++entries;
}
- while (++entries, --nentries);
+ while (--nentries);
if (nentries > 0)
png_chunk_report(png_ptr, "sPLT out of memory", PNG_CHUNK_WRITE_ERROR);
@@ -1696,14 +1730,16 @@ png_check_keyword(png_structrp png_ptr, png_const_charp key, png_bytep new_key)
png_byte ch = (png_byte)*key++;
if ((ch > 32 && ch <= 126) || (ch >= 161 /*&& ch <= 255*/))
- *new_key++ = ch, ++key_len, space = 0;
+ {
+ *new_key++ = ch; ++key_len; space = 0;
+ }
else if (space == 0)
{
/* A space or an invalid character when one wasn't seen immediately
* before; output just a space.
*/
- *new_key++ = 32, ++key_len, space = 1;
+ *new_key++ = 32; ++key_len; space = 1;
/* If the character was not a space then it is invalid. */
if (ch != 32)
@@ -1716,7 +1752,7 @@ png_check_keyword(png_structrp png_ptr, png_const_charp key, png_bytep new_key)
if (key_len > 0 && space != 0) /* trailing space */
{
- --key_len, --new_key;
+ --key_len; --new_key;
if (bad_character == 0)
bad_character = 32;
}
diff --git a/thirdparty/libpng/pngstruct.h b/thirdparty/libpng/pngstruct.h
index 749d7e35b1..44b79dea74 100644
--- a/thirdparty/libpng/pngstruct.h
+++ b/thirdparty/libpng/pngstruct.h
@@ -479,5 +479,8 @@ struct png_struct_def
png_colorspace colorspace;
#endif
#endif
+
+/* New member added in libpng-1.6.31 */
+ int num_exif;
};
#endif /* PNGSTRUCT_H */
diff --git a/thirdparty/libpng/pngtrans.c b/thirdparty/libpng/pngtrans.c
index da7413fb80..326ac33f0e 100644
--- a/thirdparty/libpng/pngtrans.c
+++ b/thirdparty/libpng/pngtrans.c
@@ -1,8 +1,8 @@
/* pngtrans.c - transforms the data in a row (used by both readers and writers)
*
- * Last changed in libpng 1.6.26 [October 20, 2016]
- * Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
+ * Last changed in libpng 1.6.30 [June 28, 2017]
+ * Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*
@@ -514,11 +514,15 @@ png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start)
if (at_start != 0) /* Skip initial filler */
++sp;
else /* Skip initial channel and, for sp, the filler */
- sp += 2, ++dp;
+ {
+ sp += 2; ++dp;
+ }
/* For a 1 pixel wide image there is nothing to do */
while (sp < ep)
- *dp++ = *sp, sp += 2;
+ {
+ *dp++ = *sp; sp += 2;
+ }
row_info->pixel_depth = 8;
}
@@ -528,10 +532,14 @@ png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start)
if (at_start != 0) /* Skip initial filler */
sp += 2;
else /* Skip initial channel and, for sp, the filler */
- sp += 4, dp += 2;
+ {
+ sp += 4; dp += 2;
+ }
while (sp < ep)
- *dp++ = *sp++, *dp++ = *sp, sp += 3;
+ {
+ *dp++ = *sp++; *dp++ = *sp; sp += 3;
+ }
row_info->pixel_depth = 16;
}
@@ -554,11 +562,15 @@ png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start)
if (at_start != 0) /* Skip initial filler */
++sp;
else /* Skip initial channels and, for sp, the filler */
- sp += 4, dp += 3;
+ {
+ sp += 4; dp += 3;
+ }
/* Note that the loop adds 3 to dp and 4 to sp each time. */
while (sp < ep)
- *dp++ = *sp++, *dp++ = *sp++, *dp++ = *sp, sp += 2;
+ {
+ *dp++ = *sp++; *dp++ = *sp++; *dp++ = *sp; sp += 2;
+ }
row_info->pixel_depth = 24;
}
@@ -568,14 +580,16 @@ png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start)
if (at_start != 0) /* Skip initial filler */
sp += 2;
else /* Skip initial channels and, for sp, the filler */
- sp += 8, dp += 6;
+ {
+ sp += 8; dp += 6;
+ }
while (sp < ep)
{
/* Copy 6 bytes, skip 2 */
- *dp++ = *sp++, *dp++ = *sp++;
- *dp++ = *sp++, *dp++ = *sp++;
- *dp++ = *sp++, *dp++ = *sp, sp += 3;
+ *dp++ = *sp++; *dp++ = *sp++;
+ *dp++ = *sp++; *dp++ = *sp++;
+ *dp++ = *sp++; *dp++ = *sp; sp += 3;
}
row_info->pixel_depth = 48;
diff --git a/thirdparty/libpng/pngwrite.c b/thirdparty/libpng/pngwrite.c
index 07088ee75e..8c2952e794 100644
--- a/thirdparty/libpng/pngwrite.c
+++ b/thirdparty/libpng/pngwrite.c
@@ -1,8 +1,8 @@
/* pngwrite.c - general routines to write a PNG file
*
- * Last changed in libpng 1.6.26 [October 20, 2016]
- * Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
+ * Last changed in libpng 1.6.31 [(PENDING RELEASE)]
+ * Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*
@@ -1007,8 +1007,8 @@ png_set_filter(png_structrp png_ptr, int method, int filters)
case 5:
case 6:
case 7: png_app_error(png_ptr, "Unknown row filter for method 0");
- /* FALL THROUGH */
#endif /* WRITE_FILTER */
+ /* FALLTHROUGH */
case PNG_FILTER_VALUE_NONE:
png_ptr->do_filter = PNG_FILTER_NONE; break;
@@ -1875,7 +1875,7 @@ png_image_set_PLTE(png_image_write_control *display)
tRNS[i] = entry[afirst ? 0 : 3];
if (tRNS[i] < 255)
num_trans = i+1;
- /* FALL THROUGH */
+ /* FALLTHROUGH */
case 3:
palette[i].blue = entry[afirst + (2 ^ bgr)];
palette[i].green = entry[afirst + 1];
@@ -1886,7 +1886,7 @@ png_image_set_PLTE(png_image_write_control *display)
tRNS[i] = entry[1 ^ afirst];
if (tRNS[i] < 255)
num_trans = i+1;
- /* FALL THROUGH */
+ /* FALLTHROUGH */
case 1:
palette[i].blue = palette[i].red = palette[i].green =
entry[afirst];
diff --git a/thirdparty/libpng/pngwutil.c b/thirdparty/libpng/pngwutil.c
index 0f98d582da..348bb524dd 100644
--- a/thirdparty/libpng/pngwutil.c
+++ b/thirdparty/libpng/pngwutil.c
@@ -1003,7 +1003,8 @@ png_compress_IDAT(png_structrp png_ptr, png_const_bytep input,
optimize_cmf(data, png_image_size(png_ptr));
#endif
- png_write_complete_chunk(png_ptr, png_IDAT, data, size);
+ if (size > 0)
+ png_write_complete_chunk(png_ptr, png_IDAT, data, size);
png_ptr->mode |= PNG_HAVE_IDAT;
png_ptr->zstream.next_out = data;
@@ -1049,7 +1050,8 @@ png_compress_IDAT(png_structrp png_ptr, png_const_bytep input,
optimize_cmf(data, png_image_size(png_ptr));
#endif
- png_write_complete_chunk(png_ptr, png_IDAT, data, size);
+ if (size > 0)
+ png_write_complete_chunk(png_ptr, png_IDAT, data, size);
png_ptr->zstream.avail_out = 0;
png_ptr->zstream.next_out = NULL;
png_ptr->mode |= PNG_HAVE_IDAT | PNG_AFTER_IDAT;
@@ -1471,6 +1473,37 @@ png_write_bKGD(png_structrp png_ptr, png_const_color_16p back, int color_type)
}
#endif
+#ifdef PNG_WRITE_eXIf_SUPPORTED
+/* Write the Exif data */
+void /* PRIVATE */
+png_write_eXIf(png_structrp png_ptr, png_bytep exif, int num_exif)
+{
+ int i;
+ png_byte buf[3];
+
+ png_debug(1, "in png_write_eXIf");
+
+ if (num_exif > (int)png_ptr->num_exif)
+ {
+ png_debug2(3, "num_exif = %d, png_ptr->num_exif = %d", num_exif,
+ png_ptr->num_exif);
+
+ png_warning(png_ptr, "Invalid number of exif bytes specified");
+ return;
+ }
+
+ png_write_chunk_header(png_ptr, png_eXIf, (png_uint_32)(num_exif));
+
+ for (i = 0; i < num_exif; i++)
+ {
+ buf[i] = exif[i];
+ png_write_chunk_data(png_ptr, buf, (png_size_t)1);
+ }
+
+ png_write_chunk_end(png_ptr);
+}
+#endif
+
#ifdef PNG_WRITE_hIST_SUPPORTED
/* Write the histogram */
void /* PRIVATE */
diff --git a/thirdparty/zstd/README.md b/thirdparty/zstd/README.md
index 7caee5fd3f..f37be4542c 100644
--- a/thirdparty/zstd/README.md
+++ b/thirdparty/zstd/README.md
@@ -6,10 +6,17 @@ and a command line utility producing and decoding `.zst` and `.gz` files.
For other programming languages,
you can consult a list of known ports on [Zstandard homepage](http://www.zstd.net/#other-languages).
-|Branch |Status |
-|------------|---------|
-|master | [![Build Status](https://travis-ci.org/facebook/zstd.svg?branch=master)](https://travis-ci.org/facebook/zstd) |
-|dev | [![Build Status](https://travis-ci.org/facebook/zstd.svg?branch=dev)](https://travis-ci.org/facebook/zstd) |
+| dev branch status |
+|-------------------|
+| [![Build Status][travisDevBadge]][travisLink] [![Build status][AppveyorDevBadge]][AppveyorLink] [![Build status][CircleDevBadge]][CircleLink]
+
+[travisDevBadge]: https://travis-ci.org/facebook/zstd.svg?branch=dev "Continuous Integration test suite"
+[travisLink]: https://travis-ci.org/facebook/zstd
+[AppveyorDevBadge]: https://ci.appveyor.com/api/projects/status/xt38wbdxjk5mrbem/branch/dev?svg=true "Windows test suite"
+[AppveyorLink]: https://ci.appveyor.com/project/YannCollet/zstd-p0yf0
+[CircleDevBadge]: https://circleci.com/gh/facebook/zstd/tree/dev.svg?style=shield "Short test suite"
+[CircleLink]: https://circleci.com/gh/facebook/zstd
+
As a reference, several fast compression algorithms were tested and compared
on a server running Linux Debian (`Linux version 4.8.0-1-amd64`),
@@ -60,11 +67,11 @@ Previous charts provide results applicable to typical file and stream scenarios
The smaller the amount of data to compress, the more difficult it is to compress. This problem is common to all compression algorithms, and reason is, compression algorithms learn from past data how to compress future data. But at the beginning of a new data set, there is no "past" to build upon.
To solve this situation, Zstd offers a __training mode__, which can be used to tune the algorithm for a selected type of data.
-Training Zstandard is achieved by provide it with a few samples (one file per sample). The result of this training is stored in a file called "dictionary", which must be loaded before compression and decompression.
+Training Zstandard is achieved by providing it with a few samples (one file per sample). The result of this training is stored in a file called "dictionary", which must be loaded before compression and decompression.
Using this dictionary, the compression ratio achievable on small data improves dramatically.
The following example uses the `github-users` [sample set](https://github.com/facebook/zstd/releases/tag/v1.1.3), created from [github public API](https://developer.github.com/v3/users/#get-all-users).
-It consists of roughly 10K records weighting about 1KB each.
+It consists of roughly 10K records weighing about 1KB each.
Compression Ratio | Compression Speed | Decompression Speed
------------------|-------------------|--------------------
diff --git a/thirdparty/zstd/common/bitstream.h b/thirdparty/zstd/common/bitstream.h
index ca42850df3..07b85026c9 100644
--- a/thirdparty/zstd/common/bitstream.h
+++ b/thirdparty/zstd/common/bitstream.h
@@ -39,7 +39,6 @@
extern "C" {
#endif
-
/*
* This API consists of small unitary functions, which must be inlined for best performance.
* Since link-time-optimization is not available for all compilers,
@@ -59,7 +58,9 @@ extern "C" {
#if defined(BIT_DEBUG) && (BIT_DEBUG>=1)
# include <assert.h>
#else
-# define assert(condition) ((void)0)
+# ifndef assert
+# define assert(condition) ((void)0)
+# endif
#endif
@@ -74,6 +75,7 @@ extern "C" {
#define STREAM_ACCUMULATOR_MIN_64 57
#define STREAM_ACCUMULATOR_MIN ((U32)(MEM_32bits() ? STREAM_ACCUMULATOR_MIN_32 : STREAM_ACCUMULATOR_MIN_64))
+
/*-******************************************
* bitStream encoding API (write forward)
********************************************/
@@ -303,13 +305,25 @@ MEM_STATIC size_t BIT_initDStream(BIT_DStream_t* bitD, const void* srcBuffer, si
bitD->bitContainer = *(const BYTE*)(bitD->start);
switch(srcSize)
{
- case 7: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[6]) << (sizeof(bitD->bitContainer)*8 - 16);
- case 6: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[5]) << (sizeof(bitD->bitContainer)*8 - 24);
- case 5: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[4]) << (sizeof(bitD->bitContainer)*8 - 32);
- case 4: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[3]) << 24;
- case 3: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[2]) << 16;
- case 2: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[1]) << 8;
- default:;
+ case 7: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[6]) << (sizeof(bitD->bitContainer)*8 - 16);
+ /* fall-through */
+
+ case 6: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[5]) << (sizeof(bitD->bitContainer)*8 - 24);
+ /* fall-through */
+
+ case 5: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[4]) << (sizeof(bitD->bitContainer)*8 - 32);
+ /* fall-through */
+
+ case 4: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[3]) << 24;
+ /* fall-through */
+
+ case 3: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[2]) << 16;
+ /* fall-through */
+
+ case 2: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[1]) << 8;
+ /* fall-through */
+
+ default: break;
}
{ BYTE const lastByte = ((const BYTE*)srcBuffer)[srcSize-1];
bitD->bitsConsumed = lastByte ? 8 - BIT_highbit32(lastByte) : 0;
diff --git a/thirdparty/zstd/common/error_private.c b/thirdparty/zstd/common/error_private.c
index b3287245f1..2d752cd23a 100644
--- a/thirdparty/zstd/common/error_private.c
+++ b/thirdparty/zstd/common/error_private.c
@@ -24,7 +24,8 @@ const char* ERR_getErrorString(ERR_enum code)
case PREFIX(frameParameter_unsupported): return "Unsupported frame parameter";
case PREFIX(frameParameter_unsupportedBy32bits): return "Frame parameter unsupported in 32-bits mode";
case PREFIX(frameParameter_windowTooLarge): return "Frame requires too much memory for decoding";
- case PREFIX(compressionParameter_unsupported): return "Compression parameter is out of bound";
+ case PREFIX(compressionParameter_unsupported): return "Compression parameter is not supported";
+ case PREFIX(compressionParameter_outOfBound): return "Compression parameter is out of bound";
case PREFIX(init_missing): return "Context should be init first";
case PREFIX(memory_allocation): return "Allocation error : not enough memory";
case PREFIX(stage_wrong): return "Operation not authorized at current processing stage";
@@ -38,6 +39,8 @@ const char* ERR_getErrorString(ERR_enum code)
case PREFIX(dictionary_corrupted): return "Dictionary is corrupted";
case PREFIX(dictionary_wrong): return "Dictionary mismatch";
case PREFIX(dictionaryCreation_failed): return "Cannot create Dictionary from provided samples";
+ case PREFIX(frameIndex_tooLarge): return "Frame index is too large";
+ case PREFIX(seekableIO): return "An I/O error occurred when reading/seeking";
case PREFIX(maxCode):
default: return notErrorCode;
}
diff --git a/thirdparty/zstd/common/huf.h b/thirdparty/zstd/common/huf.h
index 7873ca3d42..dabd359915 100644
--- a/thirdparty/zstd/common/huf.h
+++ b/thirdparty/zstd/common/huf.h
@@ -111,6 +111,18 @@ HUF_PUBLIC_API size_t HUF_compress2 (void* dst, size_t dstCapacity, const void*
#define HUF_WORKSPACE_SIZE_U32 (HUF_WORKSPACE_SIZE / sizeof(U32))
HUF_PUBLIC_API size_t HUF_compress4X_wksp (void* dst, size_t dstCapacity, const void* src, size_t srcSize, unsigned maxSymbolValue, unsigned tableLog, void* workSpace, size_t wkspSize);
+/**
+ * The minimum workspace size for the `workSpace` used in
+ * HUF_readDTableX2_wksp() and HUF_readDTableX4_wksp().
+ *
+ * The space used depends on HUF_TABLELOG_MAX, ranging from ~1500 bytes when
+ * HUF_TABLE_LOG_MAX=12 to ~1850 bytes when HUF_TABLE_LOG_MAX=15.
+ * Buffer overflow errors may potentially occur if code modifications result in
+ * a required workspace size greater than that specified in the following
+ * macro.
+ */
+#define HUF_DECOMPRESS_WORKSPACE_SIZE (2 << 10)
+#define HUF_DECOMPRESS_WORKSPACE_SIZE_U32 (HUF_DECOMPRESS_WORKSPACE_SIZE / sizeof(U32))
/* ******************************************************************
@@ -170,8 +182,11 @@ size_t HUF_decompress4X4 (void* dst, size_t dstSize, const void* cSrc, size_t cS
size_t HUF_decompress4X_DCtx (HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize); /**< decodes RLE and uncompressed */
size_t HUF_decompress4X_hufOnly(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize); /**< considers RLE and uncompressed as errors */
+size_t HUF_decompress4X_hufOnly_wksp(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize, void* workSpace, size_t wkspSize); /**< considers RLE and uncompressed as errors */
size_t HUF_decompress4X2_DCtx(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize); /**< single-symbol decoder */
+size_t HUF_decompress4X2_DCtx_wksp(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize, void* workSpace, size_t wkspSize); /**< single-symbol decoder */
size_t HUF_decompress4X4_DCtx(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize); /**< double-symbols decoder */
+size_t HUF_decompress4X4_DCtx_wksp(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize, void* workSpace, size_t wkspSize); /**< double-symbols decoder */
/* ****************************************
@@ -243,7 +258,9 @@ HUF_decompress() does the following:
U32 HUF_selectDecoder (size_t dstSize, size_t cSrcSize);
size_t HUF_readDTableX2 (HUF_DTable* DTable, const void* src, size_t srcSize);
+size_t HUF_readDTableX2_wksp (HUF_DTable* DTable, const void* src, size_t srcSize, void* workSpace, size_t wkspSize);
size_t HUF_readDTableX4 (HUF_DTable* DTable, const void* src, size_t srcSize);
+size_t HUF_readDTableX4_wksp (HUF_DTable* DTable, const void* src, size_t srcSize, void* workSpace, size_t wkspSize);
size_t HUF_decompress4X_usingDTable(void* dst, size_t maxDstSize, const void* cSrc, size_t cSrcSize, const HUF_DTable* DTable);
size_t HUF_decompress4X2_usingDTable(void* dst, size_t maxDstSize, const void* cSrc, size_t cSrcSize, const HUF_DTable* DTable);
@@ -266,8 +283,11 @@ size_t HUF_decompress1X2 (void* dst, size_t dstSize, const void* cSrc, size_t cS
size_t HUF_decompress1X4 (void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize); /* double-symbol decoder */
size_t HUF_decompress1X_DCtx (HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize);
+size_t HUF_decompress1X_DCtx_wksp (HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize, void* workSpace, size_t wkspSize);
size_t HUF_decompress1X2_DCtx(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize); /**< single-symbol decoder */
+size_t HUF_decompress1X2_DCtx_wksp(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize, void* workSpace, size_t wkspSize); /**< single-symbol decoder */
size_t HUF_decompress1X4_DCtx(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize); /**< double-symbols decoder */
+size_t HUF_decompress1X4_DCtx_wksp(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize, void* workSpace, size_t wkspSize); /**< double-symbols decoder */
size_t HUF_decompress1X_usingDTable(void* dst, size_t maxDstSize, const void* cSrc, size_t cSrcSize, const HUF_DTable* DTable); /**< automatic selection of sing or double symbol decoder, based on DTable */
size_t HUF_decompress1X2_usingDTable(void* dst, size_t maxDstSize, const void* cSrc, size_t cSrcSize, const HUF_DTable* DTable);
diff --git a/thirdparty/zstd/common/mem.h b/thirdparty/zstd/common/mem.h
index 4773a8b930..b0e5bf60b4 100644
--- a/thirdparty/zstd/common/mem.h
+++ b/thirdparty/zstd/common/mem.h
@@ -352,20 +352,6 @@ MEM_STATIC void MEM_writeBEST(void* memPtr, size_t val)
}
-/* function safe only for comparisons */
-MEM_STATIC U32 MEM_readMINMATCH(const void* memPtr, U32 length)
-{
- switch (length)
- {
- default :
- case 4 : return MEM_read32(memPtr);
- case 3 : if (MEM_isLittleEndian())
- return MEM_read32(memPtr)<<8;
- else
- return MEM_read32(memPtr)>>8;
- }
-}
-
#if defined (__cplusplus)
}
#endif
diff --git a/thirdparty/zstd/common/pool.c b/thirdparty/zstd/common/pool.c
index e439fe1b0d..749fa4f2f7 100644
--- a/thirdparty/zstd/common/pool.c
+++ b/thirdparty/zstd/common/pool.c
@@ -146,6 +146,13 @@ void POOL_free(POOL_ctx *ctx) {
free(ctx);
}
+size_t POOL_sizeof(POOL_ctx *ctx) {
+ if (ctx==NULL) return 0; /* supports sizeof NULL */
+ return sizeof(*ctx)
+ + ctx->queueSize * sizeof(POOL_job)
+ + ctx->numThreads * sizeof(pthread_t);
+}
+
void POOL_add(void *ctxVoid, POOL_function function, void *opaque) {
POOL_ctx *ctx = (POOL_ctx *)ctxVoid;
if (!ctx) { return; }
@@ -191,4 +198,9 @@ void POOL_add(void *ctx, POOL_function function, void *opaque) {
function(opaque);
}
+size_t POOL_sizeof(POOL_ctx *ctx) {
+ if (ctx==NULL) return 0; /* supports sizeof NULL */
+ return sizeof(*ctx);
+}
+
#endif /* ZSTD_MULTITHREAD */
diff --git a/thirdparty/zstd/common/pool.h b/thirdparty/zstd/common/pool.h
index 50cb25b12c..386cd674b7 100644
--- a/thirdparty/zstd/common/pool.h
+++ b/thirdparty/zstd/common/pool.h
@@ -32,6 +32,11 @@ POOL_ctx *POOL_create(size_t numThreads, size_t queueSize);
*/
void POOL_free(POOL_ctx *ctx);
+/*! POOL_sizeof() :
+ return memory usage of pool returned by POOL_create().
+*/
+size_t POOL_sizeof(POOL_ctx *ctx);
+
/*! POOL_function :
The function type that can be added to a thread pool.
*/
diff --git a/thirdparty/zstd/common/threading.c b/thirdparty/zstd/common/threading.c
index 32d58796a9..141376c561 100644
--- a/thirdparty/zstd/common/threading.c
+++ b/thirdparty/zstd/common/threading.c
@@ -1,4 +1,3 @@
-
/**
* Copyright (c) 2016 Tino Reichardt
* All rights reserved.
diff --git a/thirdparty/zstd/common/zstd_common.c b/thirdparty/zstd/common/zstd_common.c
index 8408a589ae..f681672381 100644
--- a/thirdparty/zstd/common/zstd_common.c
+++ b/thirdparty/zstd/common/zstd_common.c
@@ -12,16 +12,19 @@
/*-*************************************
* Dependencies
***************************************/
-#include <stdlib.h> /* malloc */
+#include <stdlib.h> /* malloc, calloc, free */
+#include <string.h> /* memset */
#include "error_private.h"
#define ZSTD_STATIC_LINKING_ONLY
-#include "zstd.h" /* declaration of ZSTD_isError, ZSTD_getErrorName, ZSTD_getErrorCode, ZSTD_getErrorString, ZSTD_versionNumber */
+#include "zstd.h"
/*-****************************************
* Version
******************************************/
-unsigned ZSTD_versionNumber (void) { return ZSTD_VERSION_NUMBER; }
+unsigned ZSTD_versionNumber(void) { return ZSTD_VERSION_NUMBER; }
+
+const char* ZSTD_versionString(void) { return ZSTD_VERSION_STRING; }
/*-****************************************
@@ -47,27 +50,31 @@ const char* ZSTD_getErrorString(ZSTD_ErrorCode code) { return ERR_getErrorString
/*=**************************************************************
* Custom allocator
****************************************************************/
-/* default uses stdlib */
-void* ZSTD_defaultAllocFunction(void* opaque, size_t size)
-{
- void* address = malloc(size);
- (void)opaque;
- return address;
-}
-
-void ZSTD_defaultFreeFunction(void* opaque, void* address)
+void* ZSTD_malloc(size_t size, ZSTD_customMem customMem)
{
- (void)opaque;
- free(address);
+ if (customMem.customAlloc)
+ return customMem.customAlloc(customMem.opaque, size);
+ return malloc(size);
}
-void* ZSTD_malloc(size_t size, ZSTD_customMem customMem)
+void* ZSTD_calloc(size_t size, ZSTD_customMem customMem)
{
- return customMem.customAlloc(customMem.opaque, size);
+ if (customMem.customAlloc) {
+ /* calloc implemented as malloc+memset;
+ * not as efficient as calloc, but next best guess for custom malloc */
+ void* const ptr = customMem.customAlloc(customMem.opaque, size);
+ memset(ptr, 0, size);
+ return ptr;
+ }
+ return calloc(1, size);
}
void ZSTD_free(void* ptr, ZSTD_customMem customMem)
{
- if (ptr!=NULL)
- customMem.customFree(customMem.opaque, ptr);
+ if (ptr!=NULL) {
+ if (customMem.customFree)
+ customMem.customFree(customMem.opaque, ptr);
+ else
+ free(ptr);
+ }
}
diff --git a/thirdparty/zstd/common/zstd_errors.h b/thirdparty/zstd/common/zstd_errors.h
index 3d579d9693..19f1597aa3 100644
--- a/thirdparty/zstd/common/zstd_errors.h
+++ b/thirdparty/zstd/common/zstd_errors.h
@@ -19,10 +19,12 @@ extern "C" {
/* ===== ZSTDERRORLIB_API : control library symbols visibility ===== */
-#if defined(__GNUC__) && (__GNUC__ >= 4)
-# define ZSTDERRORLIB_VISIBILITY __attribute__ ((visibility ("default")))
-#else
-# define ZSTDERRORLIB_VISIBILITY
+#ifndef ZSTDERRORLIB_VISIBILITY
+# if defined(__GNUC__) && (__GNUC__ >= 4)
+# define ZSTDERRORLIB_VISIBILITY __attribute__ ((visibility ("default")))
+# else
+# define ZSTDERRORLIB_VISIBILITY
+# endif
#endif
#if defined(ZSTD_DLL_EXPORT) && (ZSTD_DLL_EXPORT==1)
# define ZSTDERRORLIB_API __declspec(dllexport) ZSTDERRORLIB_VISIBILITY
@@ -33,8 +35,11 @@ extern "C" {
#endif
/*-****************************************
-* error codes list
-******************************************/
+ * error codes list
+ * note : this API is still considered unstable
+ * it should not be used with a dynamic library
+ * only static linking is allowed
+ ******************************************/
typedef enum {
ZSTD_error_no_error,
ZSTD_error_GENERIC,
@@ -45,6 +50,7 @@ typedef enum {
ZSTD_error_frameParameter_unsupportedBy32bits,
ZSTD_error_frameParameter_windowTooLarge,
ZSTD_error_compressionParameter_unsupported,
+ ZSTD_error_compressionParameter_outOfBound,
ZSTD_error_init_missing,
ZSTD_error_memory_allocation,
ZSTD_error_stage_wrong,
@@ -58,12 +64,14 @@ typedef enum {
ZSTD_error_dictionary_corrupted,
ZSTD_error_dictionary_wrong,
ZSTD_error_dictionaryCreation_failed,
+ ZSTD_error_frameIndex_tooLarge,
+ ZSTD_error_seekableIO,
ZSTD_error_maxCode
} ZSTD_ErrorCode;
/*! ZSTD_getErrorCode() :
convert a `size_t` function result into a `ZSTD_ErrorCode` enum type,
- which can be used to compare directly with enum list published into "error_public.h" */
+ which can be used to compare with enum list published above */
ZSTDERRORLIB_API ZSTD_ErrorCode ZSTD_getErrorCode(size_t functionResult);
ZSTDERRORLIB_API const char* ZSTD_getErrorString(ZSTD_ErrorCode code);
diff --git a/thirdparty/zstd/common/zstd_internal.h b/thirdparty/zstd/common/zstd_internal.h
index 2533333ba8..49a4796476 100644
--- a/thirdparty/zstd/common/zstd_internal.h
+++ b/thirdparty/zstd/common/zstd_internal.h
@@ -18,6 +18,7 @@
# include <intrin.h> /* For Visual 2005 */
# pragma warning(disable : 4100) /* disable: C4100: unreferenced formal parameter */
# pragma warning(disable : 4127) /* disable: C4127: conditional expression is constant */
+# pragma warning(disable : 4204) /* disable: C4204: non-constant aggregate initializer */
# pragma warning(disable : 4324) /* disable: C4324: padded structure */
#else
# if defined (__cplusplus) || defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 */
@@ -50,9 +51,42 @@
#define ZSTD_STATIC_LINKING_ONLY
#include "zstd.h"
#ifndef XXH_STATIC_LINKING_ONLY
-# define XXH_STATIC_LINKING_ONLY /* XXH64_state_t */
+# define XXH_STATIC_LINKING_ONLY /* XXH64_state_t */
+#endif
+#include "xxhash.h" /* XXH_reset, update, digest */
+
+
+/*-*************************************
+* Debug
+***************************************/
+#if defined(ZSTD_DEBUG) && (ZSTD_DEBUG>=1)
+# include <assert.h>
+#else
+# ifndef assert
+# define assert(condition) ((void)0)
+# endif
+#endif
+
+#define ZSTD_STATIC_ASSERT(c) { enum { ZSTD_static_assert = 1/(int)(!!(c)) }; }
+
+#if defined(ZSTD_DEBUG) && (ZSTD_DEBUG>=2)
+# include <stdio.h>
+/* recommended values for ZSTD_DEBUG display levels :
+ * 1 : no display, enables assert() only
+ * 2 : reserved for currently active debugging path
+ * 3 : events once per object lifetime (CCtx, CDict)
+ * 4 : events once per frame
+ * 5 : events once per block
+ * 6 : events once per sequence (*very* verbose) */
+# define DEBUGLOG(l, ...) { \
+ if (l<=ZSTD_DEBUG) { \
+ fprintf(stderr, __FILE__ ": "); \
+ fprintf(stderr, __VA_ARGS__); \
+ fprintf(stderr, " \n"); \
+ } }
+#else
+# define DEBUGLOG(l, ...) {} /* disabled */
#endif
-#include "xxhash.h" /* XXH_reset, update, digest */
/*-*************************************
@@ -70,7 +104,6 @@
* Common constants
***************************************/
#define ZSTD_OPT_NUM (1<<12)
-#define ZSTD_DICT_MAGIC 0xEC30A437 /* v0.7+ */
#define ZSTD_REP_NUM 3 /* number of repcodes */
#define ZSTD_REP_CHECK (ZSTD_REP_NUM) /* number of repcodes to check by the optimal parser */
@@ -235,15 +268,10 @@ typedef struct {
const seqStore_t* ZSTD_getSeqStore(const ZSTD_CCtx* ctx);
void ZSTD_seqToCodes(const seqStore_t* seqStorePtr);
-int ZSTD_isSkipFrame(ZSTD_DCtx* dctx);
/* custom memory allocation functions */
-void* ZSTD_defaultAllocFunction(void* opaque, size_t size);
-void ZSTD_defaultFreeFunction(void* opaque, void* address);
-#ifndef ZSTD_DLL_IMPORT
-static const ZSTD_customMem defaultCustomMem = { ZSTD_defaultAllocFunction, ZSTD_defaultFreeFunction, NULL };
-#endif
void* ZSTD_malloc(size_t size, ZSTD_customMem customMem);
+void* ZSTD_calloc(size_t size, ZSTD_customMem customMem);
void ZSTD_free(void* ptr, ZSTD_customMem customMem);
@@ -281,4 +309,38 @@ MEM_STATIC U32 ZSTD_highbit32(U32 val)
void ZSTD_invalidateRepCodes(ZSTD_CCtx* cctx);
+/*! ZSTD_initCStream_internal() :
+ * Private use only. Init streaming operation.
+ * expects params to be valid.
+ * must receive dict, or cdict, or none, but not both.
+ * @return : 0, or an error code */
+size_t ZSTD_initCStream_internal(ZSTD_CStream* zcs,
+ const void* dict, size_t dictSize,
+ const ZSTD_CDict* cdict,
+ ZSTD_parameters params, unsigned long long pledgedSrcSize);
+
+/*! ZSTD_compressStream_generic() :
+ * Private use only. To be called from zstdmt_compress.c in single-thread mode. */
+size_t ZSTD_compressStream_generic(ZSTD_CStream* zcs,
+ ZSTD_outBuffer* output,
+ ZSTD_inBuffer* input,
+ ZSTD_EndDirective const flushMode);
+
+/*! ZSTD_getParamsFromCDict() :
+ * as the name implies */
+ZSTD_parameters ZSTD_getParamsFromCDict(const ZSTD_CDict* cdict);
+
+
+typedef struct {
+ blockType_e blockType;
+ U32 lastBlock;
+ U32 origSize;
+} blockProperties_t;
+
+/*! ZSTD_getcBlockSize() :
+ * Provides the size of compressed block from block header `src` */
+ size_t ZSTD_getcBlockSize(const void* src, size_t srcSize,
+ blockProperties_t* bpPtr);
+
+
#endif /* ZSTD_CCOMMON_H_MODULE */
diff --git a/thirdparty/zstd/compress/huf_compress.c b/thirdparty/zstd/compress/huf_compress.c
index fe11aafb8f..7af0789a9c 100644
--- a/thirdparty/zstd/compress/huf_compress.c
+++ b/thirdparty/zstd/compress/huf_compress.c
@@ -266,7 +266,8 @@ static U32 HUF_setMaxHeight(nodeElt* huffNode, U32 lastNonNull, U32 maxNbBits)
if (highTotal <= lowTotal) break;
} }
/* only triggered when no more rank 1 symbol left => find closest one (note : there is necessarily at least one !) */
- while ((nBitsToDecrease<=HUF_TABLELOG_MAX) && (rankLast[nBitsToDecrease] == noSymbol)) /* HUF_MAX_TABLELOG test just to please gcc 5+; but it should not be necessary */
+ /* HUF_MAX_TABLELOG test just to please gcc 5+; but it should not be necessary */
+ while ((nBitsToDecrease<=HUF_TABLELOG_MAX) && (rankLast[nBitsToDecrease] == noSymbol))
nBitsToDecrease ++;
totalCost -= 1 << (nBitsToDecrease-1);
if (rankLast[nBitsToDecrease-1] == noSymbol)
@@ -463,12 +464,15 @@ size_t HUF_compress1X_usingCTable(void* dst, size_t dstSize, const void* src, si
{
case 3 : HUF_encodeSymbol(&bitC, ip[n+ 2], CTable);
HUF_FLUSHBITS_2(&bitC);
+ /* fall-through */
case 2 : HUF_encodeSymbol(&bitC, ip[n+ 1], CTable);
HUF_FLUSHBITS_1(&bitC);
+ /* fall-through */
case 1 : HUF_encodeSymbol(&bitC, ip[n+ 0], CTable);
HUF_FLUSHBITS(&bitC);
- case 0 :
- default: ;
+ /* fall-through */
+ case 0 : /* fall-through */
+ default: break;
}
for (; n>0; n-=4) { /* note : n&3==0 at this stage */
diff --git a/thirdparty/zstd/compress/zstd_compress.c b/thirdparty/zstd/compress/zstd_compress.c
index c08b315dab..9300357f2d 100644
--- a/thirdparty/zstd/compress/zstd_compress.c
+++ b/thirdparty/zstd/compress/zstd_compress.c
@@ -9,6 +9,14 @@
/*-*************************************
+* Tuning parameters
+***************************************/
+#ifndef ZSTD_CLEVEL_DEFAULT
+# define ZSTD_CLEVEL_DEFAULT 3
+#endif
+
+
+/*-*************************************
* Dependencies
***************************************/
#include <string.h> /* memset */
@@ -18,26 +26,7 @@
#define HUF_STATIC_LINKING_ONLY
#include "huf.h"
#include "zstd_internal.h" /* includes zstd.h */
-
-
-/*-*************************************
-* Debug
-***************************************/
-#if defined(ZSTD_DEBUG) && (ZSTD_DEBUG>=1)
-# include <assert.h>
-#else
-# define assert(condition) ((void)0)
-#endif
-
-#define ZSTD_STATIC_ASSERT(c) { enum { ZSTD_static_assert = 1/(int)(!!(c)) }; }
-
-#if defined(ZSTD_DEBUG) && (ZSTD_DEBUG>=2)
-# include <stdio.h>
- static unsigned g_debugLevel = ZSTD_DEBUG;
-# define DEBUGLOG(l, ...) if (l<=g_debugLevel) { fprintf(stderr, __FILE__ ": "); fprintf(stderr, __VA_ARGS__); fprintf(stderr, " \n"); }
-#else
-# define DEBUGLOG(l, ...) {} /* disabled */
-#endif
+#include "zstdmt_compress.h"
/*-*************************************
@@ -79,6 +68,15 @@ static void ZSTD_resetSeqStore(seqStore_t* ssPtr)
/*-*************************************
* Context memory management
***************************************/
+typedef enum { zcss_init=0, zcss_load, zcss_flush } ZSTD_cStreamStage;
+
+struct ZSTD_CDict_s {
+ void* dictBuffer;
+ const void* dictContent;
+ size_t dictContentSize;
+ ZSTD_CCtx* refContext;
+}; /* typedef'd to ZSTD_CDict within "zstd.h" */
+
struct ZSTD_CCtx_s {
const BYTE* nextSrc; /* next block here to continue on current prefix */
const BYTE* base; /* All regular indexes relative to this position */
@@ -90,19 +88,21 @@ struct ZSTD_CCtx_s {
U32 hashLog3; /* dispatch table : larger == faster, more memory */
U32 loadedDictEnd; /* index of end of dictionary */
U32 forceWindow; /* force back-references to respect limit of 1<<wLog, even for dictionary */
- U32 forceRawDict; /* Force loading dictionary in "content-only" mode (no header analysis) */
ZSTD_compressionStage_e stage;
U32 rep[ZSTD_REP_NUM];
U32 repToConfirm[ZSTD_REP_NUM];
U32 dictID;
- ZSTD_parameters params;
+ int compressionLevel;
+ ZSTD_parameters requestedParams;
+ ZSTD_parameters appliedParams;
void* workSpace;
size_t workSpaceSize;
size_t blockSize;
- U64 frameContentSize;
+ U64 pledgedSrcSizePlusOne; /* this way, 0 (default) == unknown */
U64 consumedSrcSize;
XXH64_state_t xxhState;
ZSTD_customMem customMem;
+ size_t staticSize;
seqStore_t seqStore; /* sequences storage ptrs */
U32* hashTable;
@@ -115,31 +115,92 @@ struct ZSTD_CCtx_s {
FSE_CTable* matchlengthCTable;
FSE_CTable* litlengthCTable;
unsigned* entropyScratchSpace;
+
+ /* streaming */
+ char* inBuff;
+ size_t inBuffSize;
+ size_t inToCompress;
+ size_t inBuffPos;
+ size_t inBuffTarget;
+ char* outBuff;
+ size_t outBuffSize;
+ size_t outBuffContentSize;
+ size_t outBuffFlushedSize;
+ ZSTD_cStreamStage streamStage;
+ U32 frameEnded;
+
+ /* Dictionary */
+ ZSTD_dictMode_e dictMode; /* select restricting dictionary to "rawContent" or "fullDict" only */
+ U32 dictContentByRef;
+ ZSTD_CDict* cdictLocal;
+ const ZSTD_CDict* cdict;
+ const void* prefix;
+ size_t prefixSize;
+
+ /* Multi-threading */
+ U32 nbThreads;
+ ZSTDMT_CCtx* mtctx;
};
+
ZSTD_CCtx* ZSTD_createCCtx(void)
{
- return ZSTD_createCCtx_advanced(defaultCustomMem);
+ return ZSTD_createCCtx_advanced(ZSTD_defaultCMem);
}
ZSTD_CCtx* ZSTD_createCCtx_advanced(ZSTD_customMem customMem)
{
ZSTD_CCtx* cctx;
- if (!customMem.customAlloc && !customMem.customFree) customMem = defaultCustomMem;
- if (!customMem.customAlloc || !customMem.customFree) return NULL;
+ if (!customMem.customAlloc ^ !customMem.customFree) return NULL;
- cctx = (ZSTD_CCtx*) ZSTD_malloc(sizeof(ZSTD_CCtx), customMem);
+ cctx = (ZSTD_CCtx*) ZSTD_calloc(sizeof(ZSTD_CCtx), customMem);
if (!cctx) return NULL;
- memset(cctx, 0, sizeof(ZSTD_CCtx));
cctx->customMem = customMem;
+ cctx->compressionLevel = ZSTD_CLEVEL_DEFAULT;
+ ZSTD_STATIC_ASSERT(zcss_init==0);
+ ZSTD_STATIC_ASSERT(ZSTD_CONTENTSIZE_UNKNOWN==(0ULL - 1));
+ return cctx;
+}
+
+ZSTD_CCtx* ZSTD_initStaticCCtx(void *workspace, size_t workspaceSize)
+{
+ ZSTD_CCtx* cctx = (ZSTD_CCtx*) workspace;
+ if (workspaceSize <= sizeof(ZSTD_CCtx)) return NULL; /* minimum size */
+ if ((size_t)workspace & 7) return NULL; /* must be 8-aligned */
+ memset(workspace, 0, workspaceSize); /* may be a bit generous, could memset be smaller ? */
+ cctx->staticSize = workspaceSize;
+ cctx->workSpace = (void*)(cctx+1);
+ cctx->workSpaceSize = workspaceSize - sizeof(ZSTD_CCtx);
+
+ /* entropy space (never moves) */
+ /* note : this code should be shared with resetCCtx, rather than copy/pasted */
+ { void* ptr = cctx->workSpace;
+ cctx->hufCTable = (HUF_CElt*)ptr;
+ ptr = (char*)cctx->hufCTable + hufCTable_size;
+ cctx->offcodeCTable = (FSE_CTable*) ptr;
+ ptr = (char*)ptr + offcodeCTable_size;
+ cctx->matchlengthCTable = (FSE_CTable*) ptr;
+ ptr = (char*)ptr + matchlengthCTable_size;
+ cctx->litlengthCTable = (FSE_CTable*) ptr;
+ ptr = (char*)ptr + litlengthCTable_size;
+ assert(((size_t)ptr & 3) == 0); /* ensure correct alignment */
+ cctx->entropyScratchSpace = (unsigned*) ptr;
+ }
+
return cctx;
}
size_t ZSTD_freeCCtx(ZSTD_CCtx* cctx)
{
if (cctx==NULL) return 0; /* support free on NULL */
+ if (cctx->staticSize) return ERROR(memory_allocation); /* not compatible with static CCtx */
ZSTD_free(cctx->workSpace, cctx->customMem);
+ cctx->workSpace = NULL;
+ ZSTD_freeCDict(cctx->cdictLocal);
+ cctx->cdictLocal = NULL;
+ ZSTDMT_freeCCtx(cctx->mtctx);
+ cctx->mtctx = NULL;
ZSTD_free(cctx, cctx->customMem);
return 0; /* reserved as a potential error code in the future */
}
@@ -147,46 +208,294 @@ size_t ZSTD_freeCCtx(ZSTD_CCtx* cctx)
size_t ZSTD_sizeof_CCtx(const ZSTD_CCtx* cctx)
{
if (cctx==NULL) return 0; /* support sizeof on NULL */
- return sizeof(*cctx) + cctx->workSpaceSize;
+ DEBUGLOG(5, "sizeof(*cctx) : %u", (U32)sizeof(*cctx));
+ DEBUGLOG(5, "workSpaceSize : %u", (U32)cctx->workSpaceSize);
+ DEBUGLOG(5, "streaming buffers : %u", (U32)(cctx->outBuffSize + cctx->inBuffSize));
+ DEBUGLOG(5, "inner MTCTX : %u", (U32)ZSTDMT_sizeof_CCtx(cctx->mtctx));
+ return sizeof(*cctx) + cctx->workSpaceSize
+ + ZSTD_sizeof_CDict(cctx->cdictLocal)
+ + cctx->outBuffSize + cctx->inBuffSize
+ + ZSTDMT_sizeof_CCtx(cctx->mtctx);
}
+size_t ZSTD_sizeof_CStream(const ZSTD_CStream* zcs)
+{
+ return ZSTD_sizeof_CCtx(zcs); /* same object */
+}
+
+/* private API call, for dictBuilder only */
+const seqStore_t* ZSTD_getSeqStore(const ZSTD_CCtx* ctx) { return &(ctx->seqStore); }
+
+static ZSTD_parameters ZSTD_getParamsFromCCtx(const ZSTD_CCtx* cctx) { return cctx->appliedParams; }
+
+/* older variant; will be deprecated */
size_t ZSTD_setCCtxParameter(ZSTD_CCtx* cctx, ZSTD_CCtxParameter param, unsigned value)
{
switch(param)
{
case ZSTD_p_forceWindow : cctx->forceWindow = value>0; cctx->loadedDictEnd = 0; return 0;
- case ZSTD_p_forceRawDict : cctx->forceRawDict = value>0; return 0;
+ ZSTD_STATIC_ASSERT(ZSTD_dm_auto==0);
+ ZSTD_STATIC_ASSERT(ZSTD_dm_rawContent==1);
+ case ZSTD_p_forceRawDict : cctx->dictMode = (ZSTD_dictMode_e)(value>0); return 0;
default: return ERROR(parameter_unknown);
}
}
-const seqStore_t* ZSTD_getSeqStore(const ZSTD_CCtx* ctx) /* hidden interface */
+
+#define ZSTD_CLEVEL_CUSTOM 999
+static void ZSTD_cLevelToCParams(ZSTD_CCtx* cctx)
{
- return &(ctx->seqStore);
+ if (cctx->compressionLevel==ZSTD_CLEVEL_CUSTOM) return;
+ cctx->requestedParams.cParams = ZSTD_getCParams(cctx->compressionLevel,
+ cctx->pledgedSrcSizePlusOne-1, 0);
+ cctx->compressionLevel = ZSTD_CLEVEL_CUSTOM;
}
-static ZSTD_parameters ZSTD_getParamsFromCCtx(const ZSTD_CCtx* cctx)
+#define CLAMPCHECK(val,min,max) { \
+ if (((val)<(min)) | ((val)>(max))) { \
+ return ERROR(compressionParameter_outOfBound); \
+} }
+
+size_t ZSTD_CCtx_setParameter(ZSTD_CCtx* cctx, ZSTD_cParameter param, unsigned value)
{
- return cctx->params;
+ if (cctx->streamStage != zcss_init) return ERROR(stage_wrong);
+
+ switch(param)
+ {
+ case ZSTD_p_compressionLevel :
+ if ((int)value > ZSTD_maxCLevel()) value = ZSTD_maxCLevel(); /* cap max compression level */
+ if (value == 0) return 0; /* special value : 0 means "don't change anything" */
+ if (cctx->cdict) return ERROR(stage_wrong);
+ cctx->compressionLevel = value;
+ return 0;
+
+ case ZSTD_p_windowLog :
+ DEBUGLOG(5, "setting ZSTD_p_windowLog = %u (cdict:%u)",
+ value, (cctx->cdict!=NULL));
+ if (value == 0) return 0; /* special value : 0 means "don't change anything" */
+ if (cctx->cdict) return ERROR(stage_wrong);
+ CLAMPCHECK(value, ZSTD_WINDOWLOG_MIN, ZSTD_WINDOWLOG_MAX);
+ ZSTD_cLevelToCParams(cctx);
+ cctx->requestedParams.cParams.windowLog = value;
+ return 0;
+
+ case ZSTD_p_hashLog :
+ if (value == 0) return 0; /* special value : 0 means "don't change anything" */
+ if (cctx->cdict) return ERROR(stage_wrong);
+ CLAMPCHECK(value, ZSTD_HASHLOG_MIN, ZSTD_HASHLOG_MAX);
+ ZSTD_cLevelToCParams(cctx);
+ cctx->requestedParams.cParams.hashLog = value;
+ return 0;
+
+ case ZSTD_p_chainLog :
+ if (value == 0) return 0; /* special value : 0 means "don't change anything" */
+ if (cctx->cdict) return ERROR(stage_wrong);
+ CLAMPCHECK(value, ZSTD_CHAINLOG_MIN, ZSTD_CHAINLOG_MAX);
+ ZSTD_cLevelToCParams(cctx);
+ cctx->requestedParams.cParams.chainLog = value;
+ return 0;
+
+ case ZSTD_p_searchLog :
+ if (value == 0) return 0; /* special value : 0 means "don't change anything" */
+ if (cctx->cdict) return ERROR(stage_wrong);
+ CLAMPCHECK(value, ZSTD_SEARCHLOG_MIN, ZSTD_SEARCHLOG_MAX);
+ ZSTD_cLevelToCParams(cctx);
+ cctx->requestedParams.cParams.searchLog = value;
+ return 0;
+
+ case ZSTD_p_minMatch :
+ if (value == 0) return 0; /* special value : 0 means "don't change anything" */
+ if (cctx->cdict) return ERROR(stage_wrong);
+ CLAMPCHECK(value, ZSTD_SEARCHLENGTH_MIN, ZSTD_SEARCHLENGTH_MAX);
+ ZSTD_cLevelToCParams(cctx);
+ cctx->requestedParams.cParams.searchLength = value;
+ return 0;
+
+ case ZSTD_p_targetLength :
+ if (value == 0) return 0; /* special value : 0 means "don't change anything" */
+ if (cctx->cdict) return ERROR(stage_wrong);
+ CLAMPCHECK(value, ZSTD_TARGETLENGTH_MIN, ZSTD_TARGETLENGTH_MAX);
+ ZSTD_cLevelToCParams(cctx);
+ cctx->requestedParams.cParams.targetLength = value;
+ return 0;
+
+ case ZSTD_p_compressionStrategy :
+ if (value == 0) return 0; /* special value : 0 means "don't change anything" */
+ if (cctx->cdict) return ERROR(stage_wrong);
+ CLAMPCHECK(value, (unsigned)ZSTD_fast, (unsigned)ZSTD_btultra);
+ ZSTD_cLevelToCParams(cctx);
+ cctx->requestedParams.cParams.strategy = (ZSTD_strategy)value;
+ return 0;
+
+ case ZSTD_p_contentSizeFlag :
+ DEBUGLOG(5, "set content size flag = %u", (value>0));
+ /* Content size written in frame header _when known_ (default:1) */
+ cctx->requestedParams.fParams.contentSizeFlag = value>0;
+ return 0;
+
+ case ZSTD_p_checksumFlag :
+ /* A 32-bits content checksum will be calculated and written at end of frame (default:0) */
+ cctx->requestedParams.fParams.checksumFlag = value>0;
+ return 0;
+
+ case ZSTD_p_dictIDFlag : /* When applicable, dictionary's dictID is provided in frame header (default:1) */
+ DEBUGLOG(5, "set dictIDFlag = %u", (value>0));
+ cctx->requestedParams.fParams.noDictIDFlag = (value==0);
+ return 0;
+
+ /* Dictionary parameters */
+ case ZSTD_p_dictMode :
+ if (cctx->cdict) return ERROR(stage_wrong); /* must be set before loading */
+ /* restrict dictionary mode, to "rawContent" or "fullDict" only */
+ ZSTD_STATIC_ASSERT((U32)ZSTD_dm_fullDict > (U32)ZSTD_dm_rawContent);
+ if (value > (unsigned)ZSTD_dm_fullDict)
+ return ERROR(compressionParameter_outOfBound);
+ cctx->dictMode = (ZSTD_dictMode_e)value;
+ return 0;
+
+ case ZSTD_p_refDictContent :
+ if (cctx->cdict) return ERROR(stage_wrong); /* must be set before loading */
+ /* dictionary content will be referenced, instead of copied */
+ cctx->dictContentByRef = value>0;
+ return 0;
+
+ case ZSTD_p_forceMaxWindow : /* Force back-references to remain < windowSize,
+ * even when referencing into Dictionary content
+ * default : 0 when using a CDict, 1 when using a Prefix */
+ cctx->forceWindow = value>0;
+ cctx->loadedDictEnd = 0;
+ return 0;
+
+ case ZSTD_p_nbThreads:
+ if (value==0) return 0;
+ DEBUGLOG(5, " setting nbThreads : %u", value);
+#ifndef ZSTD_MULTITHREAD
+ if (value > 1) return ERROR(compressionParameter_unsupported);
+#endif
+ if ((value>1) && (cctx->nbThreads != value)) {
+ if (cctx->staticSize) /* MT not compatible with static alloc */
+ return ERROR(compressionParameter_unsupported);
+ ZSTDMT_freeCCtx(cctx->mtctx);
+ cctx->nbThreads = 1;
+ cctx->mtctx = ZSTDMT_createCCtx(value);
+ if (cctx->mtctx == NULL) return ERROR(memory_allocation);
+ }
+ cctx->nbThreads = value;
+ return 0;
+
+ case ZSTD_p_jobSize:
+ if (cctx->nbThreads <= 1) return ERROR(compressionParameter_unsupported);
+ assert(cctx->mtctx != NULL);
+ return ZSTDMT_setMTCtxParameter(cctx->mtctx, ZSTDMT_p_sectionSize, value);
+
+ case ZSTD_p_overlapSizeLog:
+ DEBUGLOG(5, " setting overlap with nbThreads == %u", cctx->nbThreads);
+ if (cctx->nbThreads <= 1) return ERROR(compressionParameter_unsupported);
+ assert(cctx->mtctx != NULL);
+ return ZSTDMT_setMTCtxParameter(cctx->mtctx, ZSTDMT_p_overlapSectionLog, value);
+
+ default: return ERROR(parameter_unknown);
+ }
+}
+
+ZSTDLIB_API size_t ZSTD_CCtx_setPledgedSrcSize(ZSTD_CCtx* cctx, unsigned long long pledgedSrcSize)
+{
+ DEBUGLOG(5, " setting pledgedSrcSize to %u", (U32)pledgedSrcSize);
+ if (cctx->streamStage != zcss_init) return ERROR(stage_wrong);
+ cctx->pledgedSrcSizePlusOne = pledgedSrcSize+1;
+ return 0;
+}
+
+ZSTDLIB_API size_t ZSTD_CCtx_loadDictionary(ZSTD_CCtx* cctx, const void* dict, size_t dictSize)
+{
+ if (cctx->streamStage != zcss_init) return ERROR(stage_wrong);
+ if (cctx->staticSize) return ERROR(memory_allocation); /* no malloc for static CCtx */
+ DEBUGLOG(5, "load dictionary of size %u", (U32)dictSize);
+ ZSTD_freeCDict(cctx->cdictLocal); /* in case one already exists */
+ if (dict==NULL || dictSize==0) { /* no dictionary mode */
+ cctx->cdictLocal = NULL;
+ cctx->cdict = NULL;
+ } else {
+ ZSTD_compressionParameters const cParams =
+ cctx->compressionLevel == ZSTD_CLEVEL_CUSTOM ?
+ cctx->requestedParams.cParams :
+ ZSTD_getCParams(cctx->compressionLevel, 0, dictSize);
+ cctx->cdictLocal = ZSTD_createCDict_advanced(
+ dict, dictSize,
+ cctx->dictContentByRef, cctx->dictMode,
+ cParams, cctx->customMem);
+ cctx->cdict = cctx->cdictLocal;
+ if (cctx->cdictLocal == NULL)
+ return ERROR(memory_allocation);
+ }
+ return 0;
+}
+
+size_t ZSTD_CCtx_refCDict(ZSTD_CCtx* cctx, const ZSTD_CDict* cdict)
+{
+ if (cctx->streamStage != zcss_init) return ERROR(stage_wrong);
+ cctx->cdict = cdict;
+ cctx->prefix = NULL; /* exclusive */
+ cctx->prefixSize = 0;
+ return 0;
+}
+
+size_t ZSTD_CCtx_refPrefix(ZSTD_CCtx* cctx, const void* prefix, size_t prefixSize)
+{
+ if (cctx->streamStage != zcss_init) return ERROR(stage_wrong);
+ cctx->cdict = NULL; /* prefix discards any prior cdict */
+ cctx->prefix = prefix;
+ cctx->prefixSize = prefixSize;
+ return 0;
+}
+
+static void ZSTD_startNewCompression(ZSTD_CCtx* cctx)
+{
+ cctx->streamStage = zcss_init;
+ cctx->pledgedSrcSizePlusOne = 0;
}
+/*! ZSTD_CCtx_reset() :
+ * Also dumps dictionary */
+void ZSTD_CCtx_reset(ZSTD_CCtx* cctx)
+{
+ ZSTD_startNewCompression(cctx);
+ cctx->cdict = NULL;
+}
-/** ZSTD_checkParams() :
- ensure param values remain within authorized range.
+/** ZSTD_checkCParams() :
+ control CParam values remain within authorized range.
@return : 0, or an error code if one value is beyond authorized range */
size_t ZSTD_checkCParams(ZSTD_compressionParameters cParams)
{
-# define CLAMPCHECK(val,min,max) { if ((val<min) | (val>max)) return ERROR(compressionParameter_unsupported); }
CLAMPCHECK(cParams.windowLog, ZSTD_WINDOWLOG_MIN, ZSTD_WINDOWLOG_MAX);
CLAMPCHECK(cParams.chainLog, ZSTD_CHAINLOG_MIN, ZSTD_CHAINLOG_MAX);
CLAMPCHECK(cParams.hashLog, ZSTD_HASHLOG_MIN, ZSTD_HASHLOG_MAX);
CLAMPCHECK(cParams.searchLog, ZSTD_SEARCHLOG_MIN, ZSTD_SEARCHLOG_MAX);
CLAMPCHECK(cParams.searchLength, ZSTD_SEARCHLENGTH_MIN, ZSTD_SEARCHLENGTH_MAX);
CLAMPCHECK(cParams.targetLength, ZSTD_TARGETLENGTH_MIN, ZSTD_TARGETLENGTH_MAX);
- if ((U32)(cParams.strategy) > (U32)ZSTD_btopt2) return ERROR(compressionParameter_unsupported);
+ if ((U32)(cParams.strategy) > (U32)ZSTD_btultra) return ERROR(compressionParameter_unsupported);
return 0;
}
+/** ZSTD_clampCParams() :
+ * make CParam values within valid range.
+ * @return : valid CParams */
+static ZSTD_compressionParameters ZSTD_clampCParams(ZSTD_compressionParameters cParams)
+{
+# define CLAMP(val,min,max) { \
+ if (val<min) val=min; \
+ else if (val>max) val=max; \
+ }
+ CLAMP(cParams.windowLog, ZSTD_WINDOWLOG_MIN, ZSTD_WINDOWLOG_MAX);
+ CLAMP(cParams.chainLog, ZSTD_CHAINLOG_MIN, ZSTD_CHAINLOG_MAX);
+ CLAMP(cParams.hashLog, ZSTD_HASHLOG_MIN, ZSTD_HASHLOG_MAX);
+ CLAMP(cParams.searchLog, ZSTD_SEARCHLOG_MIN, ZSTD_SEARCHLOG_MAX);
+ CLAMP(cParams.searchLength, ZSTD_SEARCHLENGTH_MIN, ZSTD_SEARCHLENGTH_MAX);
+ CLAMP(cParams.targetLength, ZSTD_TARGETLENGTH_MIN, ZSTD_TARGETLENGTH_MAX);
+ if ((U32)(cParams.strategy) > (U32)ZSTD_btultra) cParams.strategy = ZSTD_btultra;
+ return cParams;
+}
/** ZSTD_cycleLog() :
* condition for correct operation : hashLog > 1 */
@@ -196,14 +505,15 @@ static U32 ZSTD_cycleLog(U32 hashLog, ZSTD_strategy strat)
return hashLog - btScale;
}
-/** ZSTD_adjustCParams() :
+/** ZSTD_adjustCParams_internal() :
optimize `cPar` for a given input (`srcSize` and `dictSize`).
mostly downsizing to reduce memory consumption and initialization.
Both `srcSize` and `dictSize` are optional (use 0 if unknown),
but if both are 0, no optimization can be done.
Note : cPar is considered validated at this stage. Use ZSTD_checkParams() to ensure that. */
-ZSTD_compressionParameters ZSTD_adjustCParams(ZSTD_compressionParameters cPar, unsigned long long srcSize, size_t dictSize)
+ZSTD_compressionParameters ZSTD_adjustCParams_internal(ZSTD_compressionParameters cPar, unsigned long long srcSize, size_t dictSize)
{
+ assert(ZSTD_checkCParams(cPar)==0);
if (srcSize+dictSize == 0) return cPar; /* no size information available : no adjustment */
/* resize params, to use less memory when necessary */
@@ -223,10 +533,16 @@ ZSTD_compressionParameters ZSTD_adjustCParams(ZSTD_compressionParameters cPar, u
return cPar;
}
+ZSTD_compressionParameters ZSTD_adjustCParams(ZSTD_compressionParameters cPar, unsigned long long srcSize, size_t dictSize)
+{
+ cPar = ZSTD_clampCParams(cPar);
+ return ZSTD_adjustCParams_internal(cPar, srcSize, dictSize);
+}
-size_t ZSTD_estimateCCtxSize(ZSTD_compressionParameters cParams)
+
+size_t ZSTD_estimateCCtxSize_advanced(ZSTD_compressionParameters cParams)
{
- size_t const blockSize = MIN(ZSTD_BLOCKSIZE_ABSOLUTEMAX, (size_t)1 << cParams.windowLog);
+ size_t const blockSize = MIN(ZSTD_BLOCKSIZE_MAX, (size_t)1 << cParams.windowLog);
U32 const divider = (cParams.searchLength==3) ? 3 : 4;
size_t const maxNbSeq = blockSize / divider;
size_t const tokenSpace = blockSize + 11*maxNbSeq;
@@ -240,31 +556,64 @@ size_t ZSTD_estimateCCtxSize(ZSTD_compressionParameters cParams)
+ entropyScratchSpace_size;
size_t const tableSpace = (chainSize + hSize + h3Size) * sizeof(U32);
- size_t const optSpace = ((MaxML+1) + (MaxLL+1) + (MaxOff+1) + (1<<Litbits))*sizeof(U32)
+ size_t const optBudget = ((MaxML+1) + (MaxLL+1) + (MaxOff+1) + (1<<Litbits))*sizeof(U32)
+ (ZSTD_OPT_NUM+1)*(sizeof(ZSTD_match_t) + sizeof(ZSTD_optimal_t));
- size_t const neededSpace = entropySpace + tableSpace + tokenSpace
- + (((cParams.strategy == ZSTD_btopt) || (cParams.strategy == ZSTD_btopt2)) ? optSpace : 0);
+ size_t const optSpace = ((cParams.strategy == ZSTD_btopt) || (cParams.strategy == ZSTD_btultra)) ? optBudget : 0;
+ size_t const neededSpace = entropySpace + tableSpace + tokenSpace + optSpace;
+ DEBUGLOG(5, "sizeof(ZSTD_CCtx) : %u", (U32)sizeof(ZSTD_CCtx));
+ DEBUGLOG(5, "estimate workSpace : %u", (U32)neededSpace);
return sizeof(ZSTD_CCtx) + neededSpace;
}
+size_t ZSTD_estimateCCtxSize(int compressionLevel)
+{
+ ZSTD_compressionParameters const cParams = ZSTD_getCParams(compressionLevel, 0, 0);
+ return ZSTD_estimateCCtxSize_advanced(cParams);
+}
-static U32 ZSTD_equivalentParams(ZSTD_parameters param1, ZSTD_parameters param2)
+size_t ZSTD_estimateCStreamSize_advanced(ZSTD_compressionParameters cParams)
{
- return (param1.cParams.hashLog == param2.cParams.hashLog)
- & (param1.cParams.chainLog == param2.cParams.chainLog)
- & (param1.cParams.strategy == param2.cParams.strategy)
- & ((param1.cParams.searchLength==3) == (param2.cParams.searchLength==3));
+ size_t const CCtxSize = ZSTD_estimateCCtxSize_advanced(cParams);
+ size_t const blockSize = MIN(ZSTD_BLOCKSIZE_MAX, (size_t)1 << cParams.windowLog);
+ size_t const inBuffSize = ((size_t)1 << cParams.windowLog) + blockSize;
+ size_t const outBuffSize = ZSTD_compressBound(blockSize) + 1;
+ size_t const streamingSize = inBuffSize + outBuffSize;
+
+ return CCtxSize + streamingSize;
+}
+
+size_t ZSTD_estimateCStreamSize(int compressionLevel) {
+ ZSTD_compressionParameters const cParams = ZSTD_getCParams(compressionLevel, 0, 0);
+ return ZSTD_estimateCStreamSize_advanced(cParams);
+}
+
+
+static U32 ZSTD_equivalentParams(ZSTD_compressionParameters cParams1,
+ ZSTD_compressionParameters cParams2)
+{
+ U32 bslog1 = MIN(cParams1.windowLog, ZSTD_BLOCKSIZELOG_MAX);
+ U32 bslog2 = MIN(cParams2.windowLog, ZSTD_BLOCKSIZELOG_MAX);
+ return (bslog1 == bslog2) /* same block size */
+ & (cParams1.hashLog == cParams2.hashLog)
+ & (cParams1.chainLog == cParams2.chainLog)
+ & (cParams1.strategy == cParams2.strategy) /* opt parser space */
+ & ((cParams1.searchLength==3) == (cParams2.searchLength==3)); /* hashlog3 space */
}
/*! ZSTD_continueCCtx() :
- reuse CCtx without reset (note : requires no dictionary) */
-static size_t ZSTD_continueCCtx(ZSTD_CCtx* cctx, ZSTD_parameters params, U64 frameContentSize)
+ * reuse CCtx without reset (note : requires no dictionary) */
+static size_t ZSTD_continueCCtx(ZSTD_CCtx* cctx, ZSTD_parameters params, U64 pledgedSrcSize)
{
U32 const end = (U32)(cctx->nextSrc - cctx->base);
- cctx->params = params;
- cctx->frameContentSize = frameContentSize;
+ DEBUGLOG(5, "continue mode");
+ cctx->appliedParams = params;
+ cctx->pledgedSrcSizePlusOne = pledgedSrcSize+1;
cctx->consumedSrcSize = 0;
+ if (pledgedSrcSize == ZSTD_CONTENTSIZE_UNKNOWN)
+ cctx->appliedParams.fParams.contentSizeFlag = 0;
+ DEBUGLOG(5, "pledged content size : %u ; flag : %u",
+ (U32)pledgedSrcSize, cctx->appliedParams.fParams.contentSizeFlag);
cctx->lowLimit = end;
cctx->dictLimit = end;
cctx->nextToUpdate = end+1;
@@ -277,30 +626,39 @@ static size_t ZSTD_continueCCtx(ZSTD_CCtx* cctx, ZSTD_parameters params, U64 fra
return 0;
}
-typedef enum { ZSTDcrp_continue, ZSTDcrp_noMemset, ZSTDcrp_fullReset } ZSTD_compResetPolicy_e;
+typedef enum { ZSTDcrp_continue, ZSTDcrp_noMemset } ZSTD_compResetPolicy_e;
+typedef enum { ZSTDb_not_buffered, ZSTDb_buffered } ZSTD_buffered_policy_e;
/*! ZSTD_resetCCtx_internal() :
- note : `params` must be validated */
-static size_t ZSTD_resetCCtx_internal (ZSTD_CCtx* zc,
- ZSTD_parameters params, U64 frameContentSize,
- ZSTD_compResetPolicy_e const crp)
+ note : `params` are assumed fully validated at this stage */
+static size_t ZSTD_resetCCtx_internal(ZSTD_CCtx* zc,
+ ZSTD_parameters params, U64 pledgedSrcSize,
+ ZSTD_compResetPolicy_e const crp,
+ ZSTD_buffered_policy_e const zbuff)
{
- if (crp == ZSTDcrp_continue)
- if (ZSTD_equivalentParams(params, zc->params)) {
+ assert(!ZSTD_isError(ZSTD_checkCParams(params.cParams)));
+
+ if (crp == ZSTDcrp_continue) {
+ if (ZSTD_equivalentParams(params.cParams, zc->appliedParams.cParams)) {
+ DEBUGLOG(5, "ZSTD_equivalentParams()==1");
zc->fseCTables_ready = 0;
zc->hufCTable_repeatMode = HUF_repeat_none;
- return ZSTD_continueCCtx(zc, params, frameContentSize);
- }
+ return ZSTD_continueCCtx(zc, params, pledgedSrcSize);
+ } }
- { size_t const blockSize = MIN(ZSTD_BLOCKSIZE_ABSOLUTEMAX, (size_t)1 << params.cParams.windowLog);
+ { size_t const blockSize = MIN(ZSTD_BLOCKSIZE_MAX, (size_t)1 << params.cParams.windowLog);
U32 const divider = (params.cParams.searchLength==3) ? 3 : 4;
size_t const maxNbSeq = blockSize / divider;
size_t const tokenSpace = blockSize + 11*maxNbSeq;
- size_t const chainSize = (params.cParams.strategy == ZSTD_fast) ? 0 : (1 << params.cParams.chainLog);
+ size_t const chainSize = (params.cParams.strategy == ZSTD_fast) ?
+ 0 : (1 << params.cParams.chainLog);
size_t const hSize = ((size_t)1) << params.cParams.hashLog;
- U32 const hashLog3 = (params.cParams.searchLength>3) ? 0 : MIN(ZSTD_HASHLOG3_MAX, params.cParams.windowLog);
+ U32 const hashLog3 = (params.cParams.searchLength>3) ?
+ 0 : MIN(ZSTD_HASHLOG3_MAX, params.cParams.windowLog);
size_t const h3Size = ((size_t)1) << hashLog3;
size_t const tableSpace = (chainSize + hSize + h3Size) * sizeof(U32);
+ size_t const buffOutSize = (zbuff==ZSTDb_buffered) ? ZSTD_compressBound(blockSize)+1 : 0;
+ size_t const buffInSize = (zbuff==ZSTDb_buffered) ? ((size_t)1 << params.cParams.windowLog) + blockSize : 0;
void* ptr;
/* Check if workSpace is large enough, alloc a new one if needed */
@@ -309,9 +667,20 @@ static size_t ZSTD_resetCCtx_internal (ZSTD_CCtx* zc,
+ entropyScratchSpace_size;
size_t const optPotentialSpace = ((MaxML+1) + (MaxLL+1) + (MaxOff+1) + (1<<Litbits)) * sizeof(U32)
+ (ZSTD_OPT_NUM+1) * (sizeof(ZSTD_match_t)+sizeof(ZSTD_optimal_t));
- size_t const optSpace = ((params.cParams.strategy == ZSTD_btopt) || (params.cParams.strategy == ZSTD_btopt2)) ? optPotentialSpace : 0;
- size_t const neededSpace = entropySpace + optSpace + tableSpace + tokenSpace;
- if (zc->workSpaceSize < neededSpace) {
+ size_t const optSpace = ( (params.cParams.strategy == ZSTD_btopt)
+ || (params.cParams.strategy == ZSTD_btultra)) ?
+ optPotentialSpace : 0;
+ size_t const bufferSpace = buffInSize + buffOutSize;
+ size_t const neededSpace = entropySpace + optSpace + tableSpace
+ + tokenSpace + bufferSpace;
+
+ if (zc->workSpaceSize < neededSpace) { /* too small : resize /*/
+ DEBUGLOG(5, "Need to update workSpaceSize from %uK to %uK \n",
+ (unsigned)zc->workSpaceSize>>10,
+ (unsigned)neededSpace>>10);
+ /* static cctx : no resize, error out */
+ if (zc->staticSize) return ERROR(memory_allocation);
+
zc->workSpaceSize = 0;
ZSTD_free(zc->workSpace, zc->customMem);
zc->workSpace = ZSTD_malloc(neededSpace, zc->customMem);
@@ -333,10 +702,14 @@ static size_t ZSTD_resetCCtx_internal (ZSTD_CCtx* zc,
} }
/* init params */
- zc->params = params;
- zc->blockSize = blockSize;
- zc->frameContentSize = frameContentSize;
+ zc->appliedParams = params;
+ zc->pledgedSrcSizePlusOne = pledgedSrcSize+1;
zc->consumedSrcSize = 0;
+ if (pledgedSrcSize == ZSTD_CONTENTSIZE_UNKNOWN)
+ zc->appliedParams.fParams.contentSizeFlag = 0;
+ DEBUGLOG(5, "pledged content size : %u ; flag : %u",
+ (U32)pledgedSrcSize, zc->appliedParams.fParams.contentSizeFlag);
+ zc->blockSize = blockSize;
XXH64_reset(&zc->xxhState, 0);
zc->stage = ZSTDcs_init;
@@ -363,7 +736,8 @@ static size_t ZSTD_resetCCtx_internal (ZSTD_CCtx* zc,
ptr = (char*)zc->entropyScratchSpace + entropyScratchSpace_size;
/* opt parser space */
- if ((params.cParams.strategy == ZSTD_btopt) || (params.cParams.strategy == ZSTD_btopt2)) {
+ if ((params.cParams.strategy == ZSTD_btopt) || (params.cParams.strategy == ZSTD_btultra)) {
+ DEBUGLOG(5, "reserving optimal parser space");
assert(((size_t)ptr & 3) == 0); /* ensure ptr is properly aligned */
zc->seqStore.litFreq = (U32*)ptr;
zc->seqStore.litLengthFreq = zc->seqStore.litFreq + (1<<Litbits);
@@ -391,6 +765,13 @@ static size_t ZSTD_resetCCtx_internal (ZSTD_CCtx* zc,
zc->seqStore.mlCode = zc->seqStore.llCode + maxNbSeq;
zc->seqStore.ofCode = zc->seqStore.mlCode + maxNbSeq;
zc->seqStore.litStart = zc->seqStore.ofCode + maxNbSeq;
+ ptr = zc->seqStore.litStart + blockSize;
+
+ /* buffers */
+ zc->inBuffSize = buffInSize;
+ zc->inBuff = (char*)ptr;
+ zc->outBuffSize = buffOutSize;
+ zc->outBuff = zc->inBuff + buffInSize;
return 0;
}
@@ -411,21 +792,25 @@ void ZSTD_invalidateRepCodes(ZSTD_CCtx* cctx) {
* Only works during stage ZSTDcs_init (i.e. after creation, but before first call to ZSTD_compressContinue()).
* pledgedSrcSize=0 means "empty" if fParams.contentSizeFlag=1
* @return : 0, or an error code */
-size_t ZSTD_copyCCtx_internal(ZSTD_CCtx* dstCCtx, const ZSTD_CCtx* srcCCtx,
- ZSTD_frameParameters fParams, unsigned long long pledgedSrcSize)
+static size_t ZSTD_copyCCtx_internal(ZSTD_CCtx* dstCCtx,
+ const ZSTD_CCtx* srcCCtx,
+ ZSTD_frameParameters fParams,
+ unsigned long long pledgedSrcSize,
+ ZSTD_buffered_policy_e zbuff)
{
+ DEBUGLOG(5, "ZSTD_copyCCtx_internal");
if (srcCCtx->stage!=ZSTDcs_init) return ERROR(stage_wrong);
memcpy(&dstCCtx->customMem, &srcCCtx->customMem, sizeof(ZSTD_customMem));
- { ZSTD_parameters params = srcCCtx->params;
+ { ZSTD_parameters params = srcCCtx->appliedParams;
params.fParams = fParams;
- DEBUGLOG(5, "ZSTD_resetCCtx_internal : dictIDFlag : %u \n", !fParams.noDictIDFlag);
- ZSTD_resetCCtx_internal(dstCCtx, params, pledgedSrcSize, ZSTDcrp_noMemset);
+ ZSTD_resetCCtx_internal(dstCCtx, params, pledgedSrcSize,
+ ZSTDcrp_noMemset, zbuff);
}
/* copy tables */
- { size_t const chainSize = (srcCCtx->params.cParams.strategy == ZSTD_fast) ? 0 : (1 << srcCCtx->params.cParams.chainLog);
- size_t const hSize = (size_t)1 << srcCCtx->params.cParams.hashLog;
+ { size_t const chainSize = (srcCCtx->appliedParams.cParams.strategy == ZSTD_fast) ? 0 : (1 << srcCCtx->appliedParams.cParams.chainLog);
+ size_t const hSize = (size_t)1 << srcCCtx->appliedParams.cParams.hashLog;
size_t const h3Size = (size_t)1 << srcCCtx->hashLog3;
size_t const tableSpace = (chainSize + hSize + h3Size) * sizeof(U32);
assert((U32*)dstCCtx->chainTable == (U32*)dstCCtx->hashTable + hSize); /* chainTable must follow hashTable */
@@ -467,9 +852,11 @@ size_t ZSTD_copyCCtx_internal(ZSTD_CCtx* dstCCtx, const ZSTD_CCtx* srcCCtx,
size_t ZSTD_copyCCtx(ZSTD_CCtx* dstCCtx, const ZSTD_CCtx* srcCCtx, unsigned long long pledgedSrcSize)
{
ZSTD_frameParameters fParams = { 1 /*content*/, 0 /*checksum*/, 0 /*noDictID*/ };
+ ZSTD_buffered_policy_e const zbuff = (ZSTD_buffered_policy_e)(srcCCtx->inBuffSize>0);
+ ZSTD_STATIC_ASSERT((U32)ZSTDb_buffered==1);
fParams.contentSizeFlag = pledgedSrcSize>0;
- return ZSTD_copyCCtx_internal(dstCCtx, srcCCtx, fParams, pledgedSrcSize);
+ return ZSTD_copyCCtx_internal(dstCCtx, srcCCtx, fParams, pledgedSrcSize, zbuff);
}
@@ -488,10 +875,10 @@ static void ZSTD_reduceTable (U32* const table, U32 const size, U32 const reduce
* rescale all indexes to avoid future overflow (indexes are U32) */
static void ZSTD_reduceIndex (ZSTD_CCtx* zc, const U32 reducerValue)
{
- { U32 const hSize = 1 << zc->params.cParams.hashLog;
+ { U32 const hSize = 1 << zc->appliedParams.cParams.hashLog;
ZSTD_reduceTable(zc->hashTable, hSize, reducerValue); }
- { U32 const chainSize = (zc->params.cParams.strategy == ZSTD_fast) ? 0 : (1 << zc->params.cParams.chainLog);
+ { U32 const chainSize = (zc->appliedParams.cParams.strategy == ZSTD_fast) ? 0 : (1 << zc->appliedParams.cParams.chainLog);
ZSTD_reduceTable(zc->chainTable, chainSize, reducerValue); }
{ U32 const h3Size = (zc->hashLog3) ? 1 << zc->hashLog3 : 0;
@@ -529,10 +916,11 @@ static size_t ZSTD_noCompressLiterals (void* dst, size_t dstCapacity, const void
case 2: /* 2 - 2 - 12 */
MEM_writeLE16(ostart, (U16)((U32)set_basic + (1<<2) + (srcSize<<4)));
break;
- default: /*note : should not be necessary : flSize is within {1,2,3} */
case 3: /* 2 - 2 - 20 */
MEM_writeLE32(ostart, (U32)((U32)set_basic + (3<<2) + (srcSize<<4)));
break;
+ default: /* not necessary : flSize is {1,2,3} */
+ assert(0);
}
memcpy(ostart + flSize, src, srcSize);
@@ -554,10 +942,11 @@ static size_t ZSTD_compressRleLiteralsBlock (void* dst, size_t dstCapacity, cons
case 2: /* 2 - 2 - 12 */
MEM_writeLE16(ostart, (U16)((U32)set_rle + (1<<2) + (srcSize<<4)));
break;
- default: /*note : should not be necessary : flSize is necessarily within {1,2,3} */
case 3: /* 2 - 2 - 20 */
MEM_writeLE32(ostart, (U32)((U32)set_rle + (3<<2) + (srcSize<<4)));
break;
+ default: /* not necessary : flSize is {1,2,3} */
+ assert(0);
}
ostart[flSize] = *(const BYTE*)src;
@@ -587,7 +976,7 @@ static size_t ZSTD_compressLiterals (ZSTD_CCtx* zc,
if (dstCapacity < lhSize+1) return ERROR(dstSize_tooSmall); /* not enough space for compression */
{ HUF_repeat repeat = zc->hufCTable_repeatMode;
- int const preferRepeat = zc->params.cParams.strategy < ZSTD_lazy ? srcSize <= 1024 : 0;
+ int const preferRepeat = zc->appliedParams.cParams.strategy < ZSTD_lazy ? srcSize <= 1024 : 0;
if (repeat == HUF_repeat_valid && lhSize == 3) singleStream = 1;
cLitSize = singleStream ? HUF_compress1X_repeat(ostart+lhSize, dstCapacity-lhSize, src, srcSize, 255, 11,
zc->entropyScratchSpace, entropyScratchSpace_size, zc->hufCTable, &repeat, preferRepeat)
@@ -619,13 +1008,14 @@ static size_t ZSTD_compressLiterals (ZSTD_CCtx* zc,
MEM_writeLE32(ostart, lhc);
break;
}
- default: /* should not be necessary, lhSize is only {3,4,5} */
case 5: /* 2 - 2 - 18 - 18 */
{ U32 const lhc = hType + (3 << 2) + ((U32)srcSize<<4) + ((U32)cLitSize<<22);
MEM_writeLE32(ostart, lhc);
ostart[4] = (BYTE)(cLitSize >> 10);
break;
}
+ default: /* not possible : lhSize is {3,4,5} */
+ assert(0);
}
return lhSize+cLitSize;
}
@@ -676,7 +1066,7 @@ MEM_STATIC size_t ZSTD_compressSequences (ZSTD_CCtx* zc,
void* dst, size_t dstCapacity,
size_t srcSize)
{
- const int longOffsets = zc->params.cParams.windowLog > STREAM_ACCUMULATOR_MIN;
+ const int longOffsets = zc->appliedParams.cParams.windowLog > STREAM_ACCUMULATOR_MIN;
const seqStore_t* seqStorePtr = &(zc->seqStore);
U32 count[MaxSeq+1];
S16 norm[MaxSeq+1];
@@ -881,12 +1271,6 @@ _check_compressibility:
return op - ostart;
}
-#if 0 /* for debug */
-# define STORESEQ_DEBUG
-#include <stdio.h> /* fprintf */
-U32 g_startDebug = 0;
-const BYTE* g_start = NULL;
-#endif
/*! ZSTD_storeSeq() :
Store a sequence (literal length, literals, offset code and match length code) into seqStore_t.
@@ -895,16 +1279,16 @@ const BYTE* g_start = NULL;
*/
MEM_STATIC void ZSTD_storeSeq(seqStore_t* seqStorePtr, size_t litLength, const void* literals, U32 offsetCode, size_t matchCode)
{
-#ifdef STORESEQ_DEBUG
- if (g_startDebug) {
- const U32 pos = (U32)((const BYTE*)literals - g_start);
- if (g_start==NULL) g_start = (const BYTE*)literals;
- if ((pos > 1895000) && (pos < 1895300))
- DEBUGLOG(5, "Cpos %6u :%5u literals & match %3u bytes at distance %6u \n",
- pos, (U32)litLength, (U32)matchCode+MINMATCH, (U32)offsetCode);
- }
+#if defined(ZSTD_DEBUG) && (ZSTD_DEBUG >= 6)
+ static const BYTE* g_start = NULL;
+ U32 const pos = (U32)((const BYTE*)literals - g_start);
+ if (g_start==NULL) g_start = (const BYTE*)literals;
+ if ((pos > 0) && (pos < 1000000000))
+ DEBUGLOG(6, "Cpos %6u :%5u literals & match %3u bytes at distance %6u",
+ pos, (U32)litLength, (U32)matchCode+MINMATCH, (U32)offsetCode);
#endif
/* copy Literals */
+ assert(seqStorePtr->lit + litLength <= seqStorePtr->litStart + 128 KB);
ZSTD_wildcopy(seqStorePtr->lit, literals, litLength);
seqStorePtr->lit += litLength;
@@ -1078,7 +1462,7 @@ static size_t ZSTD_hashPtr(const void* p, U32 hBits, U32 mls)
static void ZSTD_fillHashTable (ZSTD_CCtx* zc, const void* end, const U32 mls)
{
U32* const hashTable = zc->hashTable;
- U32 const hBits = zc->params.cParams.hashLog;
+ U32 const hBits = zc->appliedParams.cParams.hashLog;
const BYTE* const base = zc->base;
const BYTE* ip = base + zc->nextToUpdate;
const BYTE* const iend = ((const BYTE*)end) - HASH_READ_SIZE;
@@ -1097,7 +1481,7 @@ void ZSTD_compressBlock_fast_generic(ZSTD_CCtx* cctx,
const U32 mls)
{
U32* const hashTable = cctx->hashTable;
- U32 const hBits = cctx->params.cParams.hashLog;
+ U32 const hBits = cctx->appliedParams.cParams.hashLog;
seqStore_t* seqStorePtr = &(cctx->seqStore);
const BYTE* const base = cctx->base;
const BYTE* const istart = (const BYTE*)src;
@@ -1182,7 +1566,7 @@ void ZSTD_compressBlock_fast_generic(ZSTD_CCtx* cctx,
static void ZSTD_compressBlock_fast(ZSTD_CCtx* ctx,
const void* src, size_t srcSize)
{
- const U32 mls = ctx->params.cParams.searchLength;
+ const U32 mls = ctx->appliedParams.cParams.searchLength;
switch(mls)
{
default: /* includes case 3 */
@@ -1203,7 +1587,7 @@ static void ZSTD_compressBlock_fast_extDict_generic(ZSTD_CCtx* ctx,
const U32 mls)
{
U32* hashTable = ctx->hashTable;
- const U32 hBits = ctx->params.cParams.hashLog;
+ const U32 hBits = ctx->appliedParams.cParams.hashLog;
seqStore_t* seqStorePtr = &(ctx->seqStore);
const BYTE* const base = ctx->base;
const BYTE* const dictBase = ctx->dictBase;
@@ -1296,7 +1680,7 @@ static void ZSTD_compressBlock_fast_extDict_generic(ZSTD_CCtx* ctx,
static void ZSTD_compressBlock_fast_extDict(ZSTD_CCtx* ctx,
const void* src, size_t srcSize)
{
- U32 const mls = ctx->params.cParams.searchLength;
+ U32 const mls = ctx->appliedParams.cParams.searchLength;
switch(mls)
{
default: /* includes case 3 */
@@ -1318,9 +1702,9 @@ static void ZSTD_compressBlock_fast_extDict(ZSTD_CCtx* ctx,
static void ZSTD_fillDoubleHashTable (ZSTD_CCtx* cctx, const void* end, const U32 mls)
{
U32* const hashLarge = cctx->hashTable;
- U32 const hBitsL = cctx->params.cParams.hashLog;
+ U32 const hBitsL = cctx->appliedParams.cParams.hashLog;
U32* const hashSmall = cctx->chainTable;
- U32 const hBitsS = cctx->params.cParams.chainLog;
+ U32 const hBitsS = cctx->appliedParams.cParams.chainLog;
const BYTE* const base = cctx->base;
const BYTE* ip = base + cctx->nextToUpdate;
const BYTE* const iend = ((const BYTE*)end) - HASH_READ_SIZE;
@@ -1340,9 +1724,9 @@ void ZSTD_compressBlock_doubleFast_generic(ZSTD_CCtx* cctx,
const U32 mls)
{
U32* const hashLong = cctx->hashTable;
- const U32 hBitsL = cctx->params.cParams.hashLog;
+ const U32 hBitsL = cctx->appliedParams.cParams.hashLog;
U32* const hashSmall = cctx->chainTable;
- const U32 hBitsS = cctx->params.cParams.chainLog;
+ const U32 hBitsS = cctx->appliedParams.cParams.chainLog;
seqStore_t* seqStorePtr = &(cctx->seqStore);
const BYTE* const base = cctx->base;
const BYTE* const istart = (const BYTE*)src;
@@ -1452,7 +1836,7 @@ void ZSTD_compressBlock_doubleFast_generic(ZSTD_CCtx* cctx,
static void ZSTD_compressBlock_doubleFast(ZSTD_CCtx* ctx, const void* src, size_t srcSize)
{
- const U32 mls = ctx->params.cParams.searchLength;
+ const U32 mls = ctx->appliedParams.cParams.searchLength;
switch(mls)
{
default: /* includes case 3 */
@@ -1473,9 +1857,9 @@ static void ZSTD_compressBlock_doubleFast_extDict_generic(ZSTD_CCtx* ctx,
const U32 mls)
{
U32* const hashLong = ctx->hashTable;
- U32 const hBitsL = ctx->params.cParams.hashLog;
+ U32 const hBitsL = ctx->appliedParams.cParams.hashLog;
U32* const hashSmall = ctx->chainTable;
- U32 const hBitsS = ctx->params.cParams.chainLog;
+ U32 const hBitsS = ctx->appliedParams.cParams.chainLog;
seqStore_t* seqStorePtr = &(ctx->seqStore);
const BYTE* const base = ctx->base;
const BYTE* const dictBase = ctx->dictBase;
@@ -1602,7 +1986,7 @@ static void ZSTD_compressBlock_doubleFast_extDict_generic(ZSTD_CCtx* ctx,
static void ZSTD_compressBlock_doubleFast_extDict(ZSTD_CCtx* ctx,
const void* src, size_t srcSize)
{
- U32 const mls = ctx->params.cParams.searchLength;
+ U32 const mls = ctx->appliedParams.cParams.searchLength;
switch(mls)
{
default: /* includes case 3 */
@@ -1628,10 +2012,10 @@ static U32 ZSTD_insertBt1(ZSTD_CCtx* zc, const BYTE* const ip, const U32 mls, co
U32 extDict)
{
U32* const hashTable = zc->hashTable;
- U32 const hashLog = zc->params.cParams.hashLog;
+ U32 const hashLog = zc->appliedParams.cParams.hashLog;
size_t const h = ZSTD_hashPtr(ip, hashLog, mls);
U32* const bt = zc->chainTable;
- U32 const btLog = zc->params.cParams.chainLog - 1;
+ U32 const btLog = zc->appliedParams.cParams.chainLog - 1;
U32 const btMask = (1 << btLog) - 1;
U32 matchIndex = hashTable[h];
size_t commonLengthSmaller=0, commonLengthLarger=0;
@@ -1733,10 +2117,10 @@ static size_t ZSTD_insertBtAndFindBestMatch (
U32 extDict)
{
U32* const hashTable = zc->hashTable;
- U32 const hashLog = zc->params.cParams.hashLog;
+ U32 const hashLog = zc->appliedParams.cParams.hashLog;
size_t const h = ZSTD_hashPtr(ip, hashLog, mls);
U32* const bt = zc->chainTable;
- U32 const btLog = zc->params.cParams.chainLog - 1;
+ U32 const btLog = zc->appliedParams.cParams.chainLog - 1;
U32 const btMask = (1 << btLog) - 1;
U32 matchIndex = hashTable[h];
size_t commonLengthSmaller=0, commonLengthLarger=0;
@@ -1896,9 +2280,9 @@ FORCE_INLINE
U32 ZSTD_insertAndFindFirstIndex (ZSTD_CCtx* zc, const BYTE* ip, U32 mls)
{
U32* const hashTable = zc->hashTable;
- const U32 hashLog = zc->params.cParams.hashLog;
+ const U32 hashLog = zc->appliedParams.cParams.hashLog;
U32* const chainTable = zc->chainTable;
- const U32 chainMask = (1 << zc->params.cParams.chainLog) - 1;
+ const U32 chainMask = (1 << zc->appliedParams.cParams.chainLog) - 1;
const BYTE* const base = zc->base;
const U32 target = (U32)(ip - base);
U32 idx = zc->nextToUpdate;
@@ -1915,8 +2299,8 @@ U32 ZSTD_insertAndFindFirstIndex (ZSTD_CCtx* zc, const BYTE* ip, U32 mls)
}
-
-FORCE_INLINE /* inlining is important to hardwire a hot branch (template emulation) */
+/* inlining is important to hardwire a hot branch (template emulation) */
+FORCE_INLINE
size_t ZSTD_HcFindBestMatch_generic (
ZSTD_CCtx* zc, /* Index table will be updated */
const BYTE* const ip, const BYTE* const iLimit,
@@ -1924,7 +2308,7 @@ size_t ZSTD_HcFindBestMatch_generic (
const U32 maxNbAttempts, const U32 mls, const U32 extDict)
{
U32* const chainTable = zc->chainTable;
- const U32 chainSize = (1 << zc->params.cParams.chainLog);
+ const U32 chainSize = (1 << zc->appliedParams.cParams.chainLog);
const U32 chainMask = chainSize-1;
const BYTE* const base = zc->base;
const BYTE* const dictBase = zc->dictBase;
@@ -2018,8 +2402,8 @@ void ZSTD_compressBlock_lazy_generic(ZSTD_CCtx* ctx,
const BYTE* const ilimit = iend - 8;
const BYTE* const base = ctx->base + ctx->dictLimit;
- U32 const maxSearches = 1 << ctx->params.cParams.searchLog;
- U32 const mls = ctx->params.cParams.searchLength;
+ U32 const maxSearches = 1 << ctx->appliedParams.cParams.searchLog;
+ U32 const mls = ctx->appliedParams.cParams.searchLength;
typedef size_t (*searchMax_f)(ZSTD_CCtx* zc, const BYTE* ip, const BYTE* iLimit,
size_t* offsetPtr,
@@ -2101,15 +2485,19 @@ void ZSTD_compressBlock_lazy_generic(ZSTD_CCtx* ctx,
break; /* nothing found : store previous solution */
}
+ /* NOTE:
+ * start[-offset+ZSTD_REP_MOVE-1] is undefined behavior.
+ * (-offset+ZSTD_REP_MOVE-1) is unsigned, and is added to start, which
+ * overflows the pointer, which is undefined behavior.
+ */
/* catch up */
if (offset) {
while ( (start > anchor)
&& (start > base+offset-ZSTD_REP_MOVE)
- && (start[-1] == start[-1-offset+ZSTD_REP_MOVE]) ) /* only search for offset within prefix */
+ && (start[-1] == (start-offset+ZSTD_REP_MOVE)[-1]) ) /* only search for offset within prefix */
{ start--; matchLength++; }
offset_2 = offset_1; offset_1 = (U32)(offset - ZSTD_REP_MOVE);
}
-
/* store sequence */
_storeSequence:
{ size_t const litLength = start - anchor;
@@ -2182,8 +2570,8 @@ void ZSTD_compressBlock_lazy_extDict_generic(ZSTD_CCtx* ctx,
const BYTE* const dictEnd = dictBase + dictLimit;
const BYTE* const dictStart = dictBase + ctx->lowLimit;
- const U32 maxSearches = 1 << ctx->params.cParams.searchLog;
- const U32 mls = ctx->params.cParams.searchLength;
+ const U32 maxSearches = 1 << ctx->appliedParams.cParams.searchLog;
+ const U32 mls = ctx->appliedParams.cParams.searchLength;
typedef size_t (*searchMax_f)(ZSTD_CCtx* zc, const BYTE* ip, const BYTE* iLimit,
size_t* offsetPtr,
@@ -2370,7 +2758,7 @@ static void ZSTD_compressBlock_btopt(ZSTD_CCtx* ctx, const void* src, size_t src
#endif
}
-static void ZSTD_compressBlock_btopt2(ZSTD_CCtx* ctx, const void* src, size_t srcSize)
+static void ZSTD_compressBlock_btultra(ZSTD_CCtx* ctx, const void* src, size_t srcSize)
{
#ifdef ZSTD_OPT_H_91842398743
ZSTD_compressBlock_opt_generic(ctx, src, srcSize, 1);
@@ -2390,7 +2778,7 @@ static void ZSTD_compressBlock_btopt_extDict(ZSTD_CCtx* ctx, const void* src, si
#endif
}
-static void ZSTD_compressBlock_btopt2_extDict(ZSTD_CCtx* ctx, const void* src, size_t srcSize)
+static void ZSTD_compressBlock_btultra_extDict(ZSTD_CCtx* ctx, const void* src, size_t srcSize)
{
#ifdef ZSTD_OPT_H_91842398743
ZSTD_compressBlock_opt_extDict_generic(ctx, src, srcSize, 1);
@@ -2401,26 +2789,32 @@ static void ZSTD_compressBlock_btopt2_extDict(ZSTD_CCtx* ctx, const void* src, s
}
+/* ZSTD_selectBlockCompressor() :
+ * assumption : strat is a valid strategy */
typedef void (*ZSTD_blockCompressor) (ZSTD_CCtx* ctx, const void* src, size_t srcSize);
-
static ZSTD_blockCompressor ZSTD_selectBlockCompressor(ZSTD_strategy strat, int extDict)
{
- static const ZSTD_blockCompressor blockCompressor[2][8] = {
- { ZSTD_compressBlock_fast, ZSTD_compressBlock_doubleFast, ZSTD_compressBlock_greedy,
+ static const ZSTD_blockCompressor blockCompressor[2][(unsigned)ZSTD_btultra+1] = {
+ { ZSTD_compressBlock_fast /* default for 0 */,
+ ZSTD_compressBlock_fast, ZSTD_compressBlock_doubleFast, ZSTD_compressBlock_greedy,
ZSTD_compressBlock_lazy, ZSTD_compressBlock_lazy2, ZSTD_compressBlock_btlazy2,
- ZSTD_compressBlock_btopt, ZSTD_compressBlock_btopt2 },
- { ZSTD_compressBlock_fast_extDict, ZSTD_compressBlock_doubleFast_extDict, ZSTD_compressBlock_greedy_extDict,
+ ZSTD_compressBlock_btopt, ZSTD_compressBlock_btultra },
+ { ZSTD_compressBlock_fast_extDict /* default for 0 */,
+ ZSTD_compressBlock_fast_extDict, ZSTD_compressBlock_doubleFast_extDict, ZSTD_compressBlock_greedy_extDict,
ZSTD_compressBlock_lazy_extDict,ZSTD_compressBlock_lazy2_extDict, ZSTD_compressBlock_btlazy2_extDict,
- ZSTD_compressBlock_btopt_extDict, ZSTD_compressBlock_btopt2_extDict }
+ ZSTD_compressBlock_btopt_extDict, ZSTD_compressBlock_btultra_extDict }
};
+ ZSTD_STATIC_ASSERT((unsigned)ZSTD_fast == 1);
+ assert((U32)strat >= (U32)ZSTD_fast);
+ assert((U32)strat <= (U32)ZSTD_btultra);
- return blockCompressor[extDict][(U32)strat];
+ return blockCompressor[extDict!=0][(U32)strat];
}
static size_t ZSTD_compressBlock_internal(ZSTD_CCtx* zc, void* dst, size_t dstCapacity, const void* src, size_t srcSize)
{
- ZSTD_blockCompressor const blockCompressor = ZSTD_selectBlockCompressor(zc->params.cParams.strategy, zc->lowLimit < zc->dictLimit);
+ ZSTD_blockCompressor const blockCompressor = ZSTD_selectBlockCompressor(zc->appliedParams.cParams.strategy, zc->lowLimit < zc->dictLimit);
const BYTE* const base = zc->base;
const BYTE* const istart = (const BYTE*)src;
const U32 current = (U32)(istart-base);
@@ -2433,14 +2827,14 @@ static size_t ZSTD_compressBlock_internal(ZSTD_CCtx* zc, void* dst, size_t dstCa
}
-/*! ZSTD_compress_generic() :
+/*! ZSTD_compress_frameChunk() :
* Compress a chunk of data into one or multiple blocks.
* All blocks will be terminated, all input will be consumed.
* Function will issue an error if there is not enough `dstCapacity` to hold the compressed content.
* Frame is supposed already started (header already produced)
* @return : compressed size, or an error code
*/
-static size_t ZSTD_compress_generic (ZSTD_CCtx* cctx,
+static size_t ZSTD_compress_frameChunk (ZSTD_CCtx* cctx,
void* dst, size_t dstCapacity,
const void* src, size_t srcSize,
U32 lastFrameChunk)
@@ -2450,9 +2844,9 @@ static size_t ZSTD_compress_generic (ZSTD_CCtx* cctx,
const BYTE* ip = (const BYTE*)src;
BYTE* const ostart = (BYTE*)dst;
BYTE* op = ostart;
- U32 const maxDist = 1 << cctx->params.cParams.windowLog;
+ U32 const maxDist = 1 << cctx->appliedParams.cParams.windowLog;
- if (cctx->params.fParams.checksumFlag && srcSize)
+ if (cctx->appliedParams.fParams.checksumFlag && srcSize)
XXH64_update(&cctx->xxhState, src, srcSize);
while (remaining) {
@@ -2465,9 +2859,9 @@ static size_t ZSTD_compress_generic (ZSTD_CCtx* cctx,
/* preemptive overflow correction */
if (cctx->lowLimit > (3U<<29)) {
- U32 const cycleMask = (1 << ZSTD_cycleLog(cctx->params.cParams.hashLog, cctx->params.cParams.strategy)) - 1;
+ U32 const cycleMask = (1 << ZSTD_cycleLog(cctx->appliedParams.cParams.hashLog, cctx->appliedParams.cParams.strategy)) - 1;
U32 const current = (U32)(ip - cctx->base);
- U32 const newCurrent = (current & cycleMask) + (1 << cctx->params.cParams.windowLog);
+ U32 const newCurrent = (current & cycleMask) + (1 << cctx->appliedParams.cParams.windowLog);
U32 const correction = current - newCurrent;
ZSTD_STATIC_ASSERT(ZSTD_WINDOWLOG_MAX_64 <= 30);
ZSTD_reduceIndex(cctx, correction);
@@ -2522,22 +2916,20 @@ static size_t ZSTD_writeFrameHeader(void* dst, size_t dstCapacity,
U32 const singleSegment = params.fParams.contentSizeFlag && (windowSize >= pledgedSrcSize);
BYTE const windowLogByte = (BYTE)((params.cParams.windowLog - ZSTD_WINDOWLOG_ABSOLUTEMIN) << 3);
U32 const fcsCode = params.fParams.contentSizeFlag ?
- (pledgedSrcSize>=256) + (pledgedSrcSize>=65536+256) + (pledgedSrcSize>=0xFFFFFFFFU) : /* 0-3 */
- 0;
+ (pledgedSrcSize>=256) + (pledgedSrcSize>=65536+256) + (pledgedSrcSize>=0xFFFFFFFFU) : 0; /* 0-3 */
BYTE const frameHeaderDecriptionByte = (BYTE)(dictIDSizeCode + (checksumFlag<<2) + (singleSegment<<5) + (fcsCode<<6) );
size_t pos;
if (dstCapacity < ZSTD_frameHeaderSize_max) return ERROR(dstSize_tooSmall);
- DEBUGLOG(5, "ZSTD_writeFrameHeader : dictIDFlag : %u \n", !params.fParams.noDictIDFlag);
- DEBUGLOG(5, "ZSTD_writeFrameHeader : dictID : %u \n", dictID);
- DEBUGLOG(5, "ZSTD_writeFrameHeader : dictIDSizeCode : %u \n", dictIDSizeCode);
+ DEBUGLOG(5, "ZSTD_writeFrameHeader : dictIDFlag : %u ; dictID : %u ; dictIDSizeCode : %u",
+ !params.fParams.noDictIDFlag, dictID, dictIDSizeCode);
MEM_writeLE32(dst, ZSTD_MAGICNUMBER);
op[4] = frameHeaderDecriptionByte; pos=5;
if (!singleSegment) op[pos++] = windowLogByte;
switch(dictIDSizeCode)
{
- default: /* impossible */
+ default: assert(0); /* impossible */
case 0 : break;
case 1 : op[pos] = (BYTE)(dictID); pos++; break;
case 2 : MEM_writeLE16(op+pos, (U16)dictID); pos+=2; break;
@@ -2545,7 +2937,7 @@ static size_t ZSTD_writeFrameHeader(void* dst, size_t dstCapacity,
}
switch(fcsCode)
{
- default: /* impossible */
+ default: assert(0); /* impossible */
case 0 : if (singleSegment) op[pos++] = (BYTE)(pledgedSrcSize); break;
case 1 : MEM_writeLE16(op+pos, (U16)(pledgedSrcSize-256)); pos+=2; break;
case 2 : MEM_writeLE32(op+pos, (U32)(pledgedSrcSize)); pos+=4; break;
@@ -2563,10 +2955,13 @@ static size_t ZSTD_compressContinue_internal (ZSTD_CCtx* cctx,
const BYTE* const ip = (const BYTE*) src;
size_t fhSize = 0;
+ DEBUGLOG(5, "ZSTD_compressContinue_internal");
+ DEBUGLOG(5, "stage: %u", cctx->stage);
if (cctx->stage==ZSTDcs_created) return ERROR(stage_wrong); /* missing init (ZSTD_compressBegin) */
if (frame && (cctx->stage==ZSTDcs_init)) {
- fhSize = ZSTD_writeFrameHeader(dst, dstCapacity, cctx->params, cctx->frameContentSize, cctx->dictID);
+ fhSize = ZSTD_writeFrameHeader(dst, dstCapacity, cctx->appliedParams,
+ cctx->pledgedSrcSizePlusOne-1, cctx->dictID);
if (ZSTD_isError(fhSize)) return fhSize;
dstCapacity -= fhSize;
dst = (char*)dst + fhSize;
@@ -2596,7 +2991,7 @@ static size_t ZSTD_compressContinue_internal (ZSTD_CCtx* cctx,
if (srcSize) {
size_t const cSize = frame ?
- ZSTD_compress_generic (cctx, dst, dstCapacity, src, srcSize, lastFrameChunk) :
+ ZSTD_compress_frameChunk (cctx, dst, dstCapacity, src, srcSize, lastFrameChunk) :
ZSTD_compressBlock_internal (cctx, dst, dstCapacity, src, srcSize);
if (ZSTD_isError(cSize)) return cSize;
cctx->consumedSrcSize += srcSize;
@@ -2614,14 +3009,18 @@ size_t ZSTD_compressContinue (ZSTD_CCtx* cctx,
}
-size_t ZSTD_getBlockSizeMax(ZSTD_CCtx* cctx)
+size_t ZSTD_getBlockSize(const ZSTD_CCtx* cctx)
{
- return MIN (ZSTD_BLOCKSIZE_ABSOLUTEMAX, 1 << cctx->params.cParams.windowLog);
+ U32 const cLevel = cctx->compressionLevel;
+ ZSTD_compressionParameters cParams = (cLevel == ZSTD_CLEVEL_CUSTOM) ?
+ cctx->appliedParams.cParams :
+ ZSTD_getCParams(cLevel, 0, 0);
+ return MIN (ZSTD_BLOCKSIZE_MAX, 1 << cParams.windowLog);
}
size_t ZSTD_compressBlock(ZSTD_CCtx* cctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize)
{
- size_t const blockSizeMax = ZSTD_getBlockSizeMax(cctx);
+ size_t const blockSizeMax = ZSTD_getBlockSize(cctx);
if (srcSize > blockSizeMax) return ERROR(srcSize_wrong);
return ZSTD_compressContinue_internal(cctx, dst, dstCapacity, src, srcSize, 0 /* frame mode */, 0 /* last chunk */);
}
@@ -2645,32 +3044,32 @@ static size_t ZSTD_loadDictionaryContent(ZSTD_CCtx* zc, const void* src, size_t
zc->nextSrc = iend;
if (srcSize <= HASH_READ_SIZE) return 0;
- switch(zc->params.cParams.strategy)
+ switch(zc->appliedParams.cParams.strategy)
{
case ZSTD_fast:
- ZSTD_fillHashTable (zc, iend, zc->params.cParams.searchLength);
+ ZSTD_fillHashTable (zc, iend, zc->appliedParams.cParams.searchLength);
break;
case ZSTD_dfast:
- ZSTD_fillDoubleHashTable (zc, iend, zc->params.cParams.searchLength);
+ ZSTD_fillDoubleHashTable (zc, iend, zc->appliedParams.cParams.searchLength);
break;
case ZSTD_greedy:
case ZSTD_lazy:
case ZSTD_lazy2:
if (srcSize >= HASH_READ_SIZE)
- ZSTD_insertAndFindFirstIndex(zc, iend-HASH_READ_SIZE, zc->params.cParams.searchLength);
+ ZSTD_insertAndFindFirstIndex(zc, iend-HASH_READ_SIZE, zc->appliedParams.cParams.searchLength);
break;
case ZSTD_btlazy2:
case ZSTD_btopt:
- case ZSTD_btopt2:
+ case ZSTD_btultra:
if (srcSize >= HASH_READ_SIZE)
- ZSTD_updateTree(zc, iend-HASH_READ_SIZE, iend, 1 << zc->params.cParams.searchLog, zc->params.cParams.searchLength);
+ ZSTD_updateTree(zc, iend-HASH_READ_SIZE, iend, 1 << zc->appliedParams.cParams.searchLog, zc->appliedParams.cParams.searchLength);
break;
default:
- return ERROR(GENERIC); /* strategy doesn't exist; impossible */
+ assert(0); /* not possible : not a valid strategy id */
}
zc->nextToUpdate = (U32)(iend - zc->base);
@@ -2710,7 +3109,7 @@ static size_t ZSTD_loadZstdDictionary(ZSTD_CCtx* cctx, const void* dict, size_t
BYTE scratchBuffer[1<<MAX(MLFSELog,LLFSELog)];
dictPtr += 4; /* skip magic number */
- cctx->dictID = cctx->params.fParams.noDictIDFlag ? 0 : MEM_readLE32(dictPtr);
+ cctx->dictID = cctx->appliedParams.fParams.noDictIDFlag ? 0 : MEM_readLE32(dictPtr);
dictPtr += 4;
{ size_t const hufHeaderSize = HUF_readCTable(cctx->hufCTable, 255, dictPtr, dictEnd-dictPtr);
@@ -2781,28 +3180,56 @@ static size_t ZSTD_loadZstdDictionary(ZSTD_CCtx* cctx, const void* dict, size_t
/** ZSTD_compress_insertDictionary() :
* @return : 0, or an error code */
-static size_t ZSTD_compress_insertDictionary(ZSTD_CCtx* cctx, const void* dict, size_t dictSize)
+static size_t ZSTD_compress_insertDictionary(ZSTD_CCtx* cctx,
+ const void* dict, size_t dictSize,
+ ZSTD_dictMode_e dictMode)
{
+ DEBUGLOG(5, "ZSTD_compress_insertDictionary");
if ((dict==NULL) || (dictSize<=8)) return 0;
- /* dict as pure content */
- if ((MEM_readLE32(dict) != ZSTD_DICT_MAGIC) || (cctx->forceRawDict))
+ /* dict restricted modes */
+ if (dictMode==ZSTD_dm_rawContent)
return ZSTD_loadDictionaryContent(cctx, dict, dictSize);
- /* dict as zstd dictionary */
+ if (MEM_readLE32(dict) != ZSTD_MAGIC_DICTIONARY) {
+ if (dictMode == ZSTD_dm_auto) {
+ DEBUGLOG(5, "raw content dictionary detected");
+ return ZSTD_loadDictionaryContent(cctx, dict, dictSize);
+ }
+ if (dictMode == ZSTD_dm_fullDict)
+ return ERROR(dictionary_wrong);
+ assert(0); /* impossible */
+ }
+
+ /* dict as full zstd dictionary */
return ZSTD_loadZstdDictionary(cctx, dict, dictSize);
}
/*! ZSTD_compressBegin_internal() :
-* @return : 0, or an error code */
+ * @return : 0, or an error code */
static size_t ZSTD_compressBegin_internal(ZSTD_CCtx* cctx,
const void* dict, size_t dictSize,
- ZSTD_parameters params, U64 pledgedSrcSize)
+ ZSTD_dictMode_e dictMode,
+ const ZSTD_CDict* cdict,
+ ZSTD_parameters params, U64 pledgedSrcSize,
+ ZSTD_buffered_policy_e zbuff)
{
- ZSTD_compResetPolicy_e const crp = dictSize ? ZSTDcrp_fullReset : ZSTDcrp_continue;
+ DEBUGLOG(4, "ZSTD_compressBegin_internal");
+ DEBUGLOG(4, "dict ? %s", dict ? "dict" : (cdict ? "cdict" : "none"));
+ DEBUGLOG(4, "dictMode : %u", (U32)dictMode);
+ /* params are supposed to be fully validated at this point */
assert(!ZSTD_isError(ZSTD_checkCParams(params.cParams)));
- CHECK_F(ZSTD_resetCCtx_internal(cctx, params, pledgedSrcSize, crp));
- return ZSTD_compress_insertDictionary(cctx, dict, dictSize);
+ assert(!((dict) && (cdict))); /* either dict or cdict, not both */
+
+ if (cdict && cdict->dictContentSize>0) {
+ return ZSTD_copyCCtx_internal(cctx, cdict->refContext,
+ params.fParams, pledgedSrcSize,
+ zbuff);
+ }
+
+ CHECK_F( ZSTD_resetCCtx_internal(cctx, params, pledgedSrcSize,
+ ZSTDcrp_continue, zbuff) );
+ return ZSTD_compress_insertDictionary(cctx, dict, dictSize, dictMode);
}
@@ -2814,14 +3241,16 @@ size_t ZSTD_compressBegin_advanced(ZSTD_CCtx* cctx,
{
/* compression parameters verification and optimization */
CHECK_F(ZSTD_checkCParams(params.cParams));
- return ZSTD_compressBegin_internal(cctx, dict, dictSize, params, pledgedSrcSize);
+ return ZSTD_compressBegin_internal(cctx, dict, dictSize, ZSTD_dm_auto, NULL,
+ params, pledgedSrcSize, ZSTDb_not_buffered);
}
size_t ZSTD_compressBegin_usingDict(ZSTD_CCtx* cctx, const void* dict, size_t dictSize, int compressionLevel)
{
ZSTD_parameters const params = ZSTD_getParams(compressionLevel, 0, dictSize);
- return ZSTD_compressBegin_internal(cctx, dict, dictSize, params, 0);
+ return ZSTD_compressBegin_internal(cctx, dict, dictSize, ZSTD_dm_auto, NULL,
+ params, 0, ZSTDb_not_buffered);
}
@@ -2840,11 +3269,12 @@ static size_t ZSTD_writeEpilogue(ZSTD_CCtx* cctx, void* dst, size_t dstCapacity)
BYTE* op = ostart;
size_t fhSize = 0;
+ DEBUGLOG(5, "ZSTD_writeEpilogue");
if (cctx->stage == ZSTDcs_created) return ERROR(stage_wrong); /* init missing */
/* special case : empty frame */
if (cctx->stage == ZSTDcs_init) {
- fhSize = ZSTD_writeFrameHeader(dst, dstCapacity, cctx->params, 0, 0);
+ fhSize = ZSTD_writeFrameHeader(dst, dstCapacity, cctx->appliedParams, 0, 0);
if (ZSTD_isError(fhSize)) return fhSize;
dstCapacity -= fhSize;
op += fhSize;
@@ -2860,7 +3290,7 @@ static size_t ZSTD_writeEpilogue(ZSTD_CCtx* cctx, void* dst, size_t dstCapacity)
dstCapacity -= ZSTD_blockHeaderSize;
}
- if (cctx->params.fParams.checksumFlag) {
+ if (cctx->appliedParams.fParams.checksumFlag) {
U32 const checksum = (U32) XXH64_digest(&cctx->xxhState);
if (dstCapacity<4) return ERROR(dstSize_tooSmall);
MEM_writeLE32(op, checksum);
@@ -2877,13 +3307,19 @@ size_t ZSTD_compressEnd (ZSTD_CCtx* cctx,
const void* src, size_t srcSize)
{
size_t endResult;
- size_t const cSize = ZSTD_compressContinue_internal(cctx, dst, dstCapacity, src, srcSize, 1 /* frame mode */, 1 /* last chunk */);
+ size_t const cSize = ZSTD_compressContinue_internal(cctx,
+ dst, dstCapacity, src, srcSize,
+ 1 /* frame mode */, 1 /* last chunk */);
if (ZSTD_isError(cSize)) return cSize;
endResult = ZSTD_writeEpilogue(cctx, (char*)dst + cSize, dstCapacity-cSize);
if (ZSTD_isError(endResult)) return endResult;
- if (cctx->params.fParams.contentSizeFlag) { /* control src size */
- if (cctx->frameContentSize != cctx->consumedSrcSize) return ERROR(srcSize_wrong);
- }
+ if (cctx->appliedParams.fParams.contentSizeFlag) { /* control src size */
+ DEBUGLOG(5, "end of frame : controlling src size");
+ if (cctx->pledgedSrcSizePlusOne != cctx->consumedSrcSize+1) {
+ DEBUGLOG(5, "error : pledgedSrcSize = %u, while realSrcSize = %u",
+ (U32)cctx->pledgedSrcSizePlusOne-1, (U32)cctx->consumedSrcSize);
+ return ERROR(srcSize_wrong);
+ } }
return cSize + endResult;
}
@@ -2894,7 +3330,8 @@ static size_t ZSTD_compress_internal (ZSTD_CCtx* cctx,
const void* dict,size_t dictSize,
ZSTD_parameters params)
{
- CHECK_F(ZSTD_compressBegin_internal(cctx, dict, dictSize, params, srcSize));
+ CHECK_F( ZSTD_compressBegin_internal(cctx, dict, dictSize, ZSTD_dm_auto, NULL,
+ params, srcSize, ZSTDb_not_buffered) );
return ZSTD_compressEnd(cctx, dst, dstCapacity, src, srcSize);
}
@@ -2926,25 +3363,36 @@ size_t ZSTD_compress(void* dst, size_t dstCapacity, const void* src, size_t srcS
size_t result;
ZSTD_CCtx ctxBody;
memset(&ctxBody, 0, sizeof(ctxBody));
- memcpy(&ctxBody.customMem, &defaultCustomMem, sizeof(ZSTD_customMem));
+ ctxBody.customMem = ZSTD_defaultCMem;
result = ZSTD_compressCCtx(&ctxBody, dst, dstCapacity, src, srcSize, compressionLevel);
- ZSTD_free(ctxBody.workSpace, defaultCustomMem); /* can't free ctxBody itself, as it's on stack; free only heap content */
+ ZSTD_free(ctxBody.workSpace, ZSTD_defaultCMem); /* can't free ctxBody itself, as it's on stack; free only heap content */
return result;
}
/* ===== Dictionary API ===== */
-struct ZSTD_CDict_s {
- void* dictBuffer;
- const void* dictContent;
- size_t dictContentSize;
- ZSTD_CCtx* refContext;
-}; /* typedef'd tp ZSTD_CDict within "zstd.h" */
+/*! ZSTD_estimateCDictSize_advanced() :
+ * Estimate amount of memory that will be needed to create a dictionary with following arguments */
+size_t ZSTD_estimateCDictSize_advanced(size_t dictSize, ZSTD_compressionParameters cParams, unsigned byReference)
+{
+ DEBUGLOG(5, "sizeof(ZSTD_CDict) : %u", (U32)sizeof(ZSTD_CDict));
+ DEBUGLOG(5, "CCtx estimate : %u", (U32)ZSTD_estimateCCtxSize_advanced(cParams));
+ return sizeof(ZSTD_CDict) + ZSTD_estimateCCtxSize_advanced(cParams)
+ + (byReference ? 0 : dictSize);
+}
+
+size_t ZSTD_estimateCDictSize(size_t dictSize, int compressionLevel)
+{
+ ZSTD_compressionParameters const cParams = ZSTD_getCParams(compressionLevel, 0, dictSize);
+ return ZSTD_estimateCDictSize_advanced(dictSize, cParams, 0);
+}
size_t ZSTD_sizeof_CDict(const ZSTD_CDict* cdict)
{
if (cdict==NULL) return 0; /* support sizeof on NULL */
+ DEBUGLOG(5, "sizeof(*cdict) : %u", (U32)sizeof(*cdict));
+ DEBUGLOG(5, "ZSTD_sizeof_CCtx : %u", (U32)ZSTD_sizeof_CCtx(cdict->refContext));
return ZSTD_sizeof_CCtx(cdict->refContext) + (cdict->dictBuffer ? cdict->dictContentSize : 0) + sizeof(*cdict);
}
@@ -2956,13 +3404,46 @@ static ZSTD_parameters ZSTD_makeParams(ZSTD_compressionParameters cParams, ZSTD_
return params;
}
-ZSTD_CDict* ZSTD_createCDict_advanced(const void* dictBuffer, size_t dictSize, unsigned byReference,
+static size_t ZSTD_initCDict_internal(
+ ZSTD_CDict* cdict,
+ const void* dictBuffer, size_t dictSize,
+ unsigned byReference, ZSTD_dictMode_e dictMode,
+ ZSTD_compressionParameters cParams)
+{
+ DEBUGLOG(5, "ZSTD_initCDict_internal, mode %u", (U32)dictMode);
+ if ((byReference) || (!dictBuffer) || (!dictSize)) {
+ cdict->dictBuffer = NULL;
+ cdict->dictContent = dictBuffer;
+ } else {
+ void* const internalBuffer = ZSTD_malloc(dictSize, cdict->refContext->customMem);
+ cdict->dictBuffer = internalBuffer;
+ cdict->dictContent = internalBuffer;
+ if (!internalBuffer) return ERROR(memory_allocation);
+ memcpy(internalBuffer, dictBuffer, dictSize);
+ }
+ cdict->dictContentSize = dictSize;
+
+ { ZSTD_frameParameters const fParams = { 0 /* contentSizeFlag */,
+ 0 /* checksumFlag */, 0 /* noDictIDFlag */ }; /* dummy */
+ ZSTD_parameters const params = ZSTD_makeParams(cParams, fParams);
+ CHECK_F( ZSTD_compressBegin_internal(cdict->refContext,
+ cdict->dictContent, dictSize, dictMode,
+ NULL,
+ params, ZSTD_CONTENTSIZE_UNKNOWN,
+ ZSTDb_not_buffered) );
+ }
+
+ return 0;
+}
+
+ZSTD_CDict* ZSTD_createCDict_advanced(const void* dictBuffer, size_t dictSize,
+ unsigned byReference, ZSTD_dictMode_e dictMode,
ZSTD_compressionParameters cParams, ZSTD_customMem customMem)
{
- if (!customMem.customAlloc && !customMem.customFree) customMem = defaultCustomMem;
- if (!customMem.customAlloc || !customMem.customFree) return NULL;
+ DEBUGLOG(5, "ZSTD_createCDict_advanced, mode %u", (U32)dictMode);
+ if (!customMem.customAlloc ^ !customMem.customFree) return NULL;
- { ZSTD_CDict* const cdict = (ZSTD_CDict*) ZSTD_malloc(sizeof(ZSTD_CDict), customMem);
+ { ZSTD_CDict* const cdict = (ZSTD_CDict*)ZSTD_malloc(sizeof(ZSTD_CDict), customMem);
ZSTD_CCtx* const cctx = ZSTD_createCCtx_advanced(customMem);
if (!cdict || !cctx) {
@@ -2970,46 +3451,34 @@ ZSTD_CDict* ZSTD_createCDict_advanced(const void* dictBuffer, size_t dictSize, u
ZSTD_freeCCtx(cctx);
return NULL;
}
+ cdict->refContext = cctx;
- if ((byReference) || (!dictBuffer) || (!dictSize)) {
- cdict->dictBuffer = NULL;
- cdict->dictContent = dictBuffer;
- } else {
- void* const internalBuffer = ZSTD_malloc(dictSize, customMem);
- if (!internalBuffer) { ZSTD_free(cctx, customMem); ZSTD_free(cdict, customMem); return NULL; }
- memcpy(internalBuffer, dictBuffer, dictSize);
- cdict->dictBuffer = internalBuffer;
- cdict->dictContent = internalBuffer;
+ if (ZSTD_isError( ZSTD_initCDict_internal(cdict,
+ dictBuffer, dictSize,
+ byReference, dictMode,
+ cParams) )) {
+ ZSTD_freeCDict(cdict);
+ return NULL;
}
- { ZSTD_frameParameters const fParams = { 0 /* contentSizeFlag */, 0 /* checksumFlag */, 0 /* noDictIDFlag */ }; /* dummy */
- ZSTD_parameters const params = ZSTD_makeParams(cParams, fParams);
- size_t const errorCode = ZSTD_compressBegin_advanced(cctx, cdict->dictContent, dictSize, params, 0);
- if (ZSTD_isError(errorCode)) {
- ZSTD_free(cdict->dictBuffer, customMem);
- ZSTD_free(cdict, customMem);
- ZSTD_freeCCtx(cctx);
- return NULL;
- } }
-
- cdict->refContext = cctx;
- cdict->dictContentSize = dictSize;
return cdict;
}
}
ZSTD_CDict* ZSTD_createCDict(const void* dict, size_t dictSize, int compressionLevel)
{
- ZSTD_customMem const allocator = { NULL, NULL, NULL };
ZSTD_compressionParameters cParams = ZSTD_getCParams(compressionLevel, 0, dictSize);
- return ZSTD_createCDict_advanced(dict, dictSize, 0, cParams, allocator);
+ return ZSTD_createCDict_advanced(dict, dictSize,
+ 0 /* byReference */, ZSTD_dm_auto,
+ cParams, ZSTD_defaultCMem);
}
ZSTD_CDict* ZSTD_createCDict_byReference(const void* dict, size_t dictSize, int compressionLevel)
{
- ZSTD_customMem const allocator = { NULL, NULL, NULL };
ZSTD_compressionParameters cParams = ZSTD_getCParams(compressionLevel, 0, dictSize);
- return ZSTD_createCDict_advanced(dict, dictSize, 1, cParams, allocator);
+ return ZSTD_createCDict_advanced(dict, dictSize,
+ 1 /* byReference */, ZSTD_dm_auto,
+ cParams, ZSTD_defaultCMem);
}
size_t ZSTD_freeCDict(ZSTD_CDict* cdict)
@@ -3023,7 +3492,54 @@ size_t ZSTD_freeCDict(ZSTD_CDict* cdict)
}
}
-static ZSTD_parameters ZSTD_getParamsFromCDict(const ZSTD_CDict* cdict) {
+/*! ZSTD_initStaticCDict_advanced() :
+ * Generate a digested dictionary in provided memory area.
+ * workspace: The memory area to emplace the dictionary into.
+ * Provided pointer must 8-bytes aligned.
+ * It must outlive dictionary usage.
+ * workspaceSize: Use ZSTD_estimateCDictSize()
+ * to determine how large workspace must be.
+ * cParams : use ZSTD_getCParams() to transform a compression level
+ * into its relevants cParams.
+ * @return : pointer to ZSTD_CDict*, or NULL if error (size too small)
+ * Note : there is no corresponding "free" function.
+ * Since workspace was allocated externally, it must be freed externally.
+ */
+ZSTD_CDict* ZSTD_initStaticCDict(void* workspace, size_t workspaceSize,
+ const void* dict, size_t dictSize,
+ unsigned byReference, ZSTD_dictMode_e dictMode,
+ ZSTD_compressionParameters cParams)
+{
+ size_t const cctxSize = ZSTD_estimateCCtxSize_advanced(cParams);
+ size_t const neededSize = sizeof(ZSTD_CDict) + (byReference ? 0 : dictSize)
+ + cctxSize;
+ ZSTD_CDict* const cdict = (ZSTD_CDict*) workspace;
+ void* ptr;
+ DEBUGLOG(5, "(size_t)workspace & 7 : %u", (U32)(size_t)workspace & 7);
+ if ((size_t)workspace & 7) return NULL; /* 8-aligned */
+ DEBUGLOG(5, "(workspaceSize < neededSize) : (%u < %u) => %u",
+ (U32)workspaceSize, (U32)neededSize, (U32)(workspaceSize < neededSize));
+ if (workspaceSize < neededSize) return NULL;
+
+ if (!byReference) {
+ memcpy(cdict+1, dict, dictSize);
+ dict = cdict+1;
+ ptr = (char*)workspace + sizeof(ZSTD_CDict) + dictSize;
+ } else {
+ ptr = cdict+1;
+ }
+ cdict->refContext = ZSTD_initStaticCCtx(ptr, cctxSize);
+
+ if (ZSTD_isError( ZSTD_initCDict_internal(cdict,
+ dict, dictSize,
+ 1 /* byReference */, dictMode,
+ cParams) ))
+ return NULL;
+
+ return cdict;
+}
+
+ZSTD_parameters ZSTD_getParamsFromCDict(const ZSTD_CDict* cdict) {
return ZSTD_getParamsFromCCtx(cdict->refContext);
}
@@ -3033,16 +3549,16 @@ size_t ZSTD_compressBegin_usingCDict_advanced(
ZSTD_CCtx* const cctx, const ZSTD_CDict* const cdict,
ZSTD_frameParameters const fParams, unsigned long long const pledgedSrcSize)
{
- if (cdict==NULL) return ERROR(GENERIC); /* does not support NULL cdict */
- DEBUGLOG(5, "ZSTD_compressBegin_usingCDict_advanced : dictIDFlag == %u \n", !fParams.noDictIDFlag);
- if (cdict->dictContentSize)
- CHECK_F( ZSTD_copyCCtx_internal(cctx, cdict->refContext, fParams, pledgedSrcSize) )
- else {
- ZSTD_parameters params = cdict->refContext->params;
+ if (cdict==NULL) return ERROR(dictionary_wrong);
+ { ZSTD_parameters params = cdict->refContext->appliedParams;
params.fParams = fParams;
- CHECK_F(ZSTD_compressBegin_internal(cctx, NULL, 0, params, pledgedSrcSize));
+ DEBUGLOG(5, "ZSTD_compressBegin_usingCDict_advanced");
+ return ZSTD_compressBegin_internal(cctx,
+ NULL, 0, ZSTD_dm_auto,
+ cdict,
+ params, pledgedSrcSize,
+ ZSTDb_not_buffered);
}
- return 0;
}
/* ZSTD_compressBegin_usingCDict() :
@@ -3051,7 +3567,7 @@ size_t ZSTD_compressBegin_usingCDict_advanced(
size_t ZSTD_compressBegin_usingCDict(ZSTD_CCtx* cctx, const ZSTD_CDict* cdict)
{
ZSTD_frameParameters const fParams = { 0 /*content*/, 0 /*checksum*/, 0 /*noDictID*/ };
- DEBUGLOG(5, "ZSTD_compressBegin_usingCDict : dictIDFlag == %u \n", !fParams.noDictIDFlag);
+ DEBUGLOG(5, "ZSTD_compressBegin_usingCDict : dictIDFlag == %u", !fParams.noDictIDFlag);
return ZSTD_compressBegin_usingCDict_advanced(cctx, cdict, fParams, 0);
}
@@ -3084,176 +3600,133 @@ size_t ZSTD_compress_usingCDict(ZSTD_CCtx* cctx,
* Streaming
********************************************************************/
-typedef enum { zcss_init, zcss_load, zcss_flush, zcss_final } ZSTD_cStreamStage;
-
-struct ZSTD_CStream_s {
- ZSTD_CCtx* cctx;
- ZSTD_CDict* cdictLocal;
- const ZSTD_CDict* cdict;
- char* inBuff;
- size_t inBuffSize;
- size_t inToCompress;
- size_t inBuffPos;
- size_t inBuffTarget;
- size_t blockSize;
- char* outBuff;
- size_t outBuffSize;
- size_t outBuffContentSize;
- size_t outBuffFlushedSize;
- ZSTD_cStreamStage stage;
- U32 checksum;
- U32 frameEnded;
- U64 pledgedSrcSize;
- ZSTD_parameters params;
- ZSTD_customMem customMem;
-}; /* typedef'd to ZSTD_CStream within "zstd.h" */
-
ZSTD_CStream* ZSTD_createCStream(void)
{
- return ZSTD_createCStream_advanced(defaultCustomMem);
+ return ZSTD_createCStream_advanced(ZSTD_defaultCMem);
}
-ZSTD_CStream* ZSTD_createCStream_advanced(ZSTD_customMem customMem)
+ZSTD_CStream* ZSTD_initStaticCStream(void *workspace, size_t workspaceSize)
{
- ZSTD_CStream* zcs;
-
- if (!customMem.customAlloc && !customMem.customFree) customMem = defaultCustomMem;
- if (!customMem.customAlloc || !customMem.customFree) return NULL;
+ return ZSTD_initStaticCCtx(workspace, workspaceSize);
+}
- zcs = (ZSTD_CStream*)ZSTD_malloc(sizeof(ZSTD_CStream), customMem);
- if (zcs==NULL) return NULL;
- memset(zcs, 0, sizeof(ZSTD_CStream));
- memcpy(&zcs->customMem, &customMem, sizeof(ZSTD_customMem));
- zcs->cctx = ZSTD_createCCtx_advanced(customMem);
- if (zcs->cctx == NULL) { ZSTD_freeCStream(zcs); return NULL; }
- return zcs;
+ZSTD_CStream* ZSTD_createCStream_advanced(ZSTD_customMem customMem)
+{ /* CStream and CCtx are now same object */
+ return ZSTD_createCCtx_advanced(customMem);
}
size_t ZSTD_freeCStream(ZSTD_CStream* zcs)
{
- if (zcs==NULL) return 0; /* support free on NULL */
- { ZSTD_customMem const cMem = zcs->customMem;
- ZSTD_freeCCtx(zcs->cctx);
- zcs->cctx = NULL;
- ZSTD_freeCDict(zcs->cdictLocal);
- zcs->cdictLocal = NULL;
- ZSTD_free(zcs->inBuff, cMem);
- zcs->inBuff = NULL;
- ZSTD_free(zcs->outBuff, cMem);
- zcs->outBuff = NULL;
- ZSTD_free(zcs, cMem);
- return 0;
- }
+ return ZSTD_freeCCtx(zcs); /* same object */
}
+
/*====== Initialization ======*/
-size_t ZSTD_CStreamInSize(void) { return ZSTD_BLOCKSIZE_ABSOLUTEMAX; }
+size_t ZSTD_CStreamInSize(void) { return ZSTD_BLOCKSIZE_MAX; }
size_t ZSTD_CStreamOutSize(void)
{
- return ZSTD_compressBound(ZSTD_BLOCKSIZE_ABSOLUTEMAX) + ZSTD_blockHeaderSize + 4 /* 32-bits hash */ ;
+ return ZSTD_compressBound(ZSTD_BLOCKSIZE_MAX) + ZSTD_blockHeaderSize + 4 /* 32-bits hash */ ;
}
-static size_t ZSTD_resetCStream_internal(ZSTD_CStream* zcs, unsigned long long pledgedSrcSize)
+static size_t ZSTD_resetCStream_internal(ZSTD_CStream* zcs,
+ const void* dict, size_t dictSize, ZSTD_dictMode_e dictMode,
+ const ZSTD_CDict* cdict,
+ ZSTD_parameters params, unsigned long long pledgedSrcSize)
{
- if (zcs->inBuffSize==0) return ERROR(stage_wrong); /* zcs has not been init at least once => can't reset */
-
- DEBUGLOG(5, "ZSTD_resetCStream_internal : dictIDFlag == %u \n", !zcs->params.fParams.noDictIDFlag);
+ DEBUGLOG(4, "ZSTD_resetCStream_internal");
+ /* params are supposed to be fully validated at this point */
+ assert(!ZSTD_isError(ZSTD_checkCParams(params.cParams)));
+ assert(!((dict) && (cdict))); /* either dict or cdict, not both */
- if (zcs->cdict) CHECK_F(ZSTD_compressBegin_usingCDict_advanced(zcs->cctx, zcs->cdict, zcs->params.fParams, pledgedSrcSize))
- else CHECK_F(ZSTD_compressBegin_internal(zcs->cctx, NULL, 0, zcs->params, pledgedSrcSize));
+ CHECK_F( ZSTD_compressBegin_internal(zcs,
+ dict, dictSize, dictMode,
+ cdict,
+ params, pledgedSrcSize,
+ ZSTDb_buffered) );
zcs->inToCompress = 0;
zcs->inBuffPos = 0;
zcs->inBuffTarget = zcs->blockSize;
zcs->outBuffContentSize = zcs->outBuffFlushedSize = 0;
- zcs->stage = zcss_load;
+ zcs->streamStage = zcss_load;
zcs->frameEnded = 0;
- zcs->pledgedSrcSize = pledgedSrcSize;
return 0; /* ready to go */
}
size_t ZSTD_resetCStream(ZSTD_CStream* zcs, unsigned long long pledgedSrcSize)
{
-
- zcs->params.fParams.contentSizeFlag = (pledgedSrcSize > 0);
- DEBUGLOG(5, "ZSTD_resetCStream : dictIDFlag == %u \n", !zcs->params.fParams.noDictIDFlag);
- return ZSTD_resetCStream_internal(zcs, pledgedSrcSize);
+ ZSTD_parameters params = zcs->requestedParams;
+ params.fParams.contentSizeFlag = (pledgedSrcSize > 0);
+ DEBUGLOG(5, "ZSTD_resetCStream");
+ if (zcs->compressionLevel != ZSTD_CLEVEL_CUSTOM) {
+ params.cParams = ZSTD_getCParams(zcs->compressionLevel, pledgedSrcSize, 0 /* dictSize */);
+ }
+ return ZSTD_resetCStream_internal(zcs, NULL, 0, zcs->dictMode, zcs->cdict, params, pledgedSrcSize);
}
-/* ZSTD_initCStream_internal() :
- * params are supposed validated at this stage
- * and zcs->cdict is supposed to be correct */
-static size_t ZSTD_initCStream_stage2(ZSTD_CStream* zcs,
- const ZSTD_parameters params,
- unsigned long long pledgedSrcSize)
+/*! ZSTD_initCStream_internal() :
+ * Note : not static, but hidden (not exposed). Used by zstdmt_compress.c
+ * Assumption 1 : params are valid
+ * Assumption 2 : either dict, or cdict, is defined, not both */
+size_t ZSTD_initCStream_internal(ZSTD_CStream* zcs,
+ const void* dict, size_t dictSize, const ZSTD_CDict* cdict,
+ ZSTD_parameters params, unsigned long long pledgedSrcSize)
{
+ DEBUGLOG(5, "ZSTD_initCStream_internal");
assert(!ZSTD_isError(ZSTD_checkCParams(params.cParams)));
+ assert(!((dict) && (cdict))); /* either dict or cdict, not both */
- /* allocate buffers */
- { size_t const neededInBuffSize = (size_t)1 << params.cParams.windowLog;
- if (zcs->inBuffSize < neededInBuffSize) {
- zcs->inBuffSize = 0;
- ZSTD_free(zcs->inBuff, zcs->customMem);
- zcs->inBuff = (char*) ZSTD_malloc(neededInBuffSize, zcs->customMem);
- if (zcs->inBuff == NULL) return ERROR(memory_allocation);
- zcs->inBuffSize = neededInBuffSize;
+ if (dict && dictSize >= 8) {
+ DEBUGLOG(5, "loading dictionary of size %u", (U32)dictSize);
+ if (zcs->staticSize) { /* static CCtx : never uses malloc */
+ /* incompatible with internal cdict creation */
+ return ERROR(memory_allocation);
}
- zcs->blockSize = MIN(ZSTD_BLOCKSIZE_ABSOLUTEMAX, neededInBuffSize);
- }
- if (zcs->outBuffSize < ZSTD_compressBound(zcs->blockSize)+1) {
- size_t const outBuffSize = ZSTD_compressBound(zcs->blockSize)+1;
- zcs->outBuffSize = 0;
- ZSTD_free(zcs->outBuff, zcs->customMem);
- zcs->outBuff = (char*) ZSTD_malloc(outBuffSize, zcs->customMem);
- if (zcs->outBuff == NULL) return ERROR(memory_allocation);
- zcs->outBuffSize = outBuffSize;
+ ZSTD_freeCDict(zcs->cdictLocal);
+ zcs->cdictLocal = ZSTD_createCDict_advanced(dict, dictSize,
+ zcs->dictContentByRef, zcs->dictMode,
+ params.cParams, zcs->customMem);
+ zcs->cdict = zcs->cdictLocal;
+ if (zcs->cdictLocal == NULL) return ERROR(memory_allocation);
+ } else {
+ if (cdict) {
+ ZSTD_parameters const cdictParams = ZSTD_getParamsFromCDict(cdict);
+ params.cParams = cdictParams.cParams; /* cParams are enforced from cdict */
+ }
+ ZSTD_freeCDict(zcs->cdictLocal);
+ zcs->cdictLocal = NULL;
+ zcs->cdict = cdict;
}
- zcs->checksum = params.fParams.checksumFlag > 0;
- zcs->params = params;
-
- DEBUGLOG(5, "ZSTD_initCStream_stage2 : dictIDFlag == %u \n", !params.fParams.noDictIDFlag);
- return ZSTD_resetCStream_internal(zcs, pledgedSrcSize);
+ zcs->requestedParams = params;
+ zcs->compressionLevel = ZSTD_CLEVEL_CUSTOM;
+ return ZSTD_resetCStream_internal(zcs, NULL, 0, zcs->dictMode, zcs->cdict, params, pledgedSrcSize);
}
/* ZSTD_initCStream_usingCDict_advanced() :
* same as ZSTD_initCStream_usingCDict(), with control over frame parameters */
-size_t ZSTD_initCStream_usingCDict_advanced(ZSTD_CStream* zcs, const ZSTD_CDict* cdict, unsigned long long pledgedSrcSize, ZSTD_frameParameters fParams)
-{
- if (!cdict) return ERROR(GENERIC); /* cannot handle NULL cdict (does not know what to do) */
+size_t ZSTD_initCStream_usingCDict_advanced(ZSTD_CStream* zcs,
+ const ZSTD_CDict* cdict,
+ ZSTD_frameParameters fParams,
+ unsigned long long pledgedSrcSize)
+{ /* cannot handle NULL cdict (does not know what to do) */
+ if (!cdict) return ERROR(dictionary_wrong);
{ ZSTD_parameters params = ZSTD_getParamsFromCDict(cdict);
params.fParams = fParams;
- zcs->cdict = cdict;
- return ZSTD_initCStream_stage2(zcs, params, pledgedSrcSize);
+ return ZSTD_initCStream_internal(zcs,
+ NULL, 0, cdict,
+ params, pledgedSrcSize);
}
}
/* note : cdict must outlive compression session */
size_t ZSTD_initCStream_usingCDict(ZSTD_CStream* zcs, const ZSTD_CDict* cdict)
{
- ZSTD_frameParameters const fParams = { 0 /* content */, 0 /* checksum */, 0 /* noDictID */ };
- return ZSTD_initCStream_usingCDict_advanced(zcs, cdict, 0, fParams);
-}
-
-static size_t ZSTD_initCStream_internal(ZSTD_CStream* zcs,
- const void* dict, size_t dictSize,
- ZSTD_parameters params, unsigned long long pledgedSrcSize)
-{
- assert(!ZSTD_isError(ZSTD_checkCParams(params.cParams)));
- zcs->cdict = NULL;
-
- if (dict && dictSize >= 8) {
- ZSTD_freeCDict(zcs->cdictLocal);
- zcs->cdictLocal = ZSTD_createCDict_advanced(dict, dictSize, 0 /* copy */, params.cParams, zcs->customMem);
- if (zcs->cdictLocal == NULL) return ERROR(memory_allocation);
- zcs->cdict = zcs->cdictLocal;
- }
-
- DEBUGLOG(5, "ZSTD_initCStream_internal : dictIDFlag == %u \n", !params.fParams.noDictIDFlag);
- return ZSTD_initCStream_stage2(zcs, params, pledgedSrcSize);
+ ZSTD_frameParameters const fParams = { 0 /* contentSize */, 0 /* checksum */, 0 /* hideDictID */ };
+ return ZSTD_initCStream_usingCDict_advanced(zcs, cdict, fParams, 0); /* note : will check that cdict != NULL */
}
size_t ZSTD_initCStream_advanced(ZSTD_CStream* zcs,
@@ -3261,120 +3734,180 @@ size_t ZSTD_initCStream_advanced(ZSTD_CStream* zcs,
ZSTD_parameters params, unsigned long long pledgedSrcSize)
{
CHECK_F( ZSTD_checkCParams(params.cParams) );
- DEBUGLOG(5, "ZSTD_initCStream_advanced : dictIDFlag == %u \n", !params.fParams.noDictIDFlag);
- return ZSTD_initCStream_internal(zcs, dict, dictSize, params, pledgedSrcSize);
+ zcs->requestedParams = params;
+ zcs->compressionLevel = ZSTD_CLEVEL_CUSTOM;
+ return ZSTD_initCStream_internal(zcs, dict, dictSize, NULL, params, pledgedSrcSize);
}
size_t ZSTD_initCStream_usingDict(ZSTD_CStream* zcs, const void* dict, size_t dictSize, int compressionLevel)
{
ZSTD_parameters const params = ZSTD_getParams(compressionLevel, 0, dictSize);
- return ZSTD_initCStream_internal(zcs, dict, dictSize, params, 0);
+ zcs->compressionLevel = compressionLevel;
+ return ZSTD_initCStream_internal(zcs, dict, dictSize, NULL, params, 0);
}
size_t ZSTD_initCStream_srcSize(ZSTD_CStream* zcs, int compressionLevel, unsigned long long pledgedSrcSize)
{
ZSTD_parameters params = ZSTD_getParams(compressionLevel, pledgedSrcSize, 0);
params.fParams.contentSizeFlag = (pledgedSrcSize>0);
- return ZSTD_initCStream_internal(zcs, NULL, 0, params, pledgedSrcSize);
+ return ZSTD_initCStream_internal(zcs, NULL, 0, NULL, params, pledgedSrcSize);
}
size_t ZSTD_initCStream(ZSTD_CStream* zcs, int compressionLevel)
{
ZSTD_parameters const params = ZSTD_getParams(compressionLevel, 0, 0);
- return ZSTD_initCStream_internal(zcs, NULL, 0, params, 0);
-}
-
-size_t ZSTD_sizeof_CStream(const ZSTD_CStream* zcs)
-{
- if (zcs==NULL) return 0; /* support sizeof on NULL */
- return sizeof(*zcs) + ZSTD_sizeof_CCtx(zcs->cctx) + ZSTD_sizeof_CDict(zcs->cdictLocal) + zcs->outBuffSize + zcs->inBuffSize;
+ return ZSTD_initCStream_internal(zcs, NULL, 0, NULL, params, 0);
}
/*====== Compression ======*/
-typedef enum { zsf_gather, zsf_flush, zsf_end } ZSTD_flush_e;
-
-MEM_STATIC size_t ZSTD_limitCopy(void* dst, size_t dstCapacity, const void* src, size_t srcSize)
+MEM_STATIC size_t ZSTD_limitCopy(void* dst, size_t dstCapacity,
+ const void* src, size_t srcSize)
{
size_t const length = MIN(dstCapacity, srcSize);
- memcpy(dst, src, length);
+ if (length) memcpy(dst, src, length);
return length;
}
-static size_t ZSTD_compressStream_generic(ZSTD_CStream* zcs,
- void* dst, size_t* dstCapacityPtr,
- const void* src, size_t* srcSizePtr,
- ZSTD_flush_e const flush)
+/** ZSTD_compressStream_generic():
+ * internal function for all *compressStream*() variants and *compress_generic()
+ * @return : hint size for next input */
+size_t ZSTD_compressStream_generic(ZSTD_CStream* zcs,
+ ZSTD_outBuffer* output,
+ ZSTD_inBuffer* input,
+ ZSTD_EndDirective const flushMode)
{
+ const char* const istart = (const char*)input->src;
+ const char* const iend = istart + input->size;
+ const char* ip = istart + input->pos;
+ char* const ostart = (char*)output->dst;
+ char* const oend = ostart + output->size;
+ char* op = ostart + output->pos;
U32 someMoreWork = 1;
- const char* const istart = (const char*)src;
- const char* const iend = istart + *srcSizePtr;
- const char* ip = istart;
- char* const ostart = (char*)dst;
- char* const oend = ostart + *dstCapacityPtr;
- char* op = ostart;
+
+ /* check expectations */
+ DEBUGLOG(5, "ZSTD_compressStream_generic, flush=%u", (U32)flushMode);
+ assert(zcs->inBuff != NULL);
+ assert(zcs->inBuffSize>0);
+ assert(zcs->outBuff!= NULL);
+ assert(zcs->outBuffSize>0);
+ assert(output->pos <= output->size);
+ assert(input->pos <= input->size);
while (someMoreWork) {
- switch(zcs->stage)
+ switch(zcs->streamStage)
{
- case zcss_init: return ERROR(init_missing); /* call ZBUFF_compressInit() first ! */
+ case zcss_init:
+ /* call ZSTD_initCStream() first ! */
+ return ERROR(init_missing);
case zcss_load:
- /* complete inBuffer */
+ if ( (flushMode == ZSTD_e_end)
+ && ((size_t)(oend-op) >= ZSTD_compressBound(iend-ip)) /* enough dstCapacity */
+ && (zcs->inBuffPos == 0) ) {
+ /* shortcut to compression pass directly into output buffer */
+ size_t const cSize = ZSTD_compressEnd(zcs,
+ op, oend-op, ip, iend-ip);
+ DEBUGLOG(4, "ZSTD_compressEnd : %u", (U32)cSize);
+ if (ZSTD_isError(cSize)) return cSize;
+ ip = iend;
+ op += cSize;
+ zcs->frameEnded = 1;
+ ZSTD_startNewCompression(zcs);
+ someMoreWork = 0; break;
+ }
+ /* complete loading into inBuffer */
{ size_t const toLoad = zcs->inBuffTarget - zcs->inBuffPos;
- size_t const loaded = ZSTD_limitCopy(zcs->inBuff + zcs->inBuffPos, toLoad, ip, iend-ip);
+ size_t const loaded = ZSTD_limitCopy(
+ zcs->inBuff + zcs->inBuffPos, toLoad,
+ ip, iend-ip);
zcs->inBuffPos += loaded;
ip += loaded;
- if ( (zcs->inBuffPos==zcs->inToCompress) || (!flush && (toLoad != loaded)) ) {
- someMoreWork = 0; break; /* not enough input to get a full block : stop there, wait for more */
- } }
+ if ( (flushMode == ZSTD_e_continue)
+ && (zcs->inBuffPos < zcs->inBuffTarget) ) {
+ /* not enough input to fill full block : stop here */
+ someMoreWork = 0; break;
+ }
+ if ( (flushMode == ZSTD_e_flush)
+ && (zcs->inBuffPos == zcs->inToCompress) ) {
+ /* empty */
+ someMoreWork = 0; break;
+ }
+ }
/* compress current block (note : this stage cannot be stopped in the middle) */
+ DEBUGLOG(5, "stream compression stage (flushMode==%u)", flushMode);
{ void* cDst;
size_t cSize;
size_t const iSize = zcs->inBuffPos - zcs->inToCompress;
size_t oSize = oend-op;
+ unsigned const lastBlock = (flushMode == ZSTD_e_end) && (ip==iend);
if (oSize >= ZSTD_compressBound(iSize))
- cDst = op; /* compress directly into output buffer (avoid flush stage) */
+ cDst = op; /* compress into output buffer, to skip flush stage */
else
cDst = zcs->outBuff, oSize = zcs->outBuffSize;
- cSize = (flush == zsf_end) ?
- ZSTD_compressEnd(zcs->cctx, cDst, oSize, zcs->inBuff + zcs->inToCompress, iSize) :
- ZSTD_compressContinue(zcs->cctx, cDst, oSize, zcs->inBuff + zcs->inToCompress, iSize);
+ cSize = lastBlock ?
+ ZSTD_compressEnd(zcs, cDst, oSize,
+ zcs->inBuff + zcs->inToCompress, iSize) :
+ ZSTD_compressContinue(zcs, cDst, oSize,
+ zcs->inBuff + zcs->inToCompress, iSize);
if (ZSTD_isError(cSize)) return cSize;
- if (flush == zsf_end) zcs->frameEnded = 1;
+ zcs->frameEnded = lastBlock;
/* prepare next block */
zcs->inBuffTarget = zcs->inBuffPos + zcs->blockSize;
if (zcs->inBuffTarget > zcs->inBuffSize)
- zcs->inBuffPos = 0, zcs->inBuffTarget = zcs->blockSize; /* note : inBuffSize >= blockSize */
+ zcs->inBuffPos = 0, zcs->inBuffTarget = zcs->blockSize;
+ DEBUGLOG(5, "inBuffTarget:%u / inBuffSize:%u",
+ (U32)zcs->inBuffTarget, (U32)zcs->inBuffSize);
+ if (!lastBlock)
+ assert(zcs->inBuffTarget <= zcs->inBuffSize);
zcs->inToCompress = zcs->inBuffPos;
- if (cDst == op) { op += cSize; break; } /* no need to flush */
+ if (cDst == op) { /* no need to flush */
+ op += cSize;
+ if (zcs->frameEnded) {
+ DEBUGLOG(5, "Frame completed directly in outBuffer");
+ someMoreWork = 0;
+ ZSTD_startNewCompression(zcs);
+ }
+ break;
+ }
zcs->outBuffContentSize = cSize;
zcs->outBuffFlushedSize = 0;
- zcs->stage = zcss_flush; /* pass-through to flush stage */
+ zcs->streamStage = zcss_flush; /* pass-through to flush stage */
}
-
+ /* fall-through */
case zcss_flush:
+ DEBUGLOG(5, "flush stage");
{ size_t const toFlush = zcs->outBuffContentSize - zcs->outBuffFlushedSize;
- size_t const flushed = ZSTD_limitCopy(op, oend-op, zcs->outBuff + zcs->outBuffFlushedSize, toFlush);
+ size_t const flushed = ZSTD_limitCopy(op, oend-op,
+ zcs->outBuff + zcs->outBuffFlushedSize, toFlush);
+ DEBUGLOG(5, "toFlush: %u into %u ==> flushed: %u",
+ (U32)toFlush, (U32)(oend-op), (U32)flushed);
op += flushed;
zcs->outBuffFlushedSize += flushed;
- if (toFlush!=flushed) { someMoreWork = 0; break; } /* dst too small to store flushed data : stop there */
+ if (toFlush!=flushed) {
+ /* flush not fully completed, presumably because dst is too small */
+ assert(op==oend);
+ someMoreWork = 0;
+ break;
+ }
zcs->outBuffContentSize = zcs->outBuffFlushedSize = 0;
- zcs->stage = zcss_load;
+ if (zcs->frameEnded) {
+ DEBUGLOG(5, "Frame completed on flush");
+ someMoreWork = 0;
+ ZSTD_startNewCompression(zcs);
+ break;
+ }
+ zcs->streamStage = zcss_load;
break;
}
- case zcss_final:
- someMoreWork = 0; /* do nothing */
- break;
-
- default:
- return ERROR(GENERIC); /* impossible */
+ default: /* impossible */
+ assert(0);
}
}
- *srcSizePtr = ip - istart;
- *dstCapacityPtr = op - ostart;
+ input->pos = ip - istart;
+ output->pos = op - ostart;
if (zcs->frameEnded) return 0;
{ size_t hintInSize = zcs->inBuffTarget - zcs->inBuffPos;
if (hintInSize==0) hintInSize = zcs->blockSize;
@@ -3384,14 +3917,86 @@ static size_t ZSTD_compressStream_generic(ZSTD_CStream* zcs,
size_t ZSTD_compressStream(ZSTD_CStream* zcs, ZSTD_outBuffer* output, ZSTD_inBuffer* input)
{
- size_t sizeRead = input->size - input->pos;
- size_t sizeWritten = output->size - output->pos;
- size_t const result = ZSTD_compressStream_generic(zcs,
- (char*)(output->dst) + output->pos, &sizeWritten,
- (const char*)(input->src) + input->pos, &sizeRead, zsf_gather);
- input->pos += sizeRead;
- output->pos += sizeWritten;
- return result;
+ /* check conditions */
+ if (output->pos > output->size) return ERROR(GENERIC);
+ if (input->pos > input->size) return ERROR(GENERIC);
+
+ return ZSTD_compressStream_generic(zcs, output, input, ZSTD_e_continue);
+}
+
+/*! ZSTDMT_initCStream_internal() :
+ * Private use only. Init streaming operation.
+ * expects params to be valid.
+ * must receive dict, or cdict, or none, but not both.
+ * @return : 0, or an error code */
+size_t ZSTDMT_initCStream_internal(ZSTDMT_CCtx* zcs,
+ const void* dict, size_t dictSize, const ZSTD_CDict* cdict,
+ ZSTD_parameters params, unsigned long long pledgedSrcSize);
+
+
+size_t ZSTD_compress_generic (ZSTD_CCtx* cctx,
+ ZSTD_outBuffer* output,
+ ZSTD_inBuffer* input,
+ ZSTD_EndDirective endOp)
+{
+ /* check conditions */
+ if (output->pos > output->size) return ERROR(GENERIC);
+ if (input->pos > input->size) return ERROR(GENERIC);
+ assert(cctx!=NULL);
+
+ /* transparent initialization stage */
+ if (cctx->streamStage == zcss_init) {
+ const void* const prefix = cctx->prefix;
+ size_t const prefixSize = cctx->prefixSize;
+ ZSTD_parameters params = cctx->requestedParams;
+ if (cctx->compressionLevel != ZSTD_CLEVEL_CUSTOM)
+ params.cParams = ZSTD_getCParams(cctx->compressionLevel,
+ cctx->pledgedSrcSizePlusOne-1, 0 /*dictSize*/);
+ cctx->prefix = NULL; cctx->prefixSize = 0; /* single usage */
+ assert(prefix==NULL || cctx->cdict==NULL); /* only one can be set */
+
+#ifdef ZSTD_MULTITHREAD
+ if (cctx->nbThreads > 1) {
+ DEBUGLOG(4, "call ZSTDMT_initCStream_internal as nbThreads=%u", cctx->nbThreads);
+ CHECK_F( ZSTDMT_initCStream_internal(cctx->mtctx, prefix, prefixSize, cctx->cdict, params, cctx->pledgedSrcSizePlusOne-1) );
+ cctx->streamStage = zcss_load;
+ } else
+#endif
+ {
+ CHECK_F( ZSTD_resetCStream_internal(cctx, prefix, prefixSize, cctx->dictMode, cctx->cdict, params, cctx->pledgedSrcSizePlusOne-1) );
+ } }
+
+ /* compression stage */
+#ifdef ZSTD_MULTITHREAD
+ if (cctx->nbThreads > 1) {
+ size_t const flushMin = ZSTDMT_compressStream_generic(cctx->mtctx, output, input, endOp);
+ DEBUGLOG(5, "ZSTDMT_compressStream_generic : %u", (U32)flushMin);
+ if ( ZSTD_isError(flushMin)
+ || (endOp == ZSTD_e_end && flushMin == 0) ) { /* compression completed */
+ ZSTD_startNewCompression(cctx);
+ }
+ return flushMin;
+ }
+#endif
+
+ CHECK_F( ZSTD_compressStream_generic(cctx, output, input, endOp) );
+ DEBUGLOG(5, "completed ZSTD_compress_generic");
+ return cctx->outBuffContentSize - cctx->outBuffFlushedSize; /* remaining to flush */
+}
+
+size_t ZSTD_compress_generic_simpleArgs (
+ ZSTD_CCtx* cctx,
+ void* dst, size_t dstCapacity, size_t* dstPos,
+ const void* src, size_t srcSize, size_t* srcPos,
+ ZSTD_EndDirective endOp)
+{
+ ZSTD_outBuffer output = { dst, dstCapacity, *dstPos };
+ ZSTD_inBuffer input = { src, srcSize, *srcPos };
+ /* ZSTD_compress_generic() will check validity of dstPos and srcPos */
+ size_t const cErr = ZSTD_compress_generic(cctx, &output, &input, endOp);
+ *dstPos = output.pos;
+ *srcPos = input.pos;
+ return cErr;
}
@@ -3401,89 +4006,59 @@ size_t ZSTD_compressStream(ZSTD_CStream* zcs, ZSTD_outBuffer* output, ZSTD_inBuf
* @return : amount of data remaining to flush */
size_t ZSTD_flushStream(ZSTD_CStream* zcs, ZSTD_outBuffer* output)
{
- size_t srcSize = 0;
- size_t sizeWritten = output->size - output->pos;
- size_t const result = ZSTD_compressStream_generic(zcs,
- (char*)(output->dst) + output->pos, &sizeWritten,
- &srcSize, &srcSize, /* use a valid src address instead of NULL */
- zsf_flush);
- output->pos += sizeWritten;
- if (ZSTD_isError(result)) return result;
- return zcs->outBuffContentSize - zcs->outBuffFlushedSize; /* remaining to flush */
+ ZSTD_inBuffer input = { NULL, 0, 0 };
+ if (output->pos > output->size) return ERROR(GENERIC);
+ CHECK_F( ZSTD_compressStream_generic(zcs, output, &input, ZSTD_e_flush) );
+ return zcs->outBuffContentSize - zcs->outBuffFlushedSize; /* remaining to flush */
}
size_t ZSTD_endStream(ZSTD_CStream* zcs, ZSTD_outBuffer* output)
{
- BYTE* const ostart = (BYTE*)(output->dst) + output->pos;
- BYTE* const oend = (BYTE*)(output->dst) + output->size;
- BYTE* op = ostart;
-
- if (zcs->stage != zcss_final) {
- /* flush whatever remains */
- size_t srcSize = 0;
- size_t sizeWritten = output->size - output->pos;
- size_t const notEnded = ZSTD_compressStream_generic(zcs, ostart, &sizeWritten,
- &srcSize /* use a valid src address instead of NULL */, &srcSize, zsf_end);
- size_t const remainingToFlush = zcs->outBuffContentSize - zcs->outBuffFlushedSize;
- op += sizeWritten;
- if (remainingToFlush) {
- output->pos += sizeWritten;
- return remainingToFlush + ZSTD_BLOCKHEADERSIZE /* final empty block */ + (zcs->checksum * 4);
- }
- /* create epilogue */
- zcs->stage = zcss_final;
- zcs->outBuffContentSize = !notEnded ? 0 :
- /* write epilogue, including final empty block, into outBuff */
- ZSTD_compressEnd(zcs->cctx, zcs->outBuff, zcs->outBuffSize, NULL, 0);
- if (ZSTD_isError(zcs->outBuffContentSize)) return zcs->outBuffContentSize;
- }
-
- /* flush epilogue */
- { size_t const toFlush = zcs->outBuffContentSize - zcs->outBuffFlushedSize;
- size_t const flushed = ZSTD_limitCopy(op, oend-op, zcs->outBuff + zcs->outBuffFlushedSize, toFlush);
- op += flushed;
- zcs->outBuffFlushedSize += flushed;
- output->pos += op-ostart;
- if (toFlush==flushed) zcs->stage = zcss_init; /* end reached */
- return toFlush - flushed;
+ ZSTD_inBuffer input = { NULL, 0, 0 };
+ if (output->pos > output->size) return ERROR(GENERIC);
+ CHECK_F( ZSTD_compressStream_generic(zcs, output, &input, ZSTD_e_end) );
+ { size_t const lastBlockSize = zcs->frameEnded ? 0 : ZSTD_BLOCKHEADERSIZE;
+ size_t const checksumSize = zcs->frameEnded ? 0 : zcs->appliedParams.fParams.checksumFlag * 4;
+ size_t const toFlush = zcs->outBuffContentSize - zcs->outBuffFlushedSize + lastBlockSize + checksumSize;
+ DEBUGLOG(5, "ZSTD_endStream : remaining to flush : %u",
+ (unsigned)toFlush);
+ return toFlush;
}
}
-
/*-===== Pre-defined compression levels =====-*/
-#define ZSTD_DEFAULT_CLEVEL 1
#define ZSTD_MAX_CLEVEL 22
int ZSTD_maxCLevel(void) { return ZSTD_MAX_CLEVEL; }
static const ZSTD_compressionParameters ZSTD_defaultCParameters[4][ZSTD_MAX_CLEVEL+1] = {
-{ /* "default" */
+{ /* "default" - guarantees a monotonically increasing memory budget */
/* W, C, H, S, L, TL, strat */
{ 18, 12, 12, 1, 7, 16, ZSTD_fast }, /* level 0 - never used */
{ 19, 13, 14, 1, 7, 16, ZSTD_fast }, /* level 1 */
{ 19, 15, 16, 1, 6, 16, ZSTD_fast }, /* level 2 */
- { 20, 16, 17, 1, 5, 16, ZSTD_dfast }, /* level 3.*/
- { 20, 18, 18, 1, 5, 16, ZSTD_dfast }, /* level 4.*/
- { 20, 15, 18, 3, 5, 16, ZSTD_greedy }, /* level 5 */
- { 21, 16, 19, 2, 5, 16, ZSTD_lazy }, /* level 6 */
- { 21, 17, 20, 3, 5, 16, ZSTD_lazy }, /* level 7 */
+ { 20, 16, 17, 1, 5, 16, ZSTD_dfast }, /* level 3 */
+ { 20, 17, 18, 1, 5, 16, ZSTD_dfast }, /* level 4 */
+ { 20, 17, 18, 2, 5, 16, ZSTD_greedy }, /* level 5 */
+ { 21, 17, 19, 2, 5, 16, ZSTD_lazy }, /* level 6 */
+ { 21, 18, 19, 3, 5, 16, ZSTD_lazy }, /* level 7 */
{ 21, 18, 20, 3, 5, 16, ZSTD_lazy2 }, /* level 8 */
- { 21, 20, 20, 3, 5, 16, ZSTD_lazy2 }, /* level 9 */
+ { 21, 19, 20, 3, 5, 16, ZSTD_lazy2 }, /* level 9 */
{ 21, 19, 21, 4, 5, 16, ZSTD_lazy2 }, /* level 10 */
{ 22, 20, 22, 4, 5, 16, ZSTD_lazy2 }, /* level 11 */
{ 22, 20, 22, 5, 5, 16, ZSTD_lazy2 }, /* level 12 */
{ 22, 21, 22, 5, 5, 16, ZSTD_lazy2 }, /* level 13 */
{ 22, 21, 22, 6, 5, 16, ZSTD_lazy2 }, /* level 14 */
- { 22, 21, 21, 5, 5, 16, ZSTD_btlazy2 }, /* level 15 */
+ { 22, 21, 22, 5, 5, 16, ZSTD_btlazy2 }, /* level 15 */
{ 23, 22, 22, 5, 5, 16, ZSTD_btlazy2 }, /* level 16 */
- { 23, 21, 22, 4, 5, 24, ZSTD_btopt }, /* level 17 */
+ { 23, 22, 22, 4, 5, 24, ZSTD_btopt }, /* level 17 */
{ 23, 22, 22, 5, 4, 32, ZSTD_btopt }, /* level 18 */
{ 23, 23, 22, 6, 3, 48, ZSTD_btopt }, /* level 19 */
- { 25, 25, 23, 7, 3, 64, ZSTD_btopt2 }, /* level 20 */
- { 26, 26, 23, 7, 3,256, ZSTD_btopt2 }, /* level 21 */
- { 27, 27, 25, 9, 3,512, ZSTD_btopt2 }, /* level 22 */
+ { 25, 25, 23, 7, 3, 64, ZSTD_btultra }, /* level 20 */
+ { 26, 26, 24, 7, 3,256, ZSTD_btultra }, /* level 21 */
+ { 27, 27, 25, 9, 3,512, ZSTD_btultra }, /* level 22 */
},
{ /* for srcSize <= 256 KB */
/* W, C, H, S, L, T, strat */
@@ -3507,9 +4082,9 @@ static const ZSTD_compressionParameters ZSTD_defaultCParameters[4][ZSTD_MAX_CLEV
{ 18, 19, 18, 8, 3, 64, ZSTD_btopt }, /* level 17.*/
{ 18, 19, 18, 9, 3,128, ZSTD_btopt }, /* level 18.*/
{ 18, 19, 18, 10, 3,256, ZSTD_btopt }, /* level 19.*/
- { 18, 19, 18, 11, 3,512, ZSTD_btopt2 }, /* level 20.*/
- { 18, 19, 18, 12, 3,512, ZSTD_btopt2 }, /* level 21.*/
- { 18, 19, 18, 13, 3,512, ZSTD_btopt2 }, /* level 22.*/
+ { 18, 19, 18, 11, 3,512, ZSTD_btultra }, /* level 20.*/
+ { 18, 19, 18, 12, 3,512, ZSTD_btultra }, /* level 21.*/
+ { 18, 19, 18, 13, 3,512, ZSTD_btultra }, /* level 22.*/
},
{ /* for srcSize <= 128 KB */
/* W, C, H, S, L, T, strat */
@@ -3533,9 +4108,9 @@ static const ZSTD_compressionParameters ZSTD_defaultCParameters[4][ZSTD_MAX_CLEV
{ 17, 18, 17, 7, 3, 64, ZSTD_btopt }, /* level 17.*/
{ 17, 18, 17, 7, 3,256, ZSTD_btopt }, /* level 18.*/
{ 17, 18, 17, 8, 3,256, ZSTD_btopt }, /* level 19.*/
- { 17, 18, 17, 9, 3,256, ZSTD_btopt2 }, /* level 20.*/
- { 17, 18, 17, 10, 3,256, ZSTD_btopt2 }, /* level 21.*/
- { 17, 18, 17, 11, 3,512, ZSTD_btopt2 }, /* level 22.*/
+ { 17, 18, 17, 9, 3,256, ZSTD_btultra }, /* level 20.*/
+ { 17, 18, 17, 10, 3,256, ZSTD_btultra }, /* level 21.*/
+ { 17, 18, 17, 11, 3,512, ZSTD_btultra }, /* level 22.*/
},
{ /* for srcSize <= 16 KB */
/* W, C, H, S, L, T, strat */
@@ -3559,39 +4134,59 @@ static const ZSTD_compressionParameters ZSTD_defaultCParameters[4][ZSTD_MAX_CLEV
{ 14, 15, 15, 6, 3,128, ZSTD_btopt }, /* level 17.*/
{ 14, 15, 15, 6, 3,256, ZSTD_btopt }, /* level 18.*/
{ 14, 15, 15, 7, 3,256, ZSTD_btopt }, /* level 19.*/
- { 14, 15, 15, 8, 3,256, ZSTD_btopt2 }, /* level 20.*/
- { 14, 15, 15, 9, 3,256, ZSTD_btopt2 }, /* level 21.*/
- { 14, 15, 15, 10, 3,256, ZSTD_btopt2 }, /* level 22.*/
+ { 14, 15, 15, 8, 3,256, ZSTD_btultra }, /* level 20.*/
+ { 14, 15, 15, 9, 3,256, ZSTD_btultra }, /* level 21.*/
+ { 14, 15, 15, 10, 3,256, ZSTD_btultra }, /* level 22.*/
},
};
+#if defined(ZSTD_DEBUG) && (ZSTD_DEBUG>=1)
+/* This function just controls
+ * the monotonic memory budget increase of ZSTD_defaultCParameters[0].
+ * Run once, on first ZSTD_getCParams() usage, if ZSTD_DEBUG is enabled
+ */
+MEM_STATIC void ZSTD_check_compressionLevel_monotonicIncrease_memoryBudget(void)
+{
+ int level;
+ for (level=1; level<ZSTD_maxCLevel(); level++) {
+ ZSTD_compressionParameters const c1 = ZSTD_defaultCParameters[0][level];
+ ZSTD_compressionParameters const c2 = ZSTD_defaultCParameters[0][level+1];
+ assert(c1.windowLog <= c2.windowLog);
+# define ZSTD_TABLECOST(h,c) ((1<<(h)) + (1<<(c)))
+ assert(ZSTD_TABLECOST(c1.hashLog, c1.chainLog) <= ZSTD_TABLECOST(c2.hashLog, c2.chainLog));
+ }
+}
+#endif
+
/*! ZSTD_getCParams() :
* @return ZSTD_compressionParameters structure for a selected compression level, `srcSize` and `dictSize`.
* Size values are optional, provide 0 if not known or unused */
-ZSTD_compressionParameters ZSTD_getCParams(int compressionLevel, unsigned long long srcSize, size_t dictSize)
+ZSTD_compressionParameters ZSTD_getCParams(int compressionLevel, unsigned long long srcSizeHint, size_t dictSize)
{
- ZSTD_compressionParameters cp;
- size_t const addedSize = srcSize ? 0 : 500;
- U64 const rSize = srcSize+dictSize ? srcSize+dictSize+addedSize : (U64)-1;
+ size_t const addedSize = srcSizeHint ? 0 : 500;
+ U64 const rSize = srcSizeHint+dictSize ? srcSizeHint+dictSize+addedSize : (U64)-1;
U32 const tableID = (rSize <= 256 KB) + (rSize <= 128 KB) + (rSize <= 16 KB); /* intentional underflow for srcSizeHint == 0 */
- if (compressionLevel <= 0) compressionLevel = ZSTD_DEFAULT_CLEVEL; /* 0 == default; no negative compressionLevel yet */
- if (compressionLevel > ZSTD_MAX_CLEVEL) compressionLevel = ZSTD_MAX_CLEVEL;
- cp = ZSTD_defaultCParameters[tableID][compressionLevel];
- if (MEM_32bits()) { /* auto-correction, for 32-bits mode */
- if (cp.windowLog > ZSTD_WINDOWLOG_MAX) cp.windowLog = ZSTD_WINDOWLOG_MAX;
- if (cp.chainLog > ZSTD_CHAINLOG_MAX) cp.chainLog = ZSTD_CHAINLOG_MAX;
- if (cp.hashLog > ZSTD_HASHLOG_MAX) cp.hashLog = ZSTD_HASHLOG_MAX;
+
+#if defined(ZSTD_DEBUG) && (ZSTD_DEBUG>=1)
+ static int g_monotonicTest = 1;
+ if (g_monotonicTest) {
+ ZSTD_check_compressionLevel_monotonicIncrease_memoryBudget();
+ g_monotonicTest=0;
}
- cp = ZSTD_adjustCParams(cp, srcSize, dictSize);
- return cp;
+#endif
+
+ if (compressionLevel <= 0) compressionLevel = ZSTD_CLEVEL_DEFAULT; /* 0 == default; no negative compressionLevel yet */
+ if (compressionLevel > ZSTD_MAX_CLEVEL) compressionLevel = ZSTD_MAX_CLEVEL;
+ { ZSTD_compressionParameters const cp = ZSTD_defaultCParameters[tableID][compressionLevel];
+ return ZSTD_adjustCParams_internal(cp, srcSizeHint, dictSize); }
}
/*! ZSTD_getParams() :
* same as ZSTD_getCParams(), but @return a `ZSTD_parameters` object (instead of `ZSTD_compressionParameters`).
* All fields of `ZSTD_frameParameters` are set to default (0) */
-ZSTD_parameters ZSTD_getParams(int compressionLevel, unsigned long long srcSize, size_t dictSize) {
+ZSTD_parameters ZSTD_getParams(int compressionLevel, unsigned long long srcSizeHint, size_t dictSize) {
ZSTD_parameters params;
- ZSTD_compressionParameters const cParams = ZSTD_getCParams(compressionLevel, srcSize, dictSize);
+ ZSTD_compressionParameters const cParams = ZSTD_getCParams(compressionLevel, srcSizeHint, dictSize);
memset(&params, 0, sizeof(params));
params.cParams = cParams;
return params;
diff --git a/thirdparty/zstd/compress/zstd_opt.h b/thirdparty/zstd/compress/zstd_opt.h
index 5437611912..e8e98915ea 100644
--- a/thirdparty/zstd/compress/zstd_opt.h
+++ b/thirdparty/zstd/compress/zstd_opt.h
@@ -43,6 +43,7 @@ MEM_STATIC void ZSTD_rescaleFreqs(seqStore_t* ssPtr, const BYTE* src, size_t src
if (ssPtr->litLengthSum == 0) {
if (srcSize <= 1024) ssPtr->staticPrices = 1;
+ assert(ssPtr->litFreq!=NULL);
for (u=0; u<=MaxLit; u++)
ssPtr->litFreq[u] = 0;
for (u=0; u<srcSize; u++)
@@ -201,6 +202,20 @@ MEM_STATIC void ZSTD_updatePrice(seqStore_t* seqStorePtr, U32 litLength, const B
}
+/* function safe only for comparisons */
+MEM_STATIC U32 ZSTD_readMINMATCH(const void* memPtr, U32 length)
+{
+ switch (length)
+ {
+ default :
+ case 4 : return MEM_read32(memPtr);
+ case 3 : if (MEM_isLittleEndian())
+ return MEM_read32(memPtr)<<8;
+ else
+ return MEM_read32(memPtr)>>8;
+ }
+}
+
/* Update hashTable3 up to ip (excluded)
Assumption : always within prefix (i.e. not within extDict) */
@@ -234,12 +249,12 @@ static U32 ZSTD_insertBtAndGetAllMatches (
{
const BYTE* const base = zc->base;
const U32 current = (U32)(ip-base);
- const U32 hashLog = zc->params.cParams.hashLog;
+ const U32 hashLog = zc->appliedParams.cParams.hashLog;
const size_t h = ZSTD_hashPtr(ip, hashLog, mls);
U32* const hashTable = zc->hashTable;
U32 matchIndex = hashTable[h];
U32* const bt = zc->chainTable;
- const U32 btLog = zc->params.cParams.chainLog - 1;
+ const U32 btLog = zc->appliedParams.cParams.chainLog - 1;
const U32 btMask= (1U << btLog) - 1;
size_t commonLengthSmaller=0, commonLengthLarger=0;
const BYTE* const dictBase = zc->dictBase;
@@ -267,7 +282,7 @@ static U32 ZSTD_insertBtAndGetAllMatches (
if (match[bestLength] == ip[bestLength]) currentMl = ZSTD_count(ip, match, iLimit);
} else {
match = dictBase + matchIndex3;
- if (MEM_readMINMATCH(match, MINMATCH) == MEM_readMINMATCH(ip, MINMATCH)) /* assumption : matchIndex3 <= dictLimit-4 (by table construction) */
+ if (ZSTD_readMINMATCH(match, MINMATCH) == ZSTD_readMINMATCH(ip, MINMATCH)) /* assumption : matchIndex3 <= dictLimit-4 (by table construction) */
currentMl = ZSTD_count_2segments(ip+MINMATCH, match+MINMATCH, iLimit, dictEnd, prefixStart) + MINMATCH;
}
@@ -410,10 +425,10 @@ void ZSTD_compressBlock_opt_generic(ZSTD_CCtx* ctx,
const BYTE* const base = ctx->base;
const BYTE* const prefixStart = base + ctx->dictLimit;
- const U32 maxSearches = 1U << ctx->params.cParams.searchLog;
- const U32 sufficient_len = ctx->params.cParams.targetLength;
- const U32 mls = ctx->params.cParams.searchLength;
- const U32 minMatch = (ctx->params.cParams.searchLength == 3) ? 3 : 4;
+ const U32 maxSearches = 1U << ctx->appliedParams.cParams.searchLog;
+ const U32 sufficient_len = ctx->appliedParams.cParams.targetLength;
+ const U32 mls = ctx->appliedParams.cParams.searchLength;
+ const U32 minMatch = (ctx->appliedParams.cParams.searchLength == 3) ? 3 : 4;
ZSTD_optimal_t* opt = seqStorePtr->priceTable;
ZSTD_match_t* matches = seqStorePtr->matchTable;
@@ -439,7 +454,7 @@ void ZSTD_compressBlock_opt_generic(ZSTD_CCtx* ctx,
for (i=(ip == anchor); i<last_i; i++) {
const S32 repCur = (i==ZSTD_REP_MOVE_OPT) ? (rep[0] - 1) : rep[i];
if ( (repCur > 0) && (repCur < (S32)(ip-prefixStart))
- && (MEM_readMINMATCH(ip, minMatch) == MEM_readMINMATCH(ip - repCur, minMatch))) {
+ && (ZSTD_readMINMATCH(ip, minMatch) == ZSTD_readMINMATCH(ip - repCur, minMatch))) {
mlen = (U32)ZSTD_count(ip+minMatch, ip+minMatch-repCur, iend) + minMatch;
if (mlen > sufficient_len || mlen >= ZSTD_OPT_NUM) {
best_mlen = mlen; best_off = i; cur = 0; last_pos = 1;
@@ -524,7 +539,7 @@ void ZSTD_compressBlock_opt_generic(ZSTD_CCtx* ctx,
for (i=(opt[cur].mlen != 1); i<last_i; i++) { /* check rep */
const S32 repCur = (i==ZSTD_REP_MOVE_OPT) ? (opt[cur].rep[0] - 1) : opt[cur].rep[i];
if ( (repCur > 0) && (repCur < (S32)(inr-prefixStart))
- && (MEM_readMINMATCH(inr, minMatch) == MEM_readMINMATCH(inr - repCur, minMatch))) {
+ && (ZSTD_readMINMATCH(inr, minMatch) == ZSTD_readMINMATCH(inr - repCur, minMatch))) {
mlen = (U32)ZSTD_count(inr+minMatch, inr+minMatch - repCur, iend) + minMatch;
if (mlen > sufficient_len || cur + mlen >= ZSTD_OPT_NUM) {
@@ -663,10 +678,10 @@ void ZSTD_compressBlock_opt_extDict_generic(ZSTD_CCtx* ctx,
const BYTE* const dictBase = ctx->dictBase;
const BYTE* const dictEnd = dictBase + dictLimit;
- const U32 maxSearches = 1U << ctx->params.cParams.searchLog;
- const U32 sufficient_len = ctx->params.cParams.targetLength;
- const U32 mls = ctx->params.cParams.searchLength;
- const U32 minMatch = (ctx->params.cParams.searchLength == 3) ? 3 : 4;
+ const U32 maxSearches = 1U << ctx->appliedParams.cParams.searchLog;
+ const U32 sufficient_len = ctx->appliedParams.cParams.targetLength;
+ const U32 mls = ctx->appliedParams.cParams.searchLength;
+ const U32 minMatch = (ctx->appliedParams.cParams.searchLength == 3) ? 3 : 4;
ZSTD_optimal_t* opt = seqStorePtr->priceTable;
ZSTD_match_t* matches = seqStorePtr->matchTable;
@@ -698,7 +713,7 @@ void ZSTD_compressBlock_opt_extDict_generic(ZSTD_CCtx* ctx,
const BYTE* const repMatch = repBase + repIndex;
if ( (repCur > 0 && repCur <= (S32)current)
&& (((U32)((dictLimit-1) - repIndex) >= 3) & (repIndex>lowestIndex)) /* intentional overflow */
- && (MEM_readMINMATCH(ip, minMatch) == MEM_readMINMATCH(repMatch, minMatch)) ) {
+ && (ZSTD_readMINMATCH(ip, minMatch) == ZSTD_readMINMATCH(repMatch, minMatch)) ) {
/* repcode detected we should take it */
const BYTE* const repEnd = repIndex < dictLimit ? dictEnd : iend;
mlen = (U32)ZSTD_count_2segments(ip+minMatch, repMatch+minMatch, iend, repEnd, prefixStart) + minMatch;
@@ -794,7 +809,7 @@ void ZSTD_compressBlock_opt_extDict_generic(ZSTD_CCtx* ctx,
const BYTE* const repMatch = repBase + repIndex;
if ( (repCur > 0 && repCur <= (S32)(current+cur))
&& (((U32)((dictLimit-1) - repIndex) >= 3) & (repIndex>lowestIndex)) /* intentional overflow */
- && (MEM_readMINMATCH(inr, minMatch) == MEM_readMINMATCH(repMatch, minMatch)) ) {
+ && (ZSTD_readMINMATCH(inr, minMatch) == ZSTD_readMINMATCH(repMatch, minMatch)) ) {
/* repcode detected */
const BYTE* const repEnd = repIndex < dictLimit ? dictEnd : iend;
mlen = (U32)ZSTD_count_2segments(inr+minMatch, repMatch+minMatch, iend, repEnd, prefixStart) + minMatch;
diff --git a/thirdparty/zstd/compress/zstdmt_compress.c b/thirdparty/zstd/compress/zstdmt_compress.c
index fc7f52a290..0cee01eacb 100644
--- a/thirdparty/zstd/compress/zstdmt_compress.c
+++ b/thirdparty/zstd/compress/zstdmt_compress.c
@@ -14,34 +14,31 @@
/* ====== Compiler specifics ====== */
#if defined(_MSC_VER)
-# pragma warning(disable : 4204) /* disable: C4204: non-constant aggregate initializer */
+# pragma warning(disable : 4204) /* disable: C4204: non-constant aggregate initializer */
#endif
/* ====== Dependencies ====== */
-#include <stdlib.h> /* malloc */
-#include <string.h> /* memcpy */
-#include "pool.h" /* threadpool */
-#include "threading.h" /* mutex */
-#include "zstd_internal.h" /* MIN, ERROR, ZSTD_*, ZSTD_highbit32 */
+#include <string.h> /* memcpy, memset */
+#include "pool.h" /* threadpool */
+#include "threading.h" /* mutex */
+#include "zstd_internal.h" /* MIN, ERROR, ZSTD_*, ZSTD_highbit32 */
#include "zstdmt_compress.h"
/* ====== Debug ====== */
-#if 0
+#if defined(ZSTD_DEBUG) && (ZSTD_DEBUG>=2)
# include <stdio.h>
# include <unistd.h>
# include <sys/times.h>
- static unsigned g_debugLevel = 5;
-# define DEBUGLOGRAW(l, ...) if (l<=g_debugLevel) { fprintf(stderr, __VA_ARGS__); }
-# define DEBUGLOG(l, ...) if (l<=g_debugLevel) { fprintf(stderr, __FILE__ ": "); fprintf(stderr, __VA_ARGS__); fprintf(stderr, " \n"); }
+# define DEBUGLOGRAW(l, ...) if (l<=ZSTD_DEBUG) { fprintf(stderr, __VA_ARGS__); }
-# define DEBUG_PRINTHEX(l,p,n) { \
- unsigned debug_u; \
- for (debug_u=0; debug_u<(n); debug_u++) \
+# define DEBUG_PRINTHEX(l,p,n) { \
+ unsigned debug_u; \
+ for (debug_u=0; debug_u<(n); debug_u++) \
DEBUGLOGRAW(l, "%02X ", ((const unsigned char*)(p))[debug_u]); \
- DEBUGLOGRAW(l, " \n"); \
+ DEBUGLOGRAW(l, " \n"); \
}
static unsigned long long GetCurrentClockTimeMicroseconds(void)
@@ -53,22 +50,22 @@ static unsigned long long GetCurrentClockTimeMicroseconds(void)
return ((((unsigned long long)newTicks)*(1000000))/_ticksPerSecond); }
}
-#define MUTEX_WAIT_TIME_DLEVEL 5
-#define PTHREAD_MUTEX_LOCK(mutex) \
-if (g_debugLevel>=MUTEX_WAIT_TIME_DLEVEL) { \
- unsigned long long const beforeTime = GetCurrentClockTimeMicroseconds(); \
- pthread_mutex_lock(mutex); \
- { unsigned long long const afterTime = GetCurrentClockTimeMicroseconds(); \
- unsigned long long const elapsedTime = (afterTime-beforeTime); \
- if (elapsedTime > 1000) { /* or whatever threshold you like; I'm using 1 millisecond here */ \
- DEBUGLOG(MUTEX_WAIT_TIME_DLEVEL, "Thread took %llu microseconds to acquire mutex %s \n", \
- elapsedTime, #mutex); \
- } } \
-} else pthread_mutex_lock(mutex);
+#define MUTEX_WAIT_TIME_DLEVEL 6
+#define PTHREAD_MUTEX_LOCK(mutex) { \
+ if (ZSTD_DEBUG>=MUTEX_WAIT_TIME_DLEVEL) { \
+ unsigned long long const beforeTime = GetCurrentClockTimeMicroseconds(); \
+ pthread_mutex_lock(mutex); \
+ { unsigned long long const afterTime = GetCurrentClockTimeMicroseconds(); \
+ unsigned long long const elapsedTime = (afterTime-beforeTime); \
+ if (elapsedTime > 1000) { /* or whatever threshold you like; I'm using 1 millisecond here */ \
+ DEBUGLOG(MUTEX_WAIT_TIME_DLEVEL, "Thread took %llu microseconds to acquire mutex %s \n", \
+ elapsedTime, #mutex); \
+ } } \
+ } else pthread_mutex_lock(mutex); \
+}
#else
-# define DEBUGLOG(l, ...) {} /* disabled */
# define PTHREAD_MUTEX_LOCK(m) pthread_mutex_lock(m)
# define DEBUG_PRINTHEX(l,p,n) {}
@@ -87,16 +84,19 @@ static const buffer_t g_nullBuffer = { NULL, 0 };
typedef struct ZSTDMT_bufferPool_s {
unsigned totalBuffers;
unsigned nbBuffers;
+ ZSTD_customMem cMem;
buffer_t bTable[1]; /* variable size */
} ZSTDMT_bufferPool;
-static ZSTDMT_bufferPool* ZSTDMT_createBufferPool(unsigned nbThreads)
+static ZSTDMT_bufferPool* ZSTDMT_createBufferPool(unsigned nbThreads, ZSTD_customMem cMem)
{
unsigned const maxNbBuffers = 2*nbThreads + 2;
- ZSTDMT_bufferPool* const bufPool = (ZSTDMT_bufferPool*)calloc(1, sizeof(ZSTDMT_bufferPool) + (maxNbBuffers-1) * sizeof(buffer_t));
+ ZSTDMT_bufferPool* const bufPool = (ZSTDMT_bufferPool*)ZSTD_calloc(
+ sizeof(ZSTDMT_bufferPool) + (maxNbBuffers-1) * sizeof(buffer_t), cMem);
if (bufPool==NULL) return NULL;
bufPool->totalBuffers = maxNbBuffers;
bufPool->nbBuffers = 0;
+ bufPool->cMem = cMem;
return bufPool;
}
@@ -105,23 +105,39 @@ static void ZSTDMT_freeBufferPool(ZSTDMT_bufferPool* bufPool)
unsigned u;
if (!bufPool) return; /* compatibility with free on NULL */
for (u=0; u<bufPool->totalBuffers; u++)
- free(bufPool->bTable[u].start);
- free(bufPool);
+ ZSTD_free(bufPool->bTable[u].start, bufPool->cMem);
+ ZSTD_free(bufPool, bufPool->cMem);
+}
+
+/* only works at initialization, not during compression */
+static size_t ZSTDMT_sizeof_bufferPool(ZSTDMT_bufferPool* bufPool)
+{
+ size_t const poolSize = sizeof(*bufPool)
+ + (bufPool->totalBuffers - 1) * sizeof(buffer_t);
+ unsigned u;
+ size_t totalBufferSize = 0;
+ for (u=0; u<bufPool->totalBuffers; u++)
+ totalBufferSize += bufPool->bTable[u].size;
+
+ return poolSize + totalBufferSize;
}
-/* assumption : invocation from main thread only ! */
+/** ZSTDMT_getBuffer() :
+ * assumption : invocation from main thread only ! */
static buffer_t ZSTDMT_getBuffer(ZSTDMT_bufferPool* pool, size_t bSize)
{
if (pool->nbBuffers) { /* try to use an existing buffer */
buffer_t const buf = pool->bTable[--(pool->nbBuffers)];
size_t const availBufferSize = buf.size;
- if ((availBufferSize >= bSize) & (availBufferSize <= 10*bSize)) /* large enough, but not too much */
+ if ((availBufferSize >= bSize) & (availBufferSize <= 10*bSize))
+ /* large enough, but not too much */
return buf;
- free(buf.start); /* size conditions not respected : scratch this buffer and create a new one */
+ /* size conditions not respected : scratch this buffer, create new one */
+ ZSTD_free(buf.start, pool->cMem);
}
/* create new buffer */
{ buffer_t buffer;
- void* const start = malloc(bSize);
+ void* const start = ZSTD_malloc(bSize, pool->cMem);
if (start==NULL) bSize = 0;
buffer.start = start; /* note : start can be NULL if malloc fails ! */
buffer.size = bSize;
@@ -138,7 +154,7 @@ static void ZSTDMT_releaseBuffer(ZSTDMT_bufferPool* pool, buffer_t buf)
return;
}
/* Reached bufferPool capacity (should not happen) */
- free(buf.start);
+ ZSTD_free(buf.start, pool->cMem);
}
@@ -147,6 +163,7 @@ static void ZSTDMT_releaseBuffer(ZSTDMT_bufferPool* pool, buffer_t buf)
typedef struct {
unsigned totalCCtx;
unsigned availCCtx;
+ ZSTD_customMem cMem;
ZSTD_CCtx* cctx[1]; /* variable size */
} ZSTDMT_CCtxPool;
@@ -158,23 +175,40 @@ static void ZSTDMT_freeCCtxPool(ZSTDMT_CCtxPool* pool)
unsigned u;
for (u=0; u<pool->totalCCtx; u++)
ZSTD_freeCCtx(pool->cctx[u]); /* note : compatible with free on NULL */
- free(pool);
+ ZSTD_free(pool, pool->cMem);
}
/* ZSTDMT_createCCtxPool() :
* implies nbThreads >= 1 , checked by caller ZSTDMT_createCCtx() */
-static ZSTDMT_CCtxPool* ZSTDMT_createCCtxPool(unsigned nbThreads)
+static ZSTDMT_CCtxPool* ZSTDMT_createCCtxPool(unsigned nbThreads,
+ ZSTD_customMem cMem)
{
- ZSTDMT_CCtxPool* const cctxPool = (ZSTDMT_CCtxPool*) calloc(1, sizeof(ZSTDMT_CCtxPool) + (nbThreads-1)*sizeof(ZSTD_CCtx*));
+ ZSTDMT_CCtxPool* const cctxPool = (ZSTDMT_CCtxPool*) ZSTD_calloc(
+ sizeof(ZSTDMT_CCtxPool) + (nbThreads-1)*sizeof(ZSTD_CCtx*), cMem);
if (!cctxPool) return NULL;
+ cctxPool->cMem = cMem;
cctxPool->totalCCtx = nbThreads;
cctxPool->availCCtx = 1; /* at least one cctx for single-thread mode */
- cctxPool->cctx[0] = ZSTD_createCCtx();
+ cctxPool->cctx[0] = ZSTD_createCCtx_advanced(cMem);
if (!cctxPool->cctx[0]) { ZSTDMT_freeCCtxPool(cctxPool); return NULL; }
- DEBUGLOG(1, "cctxPool created, with %u threads", nbThreads);
+ DEBUGLOG(3, "cctxPool created, with %u threads", nbThreads);
return cctxPool;
}
+/* only works during initialization phase, not during compression */
+static size_t ZSTDMT_sizeof_CCtxPool(ZSTDMT_CCtxPool* cctxPool)
+{
+ unsigned const nbThreads = cctxPool->totalCCtx;
+ size_t const poolSize = sizeof(*cctxPool)
+ + (nbThreads-1)*sizeof(ZSTD_CCtx*);
+ unsigned u;
+ size_t totalCCtxSize = 0;
+ for (u=0; u<nbThreads; u++)
+ totalCCtxSize += ZSTD_sizeof_CCtx(cctxPool->cctx[u]);
+
+ return poolSize + totalCCtxSize;
+}
+
static ZSTD_CCtx* ZSTDMT_getCCtx(ZSTDMT_CCtxPool* pool)
{
if (pool->availCCtx) {
@@ -218,7 +252,7 @@ typedef struct {
pthread_mutex_t* jobCompleted_mutex;
pthread_cond_t* jobCompleted_cond;
ZSTD_parameters params;
- ZSTD_CDict* cdict;
+ const ZSTD_CDict* cdict;
unsigned long long fullFrameSize;
} ZSTDMT_jobDescription;
@@ -228,11 +262,11 @@ void ZSTDMT_compressChunk(void* jobDescription)
ZSTDMT_jobDescription* const job = (ZSTDMT_jobDescription*)jobDescription;
const void* const src = (const char*)job->srcStart + job->dictSize;
buffer_t const dstBuff = job->dstBuff;
- DEBUGLOG(3, "job (first:%u) (last:%u) : dictSize %u, srcSize %u",
+ DEBUGLOG(5, "job (first:%u) (last:%u) : dictSize %u, srcSize %u",
job->firstChunk, job->lastChunk, (U32)job->dictSize, (U32)job->srcSize);
if (job->cdict) { /* should only happen for first segment */
size_t const initError = ZSTD_compressBegin_usingCDict_advanced(job->cctx, job->cdict, job->params.fParams, job->fullFrameSize);
- if (job->cdict) DEBUGLOG(3, "using CDict ");
+ DEBUGLOG(5, "using CDict");
if (ZSTD_isError(initError)) { job->cSize = initError; goto _endJob; }
} else { /* srcStart points at reloaded section */
if (!job->firstChunk) job->params.fParams.contentSizeFlag = 0; /* ensure no srcSize control */
@@ -247,12 +281,12 @@ void ZSTDMT_compressChunk(void* jobDescription)
ZSTD_invalidateRepCodes(job->cctx);
}
- DEBUGLOG(4, "Compressing : ");
+ DEBUGLOG(5, "Compressing : ");
DEBUG_PRINTHEX(4, job->srcStart, 12);
job->cSize = (job->lastChunk) ?
ZSTD_compressEnd (job->cctx, dstBuff.start, dstBuff.size, src, job->srcSize) :
ZSTD_compressContinue(job->cctx, dstBuff.start, dstBuff.size, src, job->srcSize);
- DEBUGLOG(3, "compressed %u bytes into %u bytes (first:%u) (last:%u)",
+ DEBUGLOG(5, "compressed %u bytes into %u bytes (first:%u) (last:%u)",
(unsigned)job->srcSize, (unsigned)job->cSize, job->firstChunk, job->lastChunk);
DEBUGLOG(5, "dstBuff.size : %u ; => %s", (U32)dstBuff.size, ZSTD_getErrorName(job->cSize));
@@ -271,6 +305,7 @@ _endJob:
struct ZSTDMT_CCtx_s {
POOL_ctx* factory;
+ ZSTDMT_jobDescription* jobs;
ZSTDMT_bufferPool* buffPool;
ZSTDMT_CCtxPool* cctxPool;
pthread_mutex_t jobCompleted_mutex;
@@ -292,50 +327,64 @@ struct ZSTDMT_CCtx_s {
unsigned overlapRLog;
unsigned long long frameContentSize;
size_t sectionSize;
- ZSTD_CDict* cdict;
- ZSTD_CStream* cstream;
- ZSTDMT_jobDescription jobs[1]; /* variable size (must lies at the end) */
+ ZSTD_customMem cMem;
+ ZSTD_CDict* cdictLocal;
+ const ZSTD_CDict* cdict;
};
-ZSTDMT_CCtx *ZSTDMT_createCCtx(unsigned nbThreads)
+static ZSTDMT_jobDescription* ZSTDMT_allocJobsTable(U32* nbJobsPtr, ZSTD_customMem cMem)
{
- ZSTDMT_CCtx* cctx;
- U32 const minNbJobs = nbThreads + 2;
- U32 const nbJobsLog2 = ZSTD_highbit32(minNbJobs) + 1;
+ U32 const nbJobsLog2 = ZSTD_highbit32(*nbJobsPtr) + 1;
U32 const nbJobs = 1 << nbJobsLog2;
- DEBUGLOG(5, "nbThreads : %u ; minNbJobs : %u ; nbJobsLog2 : %u ; nbJobs : %u \n",
- nbThreads, minNbJobs, nbJobsLog2, nbJobs);
+ *nbJobsPtr = nbJobs;
+ return (ZSTDMT_jobDescription*) ZSTD_calloc(
+ nbJobs * sizeof(ZSTDMT_jobDescription), cMem);
+}
+
+ZSTDMT_CCtx* ZSTDMT_createCCtx_advanced(unsigned nbThreads, ZSTD_customMem cMem)
+{
+ ZSTDMT_CCtx* mtctx;
+ U32 nbJobs = nbThreads + 2;
+ DEBUGLOG(3, "ZSTDMT_createCCtx_advanced");
+
if ((nbThreads < 1) | (nbThreads > ZSTDMT_NBTHREADS_MAX)) return NULL;
- cctx = (ZSTDMT_CCtx*) calloc(1, sizeof(ZSTDMT_CCtx) + nbJobs*sizeof(ZSTDMT_jobDescription));
- if (!cctx) return NULL;
- cctx->nbThreads = nbThreads;
- cctx->jobIDMask = nbJobs - 1;
- cctx->allJobsCompleted = 1;
- cctx->sectionSize = 0;
- cctx->overlapRLog = 3;
- cctx->factory = POOL_create(nbThreads, 1);
- cctx->buffPool = ZSTDMT_createBufferPool(nbThreads);
- cctx->cctxPool = ZSTDMT_createCCtxPool(nbThreads);
- if (!cctx->factory | !cctx->buffPool | !cctx->cctxPool) { /* one object was not created */
- ZSTDMT_freeCCtx(cctx);
+ if ((cMem.customAlloc!=NULL) ^ (cMem.customFree!=NULL))
+ /* invalid custom allocator */
+ return NULL;
+
+ mtctx = (ZSTDMT_CCtx*) ZSTD_calloc(sizeof(ZSTDMT_CCtx), cMem);
+ if (!mtctx) return NULL;
+ mtctx->cMem = cMem;
+ mtctx->nbThreads = nbThreads;
+ mtctx->allJobsCompleted = 1;
+ mtctx->sectionSize = 0;
+ mtctx->overlapRLog = 3;
+ mtctx->factory = POOL_create(nbThreads, 1);
+ mtctx->jobs = ZSTDMT_allocJobsTable(&nbJobs, cMem);
+ mtctx->jobIDMask = nbJobs - 1;
+ mtctx->buffPool = ZSTDMT_createBufferPool(nbThreads, cMem);
+ mtctx->cctxPool = ZSTDMT_createCCtxPool(nbThreads, cMem);
+ if (!mtctx->factory | !mtctx->jobs | !mtctx->buffPool | !mtctx->cctxPool) {
+ ZSTDMT_freeCCtx(mtctx);
return NULL;
}
- if (nbThreads==1) {
- cctx->cstream = ZSTD_createCStream();
- if (!cctx->cstream) {
- ZSTDMT_freeCCtx(cctx); return NULL;
- } }
- pthread_mutex_init(&cctx->jobCompleted_mutex, NULL); /* Todo : check init function return */
- pthread_cond_init(&cctx->jobCompleted_cond, NULL);
- DEBUGLOG(4, "mt_cctx created, for %u threads \n", nbThreads);
- return cctx;
+ pthread_mutex_init(&mtctx->jobCompleted_mutex, NULL); /* Todo : check init function return */
+ pthread_cond_init(&mtctx->jobCompleted_cond, NULL);
+ DEBUGLOG(3, "mt_cctx created, for %u threads", nbThreads);
+ return mtctx;
+}
+
+ZSTDMT_CCtx* ZSTDMT_createCCtx(unsigned nbThreads)
+{
+ return ZSTDMT_createCCtx_advanced(nbThreads, ZSTD_defaultCMem);
}
/* ZSTDMT_releaseAllJobResources() :
- * Ensure all workers are killed first. */
+ * note : ensure all workers are killed first ! */
static void ZSTDMT_releaseAllJobResources(ZSTDMT_CCtx* mtctx)
{
unsigned jobID;
+ DEBUGLOG(3, "ZSTDMT_releaseAllJobResources");
for (jobID=0; jobID <= mtctx->jobIDMask; jobID++) {
ZSTDMT_releaseBuffer(mtctx->buffPool, mtctx->jobs[jobID].dstBuff);
mtctx->jobs[jobID].dstBuff = g_nullBuffer;
@@ -356,15 +405,26 @@ size_t ZSTDMT_freeCCtx(ZSTDMT_CCtx* mtctx)
POOL_free(mtctx->factory);
if (!mtctx->allJobsCompleted) ZSTDMT_releaseAllJobResources(mtctx); /* stop workers first */
ZSTDMT_freeBufferPool(mtctx->buffPool); /* release job resources into pools first */
+ ZSTD_free(mtctx->jobs, mtctx->cMem);
ZSTDMT_freeCCtxPool(mtctx->cctxPool);
- ZSTD_freeCDict(mtctx->cdict);
- ZSTD_freeCStream(mtctx->cstream);
+ ZSTD_freeCDict(mtctx->cdictLocal);
pthread_mutex_destroy(&mtctx->jobCompleted_mutex);
pthread_cond_destroy(&mtctx->jobCompleted_cond);
- free(mtctx);
+ ZSTD_free(mtctx, mtctx->cMem);
return 0;
}
+size_t ZSTDMT_sizeof_CCtx(ZSTDMT_CCtx* mtctx)
+{
+ if (mtctx == NULL) return 0; /* supports sizeof NULL */
+ return sizeof(*mtctx)
+ + POOL_sizeof(mtctx->factory)
+ + ZSTDMT_sizeof_bufferPool(mtctx->buffPool)
+ + (mtctx->jobIDMask+1) * sizeof(ZSTDMT_jobDescription)
+ + ZSTDMT_sizeof_CCtxPool(mtctx->cctxPool)
+ + ZSTD_sizeof_CDict(mtctx->cdictLocal);
+}
+
size_t ZSTDMT_setMTCtxParameter(ZSTDMT_CCtx* mtctx, ZSDTMT_parameter parameter, unsigned value)
{
switch(parameter)
@@ -373,7 +433,7 @@ size_t ZSTDMT_setMTCtxParameter(ZSTDMT_CCtx* mtctx, ZSDTMT_parameter parameter,
mtctx->sectionSize = value;
return 0;
case ZSTDMT_p_overlapSectionLog :
- DEBUGLOG(4, "ZSTDMT_p_overlapSectionLog : %u", value);
+ DEBUGLOG(5, "ZSTDMT_p_overlapSectionLog : %u", value);
mtctx->overlapRLog = (value >= 9) ? 0 : 9 - value;
return 0;
default :
@@ -386,31 +446,49 @@ size_t ZSTDMT_setMTCtxParameter(ZSTDMT_CCtx* mtctx, ZSDTMT_parameter parameter,
/* ===== Multi-threaded compression ===== */
/* ------------------------------------------ */
-size_t ZSTDMT_compressCCtx(ZSTDMT_CCtx* mtctx,
+static unsigned computeNbChunks(size_t srcSize, unsigned windowLog, unsigned nbThreads) {
+ size_t const chunkSizeTarget = (size_t)1 << (windowLog + 2);
+ size_t const chunkMaxSize = chunkSizeTarget << 2;
+ size_t const passSizeMax = chunkMaxSize * nbThreads;
+ unsigned const multiplier = (unsigned)(srcSize / passSizeMax) + 1;
+ unsigned const nbChunksLarge = multiplier * nbThreads;
+ unsigned const nbChunksMax = (unsigned)(srcSize / chunkSizeTarget) + 1;
+ unsigned const nbChunksSmall = MIN(nbChunksMax, nbThreads);
+ return (multiplier>1) ? nbChunksLarge : nbChunksSmall;
+}
+
+
+size_t ZSTDMT_compress_advanced(ZSTDMT_CCtx* mtctx,
void* dst, size_t dstCapacity,
const void* src, size_t srcSize,
- int compressionLevel)
+ const ZSTD_CDict* cdict,
+ ZSTD_parameters const params,
+ unsigned overlapRLog)
{
- ZSTD_parameters params = ZSTD_getParams(compressionLevel, srcSize, 0);
- U32 const overlapLog = (compressionLevel >= ZSTD_maxCLevel()) ? 0 : 3;
- size_t const overlapSize = (size_t)1 << (params.cParams.windowLog - overlapLog);
- size_t const chunkTargetSize = (size_t)1 << (params.cParams.windowLog + 2);
- unsigned const nbChunksMax = (unsigned)(srcSize / chunkTargetSize) + 1;
- unsigned nbChunks = MIN(nbChunksMax, mtctx->nbThreads);
+ size_t const overlapSize = (overlapRLog>=9) ? 0 : (size_t)1 << (params.cParams.windowLog - overlapRLog);
+ unsigned nbChunks = computeNbChunks(srcSize, params.cParams.windowLog, mtctx->nbThreads);
size_t const proposedChunkSize = (srcSize + (nbChunks-1)) / nbChunks;
- size_t const avgChunkSize = ((proposedChunkSize & 0x1FFFF) < 0xFFFF) ? proposedChunkSize + 0xFFFF : proposedChunkSize; /* avoid too small last block */
- size_t remainingSrcSize = srcSize;
+ size_t const avgChunkSize = ((proposedChunkSize & 0x1FFFF) < 0x7FFF) ? proposedChunkSize + 0xFFFF : proposedChunkSize; /* avoid too small last block */
const char* const srcStart = (const char*)src;
+ size_t remainingSrcSize = srcSize;
unsigned const compressWithinDst = (dstCapacity >= ZSTD_compressBound(srcSize)) ? nbChunks : (unsigned)(dstCapacity / ZSTD_compressBound(avgChunkSize)); /* presumes avgChunkSize >= 256 KB, which should be the case */
size_t frameStartPos = 0, dstBufferPos = 0;
- DEBUGLOG(3, "windowLog : %2u => chunkTargetSize : %u bytes ", params.cParams.windowLog, (U32)chunkTargetSize);
- DEBUGLOG(2, "nbChunks : %2u (chunkSize : %u bytes) ", nbChunks, (U32)avgChunkSize);
- params.fParams.contentSizeFlag = 1;
-
+ DEBUGLOG(4, "nbChunks : %2u (chunkSize : %u bytes) ", nbChunks, (U32)avgChunkSize);
if (nbChunks==1) { /* fallback to single-thread mode */
ZSTD_CCtx* const cctx = mtctx->cctxPool->cctx[0];
- return ZSTD_compressCCtx(cctx, dst, dstCapacity, src, srcSize, compressionLevel);
+ if (cdict) return ZSTD_compress_usingCDict_advanced(cctx, dst, dstCapacity, src, srcSize, cdict, params.fParams);
+ return ZSTD_compress_advanced(cctx, dst, dstCapacity, src, srcSize, NULL, 0, params);
+ }
+ assert(avgChunkSize >= 256 KB); /* condition for ZSTD_compressBound(A) + ZSTD_compressBound(B) <= ZSTD_compressBound(A+B), which is useful to avoid allocating extra buffers */
+
+ if (nbChunks > mtctx->jobIDMask+1) { /* enlarge job table */
+ U32 nbJobs = nbChunks;
+ ZSTD_free(mtctx->jobs, mtctx->cMem);
+ mtctx->jobIDMask = 0;
+ mtctx->jobs = ZSTDMT_allocJobsTable(&nbJobs, mtctx->cMem);
+ if (mtctx->jobs==NULL) return ERROR(memory_allocation);
+ mtctx->jobIDMask = nbJobs - 1;
}
{ unsigned u;
@@ -425,15 +503,18 @@ size_t ZSTDMT_compressCCtx(ZSTDMT_CCtx* mtctx,
if ((cctx==NULL) || (dstBuffer.start==NULL)) {
mtctx->jobs[u].cSize = ERROR(memory_allocation); /* job result */
mtctx->jobs[u].jobCompleted = 1;
- nbChunks = u+1;
+ nbChunks = u+1; /* only wait and free u jobs, instead of initially expected nbChunks ones */
break; /* let's wait for previous jobs to complete, but don't start new ones */
}
mtctx->jobs[u].srcStart = srcStart + frameStartPos - dictSize;
mtctx->jobs[u].dictSize = dictSize;
mtctx->jobs[u].srcSize = chunkSize;
+ mtctx->jobs[u].cdict = mtctx->nextJobID==0 ? cdict : NULL;
mtctx->jobs[u].fullFrameSize = srcSize;
mtctx->jobs[u].params = params;
+ /* do not calculate checksum within sections, but write it in header for first section */
+ if (u!=0) mtctx->jobs[u].params.fParams.checksumFlag = 0;
mtctx->jobs[u].dstBuff = dstBuffer;
mtctx->jobs[u].cctx = cctx;
mtctx->jobs[u].firstChunk = (u==0);
@@ -442,27 +523,27 @@ size_t ZSTDMT_compressCCtx(ZSTDMT_CCtx* mtctx,
mtctx->jobs[u].jobCompleted_mutex = &mtctx->jobCompleted_mutex;
mtctx->jobs[u].jobCompleted_cond = &mtctx->jobCompleted_cond;
- DEBUGLOG(3, "posting job %u (%u bytes)", u, (U32)chunkSize);
- DEBUG_PRINTHEX(3, mtctx->jobs[u].srcStart, 12);
+ DEBUGLOG(5, "posting job %u (%u bytes)", u, (U32)chunkSize);
+ DEBUG_PRINTHEX(6, mtctx->jobs[u].srcStart, 12);
POOL_add(mtctx->factory, ZSTDMT_compressChunk, &mtctx->jobs[u]);
frameStartPos += chunkSize;
dstBufferPos += dstBufferCapacity;
remainingSrcSize -= chunkSize;
} }
- /* note : since nbChunks <= nbThreads, all jobs should be running immediately in parallel */
+ /* collect result */
{ unsigned chunkID;
size_t error = 0, dstPos = 0;
for (chunkID=0; chunkID<nbChunks; chunkID++) {
- DEBUGLOG(3, "waiting for chunk %u ", chunkID);
+ DEBUGLOG(5, "waiting for chunk %u ", chunkID);
PTHREAD_MUTEX_LOCK(&mtctx->jobCompleted_mutex);
while (mtctx->jobs[chunkID].jobCompleted==0) {
- DEBUGLOG(4, "waiting for jobCompleted signal from chunk %u", chunkID);
+ DEBUGLOG(5, "waiting for jobCompleted signal from chunk %u", chunkID);
pthread_cond_wait(&mtctx->jobCompleted_cond, &mtctx->jobCompleted_mutex);
}
pthread_mutex_unlock(&mtctx->jobCompleted_mutex);
- DEBUGLOG(3, "ready to write chunk %u ", chunkID);
+ DEBUGLOG(5, "ready to write chunk %u ", chunkID);
ZSTDMT_releaseCCtx(mtctx->cctxPool, mtctx->jobs[chunkID].cctx);
mtctx->jobs[chunkID].cctx = NULL;
@@ -470,20 +551,33 @@ size_t ZSTDMT_compressCCtx(ZSTDMT_CCtx* mtctx,
{ size_t const cSize = mtctx->jobs[chunkID].cSize;
if (ZSTD_isError(cSize)) error = cSize;
if ((!error) && (dstPos + cSize > dstCapacity)) error = ERROR(dstSize_tooSmall);
- if (chunkID) { /* note : chunk 0 is already written directly into dst */
+ if (chunkID) { /* note : chunk 0 is written directly at dst, which is correct position */
if (!error)
- memmove((char*)dst + dstPos, mtctx->jobs[chunkID].dstBuff.start, cSize); /* may overlap if chunk decompressed within dst */
- if (chunkID >= compressWithinDst) /* otherwise, it decompresses within dst */
+ memmove((char*)dst + dstPos, mtctx->jobs[chunkID].dstBuff.start, cSize); /* may overlap when chunk compressed within dst */
+ if (chunkID >= compressWithinDst) { /* chunk compressed into its own buffer, which must be released */
+ DEBUGLOG(5, "releasing buffer %u>=%u", chunkID, compressWithinDst);
ZSTDMT_releaseBuffer(mtctx->buffPool, mtctx->jobs[chunkID].dstBuff);
+ }
mtctx->jobs[chunkID].dstBuff = g_nullBuffer;
}
dstPos += cSize ;
}
}
- if (!error) DEBUGLOG(3, "compressed size : %u ", (U32)dstPos);
+ if (!error) DEBUGLOG(4, "compressed size : %u ", (U32)dstPos);
return error ? error : dstPos;
}
+}
+
+size_t ZSTDMT_compressCCtx(ZSTDMT_CCtx* mtctx,
+ void* dst, size_t dstCapacity,
+ const void* src, size_t srcSize,
+ int compressionLevel)
+{
+ U32 const overlapRLog = (compressionLevel >= ZSTD_maxCLevel()) ? 0 : 3;
+ ZSTD_parameters params = ZSTD_getParams(compressionLevel, srcSize, 0);
+ params.fParams.contentSizeFlag = 1;
+ return ZSTDMT_compress_advanced(mtctx, dst, dstCapacity, src, srcSize, NULL, params, overlapRLog);
}
@@ -491,12 +585,14 @@ size_t ZSTDMT_compressCCtx(ZSTDMT_CCtx* mtctx,
/* ======= Streaming API ======= */
/* ====================================== */
-static void ZSTDMT_waitForAllJobsCompleted(ZSTDMT_CCtx* zcs) {
+static void ZSTDMT_waitForAllJobsCompleted(ZSTDMT_CCtx* zcs)
+{
+ DEBUGLOG(4, "ZSTDMT_waitForAllJobsCompleted");
while (zcs->doneJobID < zcs->nextJobID) {
unsigned const jobID = zcs->doneJobID & zcs->jobIDMask;
PTHREAD_MUTEX_LOCK(&zcs->jobCompleted_mutex);
while (zcs->jobs[jobID].jobCompleted==0) {
- DEBUGLOG(4, "waiting for jobCompleted signal from chunk %u", zcs->doneJobID); /* we want to block when waiting for data to flush */
+ DEBUGLOG(5, "waiting for jobCompleted signal from chunk %u", zcs->doneJobID); /* we want to block when waiting for data to flush */
pthread_cond_wait(&zcs->jobCompleted_cond, &zcs->jobCompleted_mutex);
}
pthread_mutex_unlock(&zcs->jobCompleted_mutex);
@@ -505,33 +601,54 @@ static void ZSTDMT_waitForAllJobsCompleted(ZSTDMT_CCtx* zcs) {
}
-static size_t ZSTDMT_initCStream_internal(ZSTDMT_CCtx* zcs,
- const void* dict, size_t dictSize, unsigned updateDict,
- ZSTD_parameters params, unsigned long long pledgedSrcSize)
+/** ZSTDMT_initCStream_internal() :
+ * internal usage only */
+size_t ZSTDMT_initCStream_internal(ZSTDMT_CCtx* zcs,
+ const void* dict, size_t dictSize, const ZSTD_CDict* cdict,
+ ZSTD_parameters params, unsigned long long pledgedSrcSize)
{
- ZSTD_customMem const cmem = { NULL, NULL, NULL };
- DEBUGLOG(3, "Started new compression, with windowLog : %u", params.cParams.windowLog);
- if (zcs->nbThreads==1) return ZSTD_initCStream_advanced(zcs->cstream, dict, dictSize, params, pledgedSrcSize);
- if (zcs->allJobsCompleted == 0) { /* previous job not correctly finished */
+ DEBUGLOG(4, "ZSTDMT_initCStream_internal");
+ /* params are supposed to be fully validated at this point */
+ assert(!ZSTD_isError(ZSTD_checkCParams(params.cParams)));
+ assert(!((dict) && (cdict))); /* either dict or cdict, not both */
+
+ if (zcs->nbThreads==1) {
+ DEBUGLOG(4, "single thread mode");
+ return ZSTD_initCStream_internal(zcs->cctxPool->cctx[0],
+ dict, dictSize, cdict,
+ params, pledgedSrcSize);
+ }
+
+ if (zcs->allJobsCompleted == 0) { /* previous compression not correctly finished */
ZSTDMT_waitForAllJobsCompleted(zcs);
ZSTDMT_releaseAllJobResources(zcs);
zcs->allJobsCompleted = 1;
}
+
zcs->params = params;
- if (updateDict) {
- ZSTD_freeCDict(zcs->cdict); zcs->cdict = NULL;
- if (dict && dictSize) {
- zcs->cdict = ZSTD_createCDict_advanced(dict, dictSize, 0, params.cParams, cmem);
- if (zcs->cdict == NULL) return ERROR(memory_allocation);
- } }
zcs->frameContentSize = pledgedSrcSize;
+ if (dict) {
+ DEBUGLOG(4,"cdictLocal: %08X", (U32)(size_t)zcs->cdictLocal);
+ ZSTD_freeCDict(zcs->cdictLocal);
+ zcs->cdictLocal = ZSTD_createCDict_advanced(dict, dictSize,
+ 0 /* byRef */, ZSTD_dm_auto, /* note : a loadPrefix becomes an internal CDict */
+ params.cParams, zcs->cMem);
+ zcs->cdict = zcs->cdictLocal;
+ if (zcs->cdictLocal == NULL) return ERROR(memory_allocation);
+ } else {
+ DEBUGLOG(4,"cdictLocal: %08X", (U32)(size_t)zcs->cdictLocal);
+ ZSTD_freeCDict(zcs->cdictLocal);
+ zcs->cdictLocal = NULL;
+ zcs->cdict = cdict;
+ }
+
zcs->targetDictSize = (zcs->overlapRLog>=9) ? 0 : (size_t)1 << (zcs->params.cParams.windowLog - zcs->overlapRLog);
DEBUGLOG(4, "overlapRLog : %u ", zcs->overlapRLog);
- DEBUGLOG(3, "overlap Size : %u KB", (U32)(zcs->targetDictSize>>10));
+ DEBUGLOG(4, "overlap Size : %u KB", (U32)(zcs->targetDictSize>>10));
zcs->targetSectionSize = zcs->sectionSize ? zcs->sectionSize : (size_t)1 << (zcs->params.cParams.windowLog + 2);
zcs->targetSectionSize = MAX(ZSTDMT_SECTION_SIZE_MIN, zcs->targetSectionSize);
zcs->targetSectionSize = MAX(zcs->targetDictSize, zcs->targetSectionSize);
- DEBUGLOG(3, "Section Size : %u KB", (U32)(zcs->targetSectionSize>>10));
+ DEBUGLOG(4, "Section Size : %u KB", (U32)(zcs->targetSectionSize>>10));
zcs->marginSize = zcs->targetSectionSize >> 2;
zcs->inBuffSize = zcs->targetDictSize + zcs->targetSectionSize + zcs->marginSize;
zcs->inBuff.buffer = ZSTDMT_getBuffer(zcs->buffPool, zcs->inBuffSize);
@@ -546,24 +663,39 @@ static size_t ZSTDMT_initCStream_internal(ZSTDMT_CCtx* zcs,
return 0;
}
-size_t ZSTDMT_initCStream_advanced(ZSTDMT_CCtx* zcs,
+size_t ZSTDMT_initCStream_advanced(ZSTDMT_CCtx* mtctx,
const void* dict, size_t dictSize,
ZSTD_parameters params, unsigned long long pledgedSrcSize)
{
- return ZSTDMT_initCStream_internal(zcs, dict, dictSize, 1, params, pledgedSrcSize);
+ DEBUGLOG(5, "ZSTDMT_initCStream_advanced");
+ return ZSTDMT_initCStream_internal(mtctx, dict, dictSize, NULL, params, pledgedSrcSize);
}
+size_t ZSTDMT_initCStream_usingCDict(ZSTDMT_CCtx* mtctx,
+ const ZSTD_CDict* cdict,
+ ZSTD_frameParameters fParams,
+ unsigned long long pledgedSrcSize)
+{
+ ZSTD_parameters params = ZSTD_getParamsFromCDict(cdict);
+ if (cdict==NULL) return ERROR(dictionary_wrong); /* method incompatible with NULL cdict */
+ params.fParams = fParams;
+ return ZSTDMT_initCStream_internal(mtctx, NULL, 0 /*dictSize*/, cdict,
+ params, pledgedSrcSize);
+}
+
+
/* ZSTDMT_resetCStream() :
* pledgedSrcSize is optional and can be zero == unknown */
size_t ZSTDMT_resetCStream(ZSTDMT_CCtx* zcs, unsigned long long pledgedSrcSize)
{
- if (zcs->nbThreads==1) return ZSTD_resetCStream(zcs->cstream, pledgedSrcSize);
+ if (zcs->nbThreads==1)
+ return ZSTD_resetCStream(zcs->cctxPool->cctx[0], pledgedSrcSize);
return ZSTDMT_initCStream_internal(zcs, NULL, 0, 0, zcs->params, pledgedSrcSize);
}
size_t ZSTDMT_initCStream(ZSTDMT_CCtx* zcs, int compressionLevel) {
ZSTD_parameters const params = ZSTD_getParams(compressionLevel, 0, 0);
- return ZSTDMT_initCStream_internal(zcs, NULL, 0, 1, params, 0);
+ return ZSTDMT_initCStream_internal(zcs, NULL, 0, NULL, params, 0);
}
@@ -582,13 +714,16 @@ static size_t ZSTDMT_createCompressionJob(ZSTDMT_CCtx* zcs, size_t srcSize, unsi
return ERROR(memory_allocation);
}
- DEBUGLOG(4, "preparing job %u to compress %u bytes with %u preload ", zcs->nextJobID, (U32)srcSize, (U32)zcs->dictSize);
+ DEBUGLOG(4, "preparing job %u to compress %u bytes with %u preload ",
+ zcs->nextJobID, (U32)srcSize, (U32)zcs->dictSize);
zcs->jobs[jobID].src = zcs->inBuff.buffer;
zcs->jobs[jobID].srcStart = zcs->inBuff.buffer.start;
zcs->jobs[jobID].srcSize = srcSize;
- zcs->jobs[jobID].dictSize = zcs->dictSize; /* note : zcs->inBuff.filled is presumed >= srcSize + dictSize */
+ zcs->jobs[jobID].dictSize = zcs->dictSize;
+ assert(zcs->inBuff.filled >= srcSize + zcs->dictSize);
zcs->jobs[jobID].params = zcs->params;
- if (zcs->nextJobID) zcs->jobs[jobID].params.fParams.checksumFlag = 0; /* do not calculate checksum within sections, just keep it in header for first section */
+ /* do not calculate checksum within sections, but write it in header for first section */
+ if (zcs->nextJobID) zcs->jobs[jobID].params.fParams.checksumFlag = 0;
zcs->jobs[jobID].cdict = zcs->nextJobID==0 ? zcs->cdict : NULL;
zcs->jobs[jobID].fullFrameSize = zcs->frameContentSize;
zcs->jobs[jobID].dstBuff = dstBuffer;
@@ -603,6 +738,7 @@ static size_t ZSTDMT_createCompressionJob(ZSTDMT_CCtx* zcs, size_t srcSize, unsi
/* get a new buffer for next input */
if (!endFrame) {
size_t const newDictSize = MIN(srcSize + zcs->dictSize, zcs->targetDictSize);
+ DEBUGLOG(5, "ZSTDMT_createCompressionJob::endFrame = %u", endFrame);
zcs->inBuff.buffer = ZSTDMT_getBuffer(zcs->buffPool, zcs->inBuffSize);
if (zcs->inBuff.buffer.start == NULL) { /* not enough memory to allocate next input buffer */
zcs->jobs[jobID].jobCompleted = 1;
@@ -611,22 +747,33 @@ static size_t ZSTDMT_createCompressionJob(ZSTDMT_CCtx* zcs, size_t srcSize, unsi
ZSTDMT_releaseAllJobResources(zcs);
return ERROR(memory_allocation);
}
- DEBUGLOG(5, "inBuff filled to %u", (U32)zcs->inBuff.filled);
+ DEBUGLOG(5, "inBuff currently filled to %u", (U32)zcs->inBuff.filled);
zcs->inBuff.filled -= srcSize + zcs->dictSize - newDictSize;
- DEBUGLOG(5, "new job : filled to %u, with %u dict and %u src", (U32)zcs->inBuff.filled, (U32)newDictSize, (U32)(zcs->inBuff.filled - newDictSize));
- memmove(zcs->inBuff.buffer.start, (const char*)zcs->jobs[jobID].srcStart + zcs->dictSize + srcSize - newDictSize, zcs->inBuff.filled);
+ DEBUGLOG(5, "new job : inBuff filled to %u, with %u dict and %u src",
+ (U32)zcs->inBuff.filled, (U32)newDictSize,
+ (U32)(zcs->inBuff.filled - newDictSize));
+ memmove(zcs->inBuff.buffer.start,
+ (const char*)zcs->jobs[jobID].srcStart + zcs->dictSize + srcSize - newDictSize,
+ zcs->inBuff.filled);
DEBUGLOG(5, "new inBuff pre-filled");
zcs->dictSize = newDictSize;
- } else {
+ } else { /* if (endFrame==1) */
+ DEBUGLOG(5, "ZSTDMT_createCompressionJob::endFrame = %u", endFrame);
zcs->inBuff.buffer = g_nullBuffer;
zcs->inBuff.filled = 0;
zcs->dictSize = 0;
zcs->frameEnded = 1;
if (zcs->nextJobID == 0)
- zcs->params.fParams.checksumFlag = 0; /* single chunk : checksum is calculated directly within worker thread */
+ /* single chunk exception : checksum is calculated directly within worker thread */
+ zcs->params.fParams.checksumFlag = 0;
}
- DEBUGLOG(3, "posting job %u : %u bytes (end:%u) (note : doneJob = %u=>%u)", zcs->nextJobID, (U32)zcs->jobs[jobID].srcSize, zcs->jobs[jobID].lastChunk, zcs->doneJobID, zcs->doneJobID & zcs->jobIDMask);
+ DEBUGLOG(4, "posting job %u : %u bytes (end:%u) (note : doneJob = %u=>%u)",
+ zcs->nextJobID,
+ (U32)zcs->jobs[jobID].srcSize,
+ zcs->jobs[jobID].lastChunk,
+ zcs->doneJobID,
+ zcs->doneJobID & zcs->jobIDMask);
POOL_add(zcs->factory, ZSTDMT_compressChunk, &zcs->jobs[jobID]); /* this call is blocking when thread worker pool is exhausted */
zcs->nextJobID++;
return 0;
@@ -664,7 +811,7 @@ static size_t ZSTDMT_flushNextJob(ZSTDMT_CCtx* zcs, ZSTD_outBuffer* output, unsi
XXH64_update(&zcs->xxhState, (const char*)job.srcStart + job.dictSize, job.srcSize);
if (zcs->frameEnded && (zcs->doneJobID+1 == zcs->nextJobID)) { /* write checksum at end of last section */
U32 const checksum = (U32)XXH64_digest(&zcs->xxhState);
- DEBUGLOG(4, "writing checksum : %08X \n", checksum);
+ DEBUGLOG(5, "writing checksum : %08X \n", checksum);
MEM_writeLE32((char*)job.dstBuff.start + job.cSize, checksum);
job.cSize += 4;
zcs->jobs[wJobID].cSize += 4;
@@ -675,7 +822,7 @@ static size_t ZSTDMT_flushNextJob(ZSTDMT_CCtx* zcs, ZSTD_outBuffer* output, unsi
zcs->jobs[wJobID].jobScanned = 1;
}
{ size_t const toWrite = MIN(job.cSize - job.dstFlushed, output->size - output->pos);
- DEBUGLOG(4, "Flushing %u bytes from job %u ", (U32)toWrite, zcs->doneJobID);
+ DEBUGLOG(5, "Flushing %u bytes from job %u ", (U32)toWrite, zcs->doneJobID);
memcpy((char*)output->dst + output->pos, (const char*)job.dstBuff.start + job.dstFlushed, toWrite);
output->pos += toWrite;
job.dstFlushed += toWrite;
@@ -696,26 +843,81 @@ static size_t ZSTDMT_flushNextJob(ZSTDMT_CCtx* zcs, ZSTD_outBuffer* output, unsi
} }
-size_t ZSTDMT_compressStream(ZSTDMT_CCtx* zcs, ZSTD_outBuffer* output, ZSTD_inBuffer* input)
+/** ZSTDMT_compressStream_generic() :
+ * internal use only
+ * assumption : output and input are valid (pos <= size)
+ * @return : minimum amount of data remaining to flush, 0 if none */
+size_t ZSTDMT_compressStream_generic(ZSTDMT_CCtx* mtctx,
+ ZSTD_outBuffer* output,
+ ZSTD_inBuffer* input,
+ ZSTD_EndDirective endOp)
{
- size_t const newJobThreshold = zcs->dictSize + zcs->targetSectionSize + zcs->marginSize;
- if (zcs->frameEnded) return ERROR(stage_wrong); /* current frame being ended. Only flush is allowed. Restart with init */
- if (zcs->nbThreads==1) return ZSTD_compressStream(zcs->cstream, output, input);
+ size_t const newJobThreshold = mtctx->dictSize + mtctx->targetSectionSize + mtctx->marginSize;
+ assert(output->pos <= output->size);
+ assert(input->pos <= input->size);
+ if ((mtctx->frameEnded) && (endOp==ZSTD_e_continue)) {
+ /* current frame being ended. Only flush/end are allowed. Or start new frame with init */
+ return ERROR(stage_wrong);
+ }
+ if (mtctx->nbThreads==1) {
+ return ZSTD_compressStream_generic(mtctx->cctxPool->cctx[0], output, input, endOp);
+ }
+
+ /* single-pass shortcut (note : this is blocking-mode) */
+ if ( (mtctx->nextJobID==0) /* just started */
+ && (mtctx->inBuff.filled==0) /* nothing buffered */
+ && (endOp==ZSTD_e_end) /* end order */
+ && (output->size - output->pos >= ZSTD_compressBound(input->size - input->pos)) ) { /* enough room */
+ size_t const cSize = ZSTDMT_compress_advanced(mtctx,
+ (char*)output->dst + output->pos, output->size - output->pos,
+ (const char*)input->src + input->pos, input->size - input->pos,
+ mtctx->cdict, mtctx->params, mtctx->overlapRLog);
+ if (ZSTD_isError(cSize)) return cSize;
+ input->pos = input->size;
+ output->pos += cSize;
+ ZSTDMT_releaseBuffer(mtctx->buffPool, mtctx->inBuff.buffer); /* was allocated in initStream */
+ mtctx->allJobsCompleted = 1;
+ mtctx->frameEnded = 1;
+ return 0;
+ }
/* fill input buffer */
- { size_t const toLoad = MIN(input->size - input->pos, zcs->inBuffSize - zcs->inBuff.filled);
- memcpy((char*)zcs->inBuff.buffer.start + zcs->inBuff.filled, input->src, toLoad);
+ if ((input->src) && (mtctx->inBuff.buffer.start)) { /* support NULL input */
+ size_t const toLoad = MIN(input->size - input->pos, mtctx->inBuffSize - mtctx->inBuff.filled);
+ DEBUGLOG(2, "inBuff:%08X; inBuffSize=%u; ToCopy=%u", (U32)(size_t)mtctx->inBuff.buffer.start, (U32)mtctx->inBuffSize, (U32)toLoad);
+ memcpy((char*)mtctx->inBuff.buffer.start + mtctx->inBuff.filled, (const char*)input->src + input->pos, toLoad);
input->pos += toLoad;
- zcs->inBuff.filled += toLoad;
+ mtctx->inBuff.filled += toLoad;
}
- if ( (zcs->inBuff.filled >= newJobThreshold) /* filled enough : let's compress */
- && (zcs->nextJobID <= zcs->doneJobID + zcs->jobIDMask) ) { /* avoid overwriting job round buffer */
- CHECK_F( ZSTDMT_createCompressionJob(zcs, zcs->targetSectionSize, 0) );
+ if ( (mtctx->inBuff.filled >= newJobThreshold) /* filled enough : let's compress */
+ && (mtctx->nextJobID <= mtctx->doneJobID + mtctx->jobIDMask) ) { /* avoid overwriting job round buffer */
+ CHECK_F( ZSTDMT_createCompressionJob(mtctx, mtctx->targetSectionSize, 0 /* endFrame */) );
}
- /* check for data to flush */
- CHECK_F( ZSTDMT_flushNextJob(zcs, output, (zcs->inBuff.filled == zcs->inBuffSize)) ); /* block if it wasn't possible to create new job due to saturation */
+ /* check for potential compressed data ready to be flushed */
+ CHECK_F( ZSTDMT_flushNextJob(mtctx, output, (mtctx->inBuff.filled == mtctx->inBuffSize) /* blockToFlush */) ); /* block if it wasn't possible to create new job due to saturation */
+
+ if (input->pos < input->size) /* input not consumed : do not flush yet */
+ endOp = ZSTD_e_continue;
+
+ switch(endOp)
+ {
+ case ZSTD_e_flush:
+ return ZSTDMT_flushStream(mtctx, output);
+ case ZSTD_e_end:
+ return ZSTDMT_endStream(mtctx, output);
+ case ZSTD_e_continue:
+ return 1;
+ default:
+ return ERROR(GENERIC); /* invalid endDirective */
+ }
+}
+
+
+size_t ZSTDMT_compressStream(ZSTDMT_CCtx* zcs, ZSTD_outBuffer* output, ZSTD_inBuffer* input)
+{
+ CHECK_F( ZSTDMT_compressStream_generic(zcs, output, input, ZSTD_e_continue) );
/* recommended next input size : fill current input buffer */
return zcs->inBuffSize - zcs->inBuff.filled; /* note : could be zero when input buffer is fully filled and no more availability to create new job */
@@ -726,26 +928,28 @@ static size_t ZSTDMT_flushStream_internal(ZSTDMT_CCtx* zcs, ZSTD_outBuffer* outp
{
size_t const srcSize = zcs->inBuff.filled - zcs->dictSize;
- if (srcSize) DEBUGLOG(4, "flushing : %u bytes left to compress", (U32)srcSize);
if ( ((srcSize > 0) || (endFrame && !zcs->frameEnded))
&& (zcs->nextJobID <= zcs->doneJobID + zcs->jobIDMask) ) {
CHECK_F( ZSTDMT_createCompressionJob(zcs, srcSize, endFrame) );
}
/* check if there is any data available to flush */
- DEBUGLOG(5, "zcs->doneJobID : %u ; zcs->nextJobID : %u ", zcs->doneJobID, zcs->nextJobID);
- return ZSTDMT_flushNextJob(zcs, output, 1);
+ return ZSTDMT_flushNextJob(zcs, output, 1 /* blockToFlush */);
}
size_t ZSTDMT_flushStream(ZSTDMT_CCtx* zcs, ZSTD_outBuffer* output)
{
- if (zcs->nbThreads==1) return ZSTD_flushStream(zcs->cstream, output);
- return ZSTDMT_flushStream_internal(zcs, output, 0);
+ DEBUGLOG(5, "ZSTDMT_flushStream");
+ if (zcs->nbThreads==1)
+ return ZSTD_flushStream(zcs->cctxPool->cctx[0], output);
+ return ZSTDMT_flushStream_internal(zcs, output, 0 /* endFrame */);
}
size_t ZSTDMT_endStream(ZSTDMT_CCtx* zcs, ZSTD_outBuffer* output)
{
- if (zcs->nbThreads==1) return ZSTD_endStream(zcs->cstream, output);
- return ZSTDMT_flushStream_internal(zcs, output, 1);
+ DEBUGLOG(4, "ZSTDMT_endStream");
+ if (zcs->nbThreads==1)
+ return ZSTD_endStream(zcs->cctxPool->cctx[0], output);
+ return ZSTDMT_flushStream_internal(zcs, output, 1 /* endFrame */);
}
diff --git a/thirdparty/zstd/compress/zstdmt_compress.h b/thirdparty/zstd/compress/zstdmt_compress.h
index 27f78ee031..fad63b6d86 100644
--- a/thirdparty/zstd/compress/zstdmt_compress.h
+++ b/thirdparty/zstd/compress/zstdmt_compress.h
@@ -15,25 +15,34 @@
#endif
-/* Note : All prototypes defined in this file shall be considered experimental.
- * There is no guarantee of API continuity (yet) on any of these prototypes */
+/* Note : All prototypes defined in this file are labelled experimental.
+ * No guarantee of API continuity is provided on any of them.
+ * In fact, the expectation is that these prototypes will be replaced
+ * by ZSTD_compress_generic() API in the near future */
/* === Dependencies === */
-#include <stddef.h> /* size_t */
+#include <stddef.h> /* size_t */
#define ZSTD_STATIC_LINKING_ONLY /* ZSTD_parameters */
-#include "zstd.h" /* ZSTD_inBuffer, ZSTD_outBuffer, ZSTDLIB_API */
+#include "zstd.h" /* ZSTD_inBuffer, ZSTD_outBuffer, ZSTDLIB_API */
-/* === Simple one-pass functions === */
-
+/* === Memory management === */
typedef struct ZSTDMT_CCtx_s ZSTDMT_CCtx;
ZSTDLIB_API ZSTDMT_CCtx* ZSTDMT_createCCtx(unsigned nbThreads);
-ZSTDLIB_API size_t ZSTDMT_freeCCtx(ZSTDMT_CCtx* cctx);
+ZSTDLIB_API ZSTDMT_CCtx* ZSTDMT_createCCtx_advanced(unsigned nbThreads,
+ ZSTD_customMem cMem);
+ZSTDLIB_API size_t ZSTDMT_freeCCtx(ZSTDMT_CCtx* mtctx);
+
+ZSTDLIB_API size_t ZSTDMT_sizeof_CCtx(ZSTDMT_CCtx* mtctx);
+
+
+/* === Simple buffer-to-butter one-pass function === */
+
+ZSTDLIB_API size_t ZSTDMT_compressCCtx(ZSTDMT_CCtx* mtctx,
+ void* dst, size_t dstCapacity,
+ const void* src, size_t srcSize,
+ int compressionLevel);
-ZSTDLIB_API size_t ZSTDMT_compressCCtx(ZSTDMT_CCtx* cctx,
- void* dst, size_t dstCapacity,
- const void* src, size_t srcSize,
- int compressionLevel);
/* === Streaming functions === */
@@ -53,8 +62,22 @@ ZSTDLIB_API size_t ZSTDMT_endStream(ZSTDMT_CCtx* mtctx, ZSTD_outBuffer* output);
# define ZSTDMT_SECTION_SIZE_MIN (1U << 20) /* 1 MB - Minimum size of each compression job */
#endif
-ZSTDLIB_API size_t ZSTDMT_initCStream_advanced(ZSTDMT_CCtx* mtctx, const void* dict, size_t dictSize, /**< dict can be released after init, a local copy is preserved within zcs */
- ZSTD_parameters params, unsigned long long pledgedSrcSize); /**< pledgedSrcSize is optional and can be zero == unknown */
+ZSTDLIB_API size_t ZSTDMT_compress_advanced(ZSTDMT_CCtx* mtctx,
+ void* dst, size_t dstCapacity,
+ const void* src, size_t srcSize,
+ const ZSTD_CDict* cdict,
+ ZSTD_parameters const params,
+ unsigned overlapRLog);
+
+ZSTDLIB_API size_t ZSTDMT_initCStream_advanced(ZSTDMT_CCtx* mtctx,
+ const void* dict, size_t dictSize, /* dict can be released after init, a local copy is preserved within zcs */
+ ZSTD_parameters params,
+ unsigned long long pledgedSrcSize); /* pledgedSrcSize is optional and can be zero == unknown */
+
+ZSTDLIB_API size_t ZSTDMT_initCStream_usingCDict(ZSTDMT_CCtx* mtctx,
+ const ZSTD_CDict* cdict,
+ ZSTD_frameParameters fparams,
+ unsigned long long pledgedSrcSize); /* note : zero means empty */
/* ZSDTMT_parameter :
* List of parameters that can be set using ZSTDMT_setMTCtxParameter() */
@@ -71,6 +94,19 @@ typedef enum {
ZSTDLIB_API size_t ZSTDMT_setMTCtxParameter(ZSTDMT_CCtx* mtctx, ZSDTMT_parameter parameter, unsigned value);
+/*! ZSTDMT_compressStream_generic() :
+ * Combines ZSTDMT_compressStream() with ZSTDMT_flushStream() or ZSTDMT_endStream()
+ * depending on flush directive.
+ * @return : minimum amount of data still to be flushed
+ * 0 if fully flushed
+ * or an error code */
+ZSTDLIB_API size_t ZSTDMT_compressStream_generic(ZSTDMT_CCtx* mtctx,
+ ZSTD_outBuffer* output,
+ ZSTD_inBuffer* input,
+ ZSTD_EndDirective endOp);
+
+
+
#if defined (__cplusplus)
}
#endif
diff --git a/thirdparty/zstd/decompress/huf_decompress.c b/thirdparty/zstd/decompress/huf_decompress.c
index ea35c36201..2a1b70ea5e 100644
--- a/thirdparty/zstd/decompress/huf_decompress.c
+++ b/thirdparty/zstd/decompress/huf_decompress.c
@@ -67,6 +67,12 @@
#define HUF_STATIC_ASSERT(c) { enum { HUF_static_assert = 1/(int)(!!(c)) }; } /* use only *after* variable declarations */
+/* **************************************************************
+* Byte alignment for workSpace management
+****************************************************************/
+#define HUF_ALIGN(x, a) HUF_ALIGN_MASK((x), (a) - 1)
+#define HUF_ALIGN_MASK(x, mask) (((x) + (mask)) & ~(mask))
+
/*-***************************/
/* generic DTableDesc */
/*-***************************/
@@ -87,16 +93,28 @@ static DTableDesc HUF_getDTableDesc(const HUF_DTable* table)
typedef struct { BYTE byte; BYTE nbBits; } HUF_DEltX2; /* single-symbol decoding */
-size_t HUF_readDTableX2 (HUF_DTable* DTable, const void* src, size_t srcSize)
+size_t HUF_readDTableX2_wksp(HUF_DTable* DTable, const void* src, size_t srcSize, void* workSpace, size_t wkspSize)
{
- BYTE huffWeight[HUF_SYMBOLVALUE_MAX + 1];
- U32 rankVal[HUF_TABLELOG_ABSOLUTEMAX + 1]; /* large enough for values from 0 to 16 */
U32 tableLog = 0;
U32 nbSymbols = 0;
size_t iSize;
void* const dtPtr = DTable + 1;
HUF_DEltX2* const dt = (HUF_DEltX2*)dtPtr;
+ U32* rankVal;
+ BYTE* huffWeight;
+ size_t spaceUsed32 = 0;
+
+ rankVal = (U32 *)workSpace + spaceUsed32;
+ spaceUsed32 += HUF_TABLELOG_ABSOLUTEMAX + 1;
+ huffWeight = (BYTE *)((U32 *)workSpace + spaceUsed32);
+ spaceUsed32 += HUF_ALIGN(HUF_SYMBOLVALUE_MAX + 1, sizeof(U32)) >> 2;
+
+ if ((spaceUsed32 << 2) > wkspSize)
+ return ERROR(tableLog_tooLarge);
+ workSpace = (U32 *)workSpace + spaceUsed32;
+ wkspSize -= (spaceUsed32 << 2);
+
HUF_STATIC_ASSERT(sizeof(DTableDesc) == sizeof(HUF_DTable));
/* memset(huffWeight, 0, sizeof(huffWeight)); */ /* is not necessary, even though some analyzer complain ... */
@@ -135,6 +153,13 @@ size_t HUF_readDTableX2 (HUF_DTable* DTable, const void* src, size_t srcSize)
return iSize;
}
+size_t HUF_readDTableX2(HUF_DTable* DTable, const void* src, size_t srcSize)
+{
+ U32 workSpace[HUF_DECOMPRESS_WORKSPACE_SIZE_U32];
+ return HUF_readDTableX2_wksp(DTable, src, srcSize,
+ workSpace, sizeof(workSpace));
+}
+
static BYTE HUF_decodeSymbolX2(BIT_DStream_t* Dstream, const HUF_DEltX2* dt, const U32 dtLog)
{
@@ -212,11 +237,13 @@ size_t HUF_decompress1X2_usingDTable(
return HUF_decompress1X2_usingDTable_internal(dst, dstSize, cSrc, cSrcSize, DTable);
}
-size_t HUF_decompress1X2_DCtx (HUF_DTable* DCtx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize)
+size_t HUF_decompress1X2_DCtx_wksp(HUF_DTable* DCtx, void* dst, size_t dstSize,
+ const void* cSrc, size_t cSrcSize,
+ void* workSpace, size_t wkspSize)
{
const BYTE* ip = (const BYTE*) cSrc;
- size_t const hSize = HUF_readDTableX2 (DCtx, cSrc, cSrcSize);
+ size_t const hSize = HUF_readDTableX2_wksp(DCtx, cSrc, cSrcSize, workSpace, wkspSize);
if (HUF_isError(hSize)) return hSize;
if (hSize >= cSrcSize) return ERROR(srcSize_wrong);
ip += hSize; cSrcSize -= hSize;
@@ -224,6 +251,15 @@ size_t HUF_decompress1X2_DCtx (HUF_DTable* DCtx, void* dst, size_t dstSize, cons
return HUF_decompress1X2_usingDTable_internal (dst, dstSize, ip, cSrcSize, DCtx);
}
+
+size_t HUF_decompress1X2_DCtx(HUF_DTable* DCtx, void* dst, size_t dstSize,
+ const void* cSrc, size_t cSrcSize)
+{
+ U32 workSpace[HUF_DECOMPRESS_WORKSPACE_SIZE_U32];
+ return HUF_decompress1X2_DCtx_wksp(DCtx, dst, dstSize, cSrc, cSrcSize,
+ workSpace, sizeof(workSpace));
+}
+
size_t HUF_decompress1X2 (void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize)
{
HUF_CREATE_STATIC_DTABLEX2(DTable, HUF_TABLELOG_MAX);
@@ -335,11 +371,14 @@ size_t HUF_decompress4X2_usingDTable(
}
-size_t HUF_decompress4X2_DCtx (HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize)
+size_t HUF_decompress4X2_DCtx_wksp(HUF_DTable* dctx, void* dst, size_t dstSize,
+ const void* cSrc, size_t cSrcSize,
+ void* workSpace, size_t wkspSize)
{
const BYTE* ip = (const BYTE*) cSrc;
- size_t const hSize = HUF_readDTableX2 (dctx, cSrc, cSrcSize);
+ size_t const hSize = HUF_readDTableX2_wksp (dctx, cSrc, cSrcSize,
+ workSpace, wkspSize);
if (HUF_isError(hSize)) return hSize;
if (hSize >= cSrcSize) return ERROR(srcSize_wrong);
ip += hSize; cSrcSize -= hSize;
@@ -347,6 +386,13 @@ size_t HUF_decompress4X2_DCtx (HUF_DTable* dctx, void* dst, size_t dstSize, cons
return HUF_decompress4X2_usingDTable_internal (dst, dstSize, ip, cSrcSize, dctx);
}
+
+size_t HUF_decompress4X2_DCtx (HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize)
+{
+ U32 workSpace[HUF_DECOMPRESS_WORKSPACE_SIZE_U32];
+ return HUF_decompress4X2_DCtx_wksp(dctx, dst, dstSize, cSrc, cSrcSize,
+ workSpace, sizeof(workSpace));
+}
size_t HUF_decompress4X2 (void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize)
{
HUF_CREATE_STATIC_DTABLEX2(DTable, HUF_TABLELOG_MAX);
@@ -403,7 +449,8 @@ static void HUF_fillDTableX4Level2(HUF_DEltX4* DTable, U32 sizeLog, const U32 co
} }
}
-typedef U32 rankVal_t[HUF_TABLELOG_MAX][HUF_TABLELOG_MAX + 1];
+typedef U32 rankValCol_t[HUF_TABLELOG_MAX + 1];
+typedef rankValCol_t rankVal_t[HUF_TABLELOG_MAX];
static void HUF_fillDTableX4(HUF_DEltX4* DTable, const U32 targetLog,
const sortedSymbol_t* sortedList, const U32 sortedListSize,
@@ -447,20 +494,43 @@ static void HUF_fillDTableX4(HUF_DEltX4* DTable, const U32 targetLog,
}
}
-size_t HUF_readDTableX4 (HUF_DTable* DTable, const void* src, size_t srcSize)
+size_t HUF_readDTableX4_wksp(HUF_DTable* DTable, const void* src,
+ size_t srcSize, void* workSpace,
+ size_t wkspSize)
{
- BYTE weightList[HUF_SYMBOLVALUE_MAX + 1];
- sortedSymbol_t sortedSymbol[HUF_SYMBOLVALUE_MAX + 1];
- U32 rankStats[HUF_TABLELOG_MAX + 1] = { 0 };
- U32 rankStart0[HUF_TABLELOG_MAX + 2] = { 0 };
- U32* const rankStart = rankStart0+1;
- rankVal_t rankVal;
U32 tableLog, maxW, sizeOfSort, nbSymbols;
DTableDesc dtd = HUF_getDTableDesc(DTable);
U32 const maxTableLog = dtd.maxTableLog;
size_t iSize;
void* dtPtr = DTable+1; /* force compiler to avoid strict-aliasing */
HUF_DEltX4* const dt = (HUF_DEltX4*)dtPtr;
+ U32 *rankStart;
+
+ rankValCol_t* rankVal;
+ U32* rankStats;
+ U32* rankStart0;
+ sortedSymbol_t* sortedSymbol;
+ BYTE* weightList;
+ size_t spaceUsed32 = 0;
+
+ rankVal = (rankValCol_t *)((U32 *)workSpace + spaceUsed32);
+ spaceUsed32 += (sizeof(rankValCol_t) * HUF_TABLELOG_MAX) >> 2;
+ rankStats = (U32 *)workSpace + spaceUsed32;
+ spaceUsed32 += HUF_TABLELOG_MAX + 1;
+ rankStart0 = (U32 *)workSpace + spaceUsed32;
+ spaceUsed32 += HUF_TABLELOG_MAX + 2;
+ sortedSymbol = (sortedSymbol_t *)workSpace + (spaceUsed32 * sizeof(U32)) / sizeof(sortedSymbol_t);
+ spaceUsed32 += HUF_ALIGN(sizeof(sortedSymbol_t) * (HUF_SYMBOLVALUE_MAX + 1), sizeof(U32)) >> 2;
+ weightList = (BYTE *)((U32 *)workSpace + spaceUsed32);
+ spaceUsed32 += HUF_ALIGN(HUF_SYMBOLVALUE_MAX + 1, sizeof(U32)) >> 2;
+
+ if ((spaceUsed32 << 2) > wkspSize)
+ return ERROR(tableLog_tooLarge);
+ workSpace = (U32 *)workSpace + spaceUsed32;
+ wkspSize -= (spaceUsed32 << 2);
+
+ rankStart = rankStart0 + 1;
+ memset(rankStats, 0, sizeof(U32) * (2 * HUF_TABLELOG_MAX + 2 + 1));
HUF_STATIC_ASSERT(sizeof(HUF_DEltX4) == sizeof(HUF_DTable)); /* if compiler fails here, assertion is wrong */
if (maxTableLog > HUF_TABLELOG_MAX) return ERROR(tableLog_tooLarge);
@@ -527,6 +597,12 @@ size_t HUF_readDTableX4 (HUF_DTable* DTable, const void* src, size_t srcSize)
return iSize;
}
+size_t HUF_readDTableX4(HUF_DTable* DTable, const void* src, size_t srcSize)
+{
+ U32 workSpace[HUF_DECOMPRESS_WORKSPACE_SIZE_U32];
+ return HUF_readDTableX4_wksp(DTable, src, srcSize,
+ workSpace, sizeof(workSpace));
+}
static U32 HUF_decodeSymbolX4(void* op, BIT_DStream_t* DStream, const HUF_DEltX4* dt, const U32 dtLog)
{
@@ -545,7 +621,8 @@ static U32 HUF_decodeLastSymbolX4(void* op, BIT_DStream_t* DStream, const HUF_DE
if (DStream->bitsConsumed < (sizeof(DStream->bitContainer)*8)) {
BIT_skipBits(DStream, dt[val].nbBits);
if (DStream->bitsConsumed > (sizeof(DStream->bitContainer)*8))
- DStream->bitsConsumed = (sizeof(DStream->bitContainer)*8); /* ugly hack; works only because it's the last symbol. Note : can't easily extract nbBits from just this symbol */
+ /* ugly hack; works only because it's the last symbol. Note : can't easily extract nbBits from just this symbol */
+ DStream->bitsConsumed = (sizeof(DStream->bitContainer)*8);
} }
return 1;
}
@@ -626,11 +703,14 @@ size_t HUF_decompress1X4_usingDTable(
return HUF_decompress1X4_usingDTable_internal(dst, dstSize, cSrc, cSrcSize, DTable);
}
-size_t HUF_decompress1X4_DCtx (HUF_DTable* DCtx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize)
+size_t HUF_decompress1X4_DCtx_wksp(HUF_DTable* DCtx, void* dst, size_t dstSize,
+ const void* cSrc, size_t cSrcSize,
+ void* workSpace, size_t wkspSize)
{
const BYTE* ip = (const BYTE*) cSrc;
- size_t const hSize = HUF_readDTableX4 (DCtx, cSrc, cSrcSize);
+ size_t const hSize = HUF_readDTableX4_wksp(DCtx, cSrc, cSrcSize,
+ workSpace, wkspSize);
if (HUF_isError(hSize)) return hSize;
if (hSize >= cSrcSize) return ERROR(srcSize_wrong);
ip += hSize; cSrcSize -= hSize;
@@ -638,6 +718,15 @@ size_t HUF_decompress1X4_DCtx (HUF_DTable* DCtx, void* dst, size_t dstSize, cons
return HUF_decompress1X4_usingDTable_internal (dst, dstSize, ip, cSrcSize, DCtx);
}
+
+size_t HUF_decompress1X4_DCtx(HUF_DTable* DCtx, void* dst, size_t dstSize,
+ const void* cSrc, size_t cSrcSize)
+{
+ U32 workSpace[HUF_DECOMPRESS_WORKSPACE_SIZE_U32];
+ return HUF_decompress1X4_DCtx_wksp(DCtx, dst, dstSize, cSrc, cSrcSize,
+ workSpace, sizeof(workSpace));
+}
+
size_t HUF_decompress1X4 (void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize)
{
HUF_CREATE_STATIC_DTABLEX4(DTable, HUF_TABLELOG_MAX);
@@ -748,11 +837,14 @@ size_t HUF_decompress4X4_usingDTable(
}
-size_t HUF_decompress4X4_DCtx (HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize)
+size_t HUF_decompress4X4_DCtx_wksp(HUF_DTable* dctx, void* dst, size_t dstSize,
+ const void* cSrc, size_t cSrcSize,
+ void* workSpace, size_t wkspSize)
{
const BYTE* ip = (const BYTE*) cSrc;
- size_t hSize = HUF_readDTableX4 (dctx, cSrc, cSrcSize);
+ size_t hSize = HUF_readDTableX4_wksp(dctx, cSrc, cSrcSize,
+ workSpace, wkspSize);
if (HUF_isError(hSize)) return hSize;
if (hSize >= cSrcSize) return ERROR(srcSize_wrong);
ip += hSize; cSrcSize -= hSize;
@@ -760,6 +852,15 @@ size_t HUF_decompress4X4_DCtx (HUF_DTable* dctx, void* dst, size_t dstSize, cons
return HUF_decompress4X4_usingDTable_internal(dst, dstSize, ip, cSrcSize, dctx);
}
+
+size_t HUF_decompress4X4_DCtx(HUF_DTable* dctx, void* dst, size_t dstSize,
+ const void* cSrc, size_t cSrcSize)
+{
+ U32 workSpace[HUF_DECOMPRESS_WORKSPACE_SIZE_U32];
+ return HUF_decompress4X4_DCtx_wksp(dctx, dst, dstSize, cSrc, cSrcSize,
+ workSpace, sizeof(workSpace));
+}
+
size_t HUF_decompress4X4 (void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize)
{
HUF_CREATE_STATIC_DTABLEX4(DTable, HUF_TABLELOG_MAX);
@@ -861,19 +962,32 @@ size_t HUF_decompress4X_DCtx (HUF_DTable* dctx, void* dst, size_t dstSize, const
}
}
-size_t HUF_decompress4X_hufOnly (HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize)
+size_t HUF_decompress4X_hufOnly(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize)
+{
+ U32 workSpace[HUF_DECOMPRESS_WORKSPACE_SIZE_U32];
+ return HUF_decompress4X_hufOnly_wksp(dctx, dst, dstSize, cSrc, cSrcSize,
+ workSpace, sizeof(workSpace));
+}
+
+
+size_t HUF_decompress4X_hufOnly_wksp(HUF_DTable* dctx, void* dst,
+ size_t dstSize, const void* cSrc,
+ size_t cSrcSize, void* workSpace,
+ size_t wkspSize)
{
/* validation checks */
if (dstSize == 0) return ERROR(dstSize_tooSmall);
if ((cSrcSize >= dstSize) || (cSrcSize <= 1)) return ERROR(corruption_detected); /* invalid */
{ U32 const algoNb = HUF_selectDecoder(dstSize, cSrcSize);
- return algoNb ? HUF_decompress4X4_DCtx(dctx, dst, dstSize, cSrc, cSrcSize) :
- HUF_decompress4X2_DCtx(dctx, dst, dstSize, cSrc, cSrcSize) ;
+ return algoNb ? HUF_decompress4X4_DCtx_wksp(dctx, dst, dstSize, cSrc, cSrcSize, workSpace, wkspSize):
+ HUF_decompress4X2_DCtx_wksp(dctx, dst, dstSize, cSrc, cSrcSize, workSpace, wkspSize);
}
}
-size_t HUF_decompress1X_DCtx (HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize)
+size_t HUF_decompress1X_DCtx_wksp(HUF_DTable* dctx, void* dst, size_t dstSize,
+ const void* cSrc, size_t cSrcSize,
+ void* workSpace, size_t wkspSize)
{
/* validation checks */
if (dstSize == 0) return ERROR(dstSize_tooSmall);
@@ -882,7 +996,17 @@ size_t HUF_decompress1X_DCtx (HUF_DTable* dctx, void* dst, size_t dstSize, const
if (cSrcSize == 1) { memset(dst, *(const BYTE*)cSrc, dstSize); return dstSize; } /* RLE */
{ U32 const algoNb = HUF_selectDecoder(dstSize, cSrcSize);
- return algoNb ? HUF_decompress1X4_DCtx(dctx, dst, dstSize, cSrc, cSrcSize) :
- HUF_decompress1X2_DCtx(dctx, dst, dstSize, cSrc, cSrcSize) ;
+ return algoNb ? HUF_decompress1X4_DCtx_wksp(dctx, dst, dstSize, cSrc,
+ cSrcSize, workSpace, wkspSize):
+ HUF_decompress1X2_DCtx_wksp(dctx, dst, dstSize, cSrc,
+ cSrcSize, workSpace, wkspSize);
}
}
+
+size_t HUF_decompress1X_DCtx(HUF_DTable* dctx, void* dst, size_t dstSize,
+ const void* cSrc, size_t cSrcSize)
+{
+ U32 workSpace[HUF_DECOMPRESS_WORKSPACE_SIZE_U32];
+ return HUF_decompress1X_DCtx_wksp(dctx, dst, dstSize, cSrc, cSrcSize,
+ workSpace, sizeof(workSpace));
+}
diff --git a/thirdparty/zstd/decompress/zstd_decompress.c b/thirdparty/zstd/decompress/zstd_decompress.c
index 910f9ab783..465bcc20b5 100644
--- a/thirdparty/zstd/decompress/zstd_decompress.c
+++ b/thirdparty/zstd/decompress/zstd_decompress.c
@@ -53,8 +53,7 @@
# include "zstd_legacy.h"
#endif
-
-#if defined(_MSC_VER)
+#if defined(_MSC_VER) && (defined(_M_X64) || defined(_M_I86)) /* _mm_prefetch() is not defined outside of x86/x64 */
# include <mmintrin.h> /* https://msdn.microsoft.com/fr-fr/library/84szxsww(v=vs.90).aspx */
# define ZSTD_PREFETCH(ptr) _mm_prefetch((const char*)ptr, _MM_HINT_T0)
#elif defined(__GNUC__)
@@ -63,8 +62,9 @@
# define ZSTD_PREFETCH(ptr) /* disabled */
#endif
+
/*-*************************************
-* Macros
+* Errors
***************************************/
#define ZSTD_isError ERR_isError /* for inlining */
#define FSE_isError ERR_isError
@@ -85,11 +85,15 @@ typedef enum { ZSTDds_getFrameHeaderSize, ZSTDds_decodeFrameHeader,
ZSTDds_decompressLastBlock, ZSTDds_checkChecksum,
ZSTDds_decodeSkippableHeader, ZSTDds_skipFrame } ZSTD_dStage;
+typedef enum { zdss_init=0, zdss_loadHeader,
+ zdss_read, zdss_load, zdss_flush } ZSTD_dStreamStage;
+
typedef struct {
FSE_DTable LLTable[FSE_DTABLE_SIZE_U32(LLFSELog)];
FSE_DTable OFTable[FSE_DTABLE_SIZE_U32(OffFSELog)];
FSE_DTable MLTable[FSE_DTABLE_SIZE_U32(MLFSELog)];
HUF_DTable hufTable[HUF_DTABLE_SIZE(HufLog)]; /* can accommodate HUF_decompress4X */
+ U32 workspace[HUF_DECOMPRESS_WORKSPACE_SIZE_U32];
U32 rep[ZSTD_REP_NUM];
} ZSTD_entropyTables_t;
@@ -105,7 +109,7 @@ struct ZSTD_DCtx_s
const void* vBase; /* virtual start of previous segment if it was just before current one */
const void* dictEnd; /* end of previous segment */
size_t expected;
- ZSTD_frameParams fParams;
+ ZSTD_frameHeader fParams;
blockType_e bType; /* used in ZSTD_decompressContinue(), to transfer blockType between header decoding and block decoding stages */
ZSTD_dStage stage;
U32 litEntropy;
@@ -117,11 +121,39 @@ struct ZSTD_DCtx_s
ZSTD_customMem customMem;
size_t litSize;
size_t rleSize;
- BYTE litBuffer[ZSTD_BLOCKSIZE_ABSOLUTEMAX + WILDCOPY_OVERLENGTH];
+ size_t staticSize;
+
+ /* streaming */
+ ZSTD_DDict* ddictLocal;
+ const ZSTD_DDict* ddict;
+ ZSTD_dStreamStage streamStage;
+ char* inBuff;
+ size_t inBuffSize;
+ size_t inPos;
+ size_t maxWindowSize;
+ char* outBuff;
+ size_t outBuffSize;
+ size_t outStart;
+ size_t outEnd;
+ size_t blockSize;
+ size_t lhSize;
+ void* legacyContext;
+ U32 previousLegacyVersion;
+ U32 legacyVersion;
+ U32 hostageByte;
+
+ /* workspace */
+ BYTE litBuffer[ZSTD_BLOCKSIZE_MAX + WILDCOPY_OVERLENGTH];
BYTE headerBuffer[ZSTD_FRAMEHEADERSIZE_MAX];
}; /* typedef'd to ZSTD_DCtx within "zstd.h" */
-size_t ZSTD_sizeof_DCtx (const ZSTD_DCtx* dctx) { return (dctx==NULL) ? 0 : sizeof(ZSTD_DCtx); }
+size_t ZSTD_sizeof_DCtx (const ZSTD_DCtx* dctx)
+{
+ if (dctx==NULL) return 0; /* support sizeof NULL */
+ return sizeof(*dctx)
+ + ZSTD_sizeof_DDict(dctx->ddictLocal)
+ + dctx->inBuffSize + dctx->outBuffSize;
+}
size_t ZSTD_estimateDCtxSize(void) { return sizeof(ZSTD_DCtx); }
@@ -145,40 +177,76 @@ size_t ZSTD_decompressBegin(ZSTD_DCtx* dctx)
return 0;
}
+static void ZSTD_initDCtx_internal(ZSTD_DCtx* dctx)
+{
+ ZSTD_decompressBegin(dctx); /* cannot fail */
+ dctx->staticSize = 0;
+ dctx->maxWindowSize = ZSTD_MAXWINDOWSIZE_DEFAULT;
+ dctx->ddict = NULL;
+ dctx->ddictLocal = NULL;
+ dctx->inBuff = NULL;
+ dctx->inBuffSize = 0;
+ dctx->outBuffSize= 0;
+ dctx->streamStage = zdss_init;
+}
+
ZSTD_DCtx* ZSTD_createDCtx_advanced(ZSTD_customMem customMem)
{
- ZSTD_DCtx* dctx;
+ if (!customMem.customAlloc ^ !customMem.customFree) return NULL;
- if (!customMem.customAlloc && !customMem.customFree) customMem = defaultCustomMem;
- if (!customMem.customAlloc || !customMem.customFree) return NULL;
+ { ZSTD_DCtx* const dctx = (ZSTD_DCtx*)ZSTD_malloc(sizeof(*dctx), customMem);
+ if (!dctx) return NULL;
+ dctx->customMem = customMem;
+ dctx->legacyContext = NULL;
+ dctx->previousLegacyVersion = 0;
+ ZSTD_initDCtx_internal(dctx);
+ return dctx;
+ }
+}
- dctx = (ZSTD_DCtx*)ZSTD_malloc(sizeof(ZSTD_DCtx), customMem);
- if (!dctx) return NULL;
- memcpy(&dctx->customMem, &customMem, sizeof(customMem));
- ZSTD_decompressBegin(dctx);
+ZSTD_DCtx* ZSTD_initStaticDCtx(void *workspace, size_t workspaceSize)
+{
+ ZSTD_DCtx* dctx = (ZSTD_DCtx*) workspace;
+
+ if ((size_t)workspace & 7) return NULL; /* 8-aligned */
+ if (workspaceSize < sizeof(ZSTD_DCtx)) return NULL; /* minimum size */
+
+ ZSTD_initDCtx_internal(dctx);
+ dctx->staticSize = workspaceSize;
+ dctx->inBuff = (char*)(dctx+1);
return dctx;
}
ZSTD_DCtx* ZSTD_createDCtx(void)
{
- return ZSTD_createDCtx_advanced(defaultCustomMem);
+ return ZSTD_createDCtx_advanced(ZSTD_defaultCMem);
}
size_t ZSTD_freeDCtx(ZSTD_DCtx* dctx)
{
if (dctx==NULL) return 0; /* support free on NULL */
- ZSTD_free(dctx, dctx->customMem);
- return 0; /* reserved as a potential error code in the future */
+ if (dctx->staticSize) return ERROR(memory_allocation); /* not compatible with static DCtx */
+ { ZSTD_customMem const cMem = dctx->customMem;
+ ZSTD_freeDDict(dctx->ddictLocal);
+ dctx->ddictLocal = NULL;
+ ZSTD_free(dctx->inBuff, cMem);
+ dctx->inBuff = NULL;
+#if defined(ZSTD_LEGACY_SUPPORT) && (ZSTD_LEGACY_SUPPORT >= 1)
+ if (dctx->legacyContext)
+ ZSTD_freeLegacyStreamContext(dctx->legacyContext, dctx->previousLegacyVersion);
+#endif
+ ZSTD_free(dctx, cMem);
+ return 0;
+ }
}
+/* no longer useful */
void ZSTD_copyDCtx(ZSTD_DCtx* dstDCtx, const ZSTD_DCtx* srcDCtx)
{
- size_t const workSpaceSize = (ZSTD_BLOCKSIZE_ABSOLUTEMAX+WILDCOPY_OVERLENGTH) + ZSTD_frameHeaderSize_max;
- memcpy(dstDCtx, srcDCtx, sizeof(ZSTD_DCtx) - workSpaceSize); /* no need to copy workspace */
+ size_t const toCopy = (size_t)((char*)(&dstDCtx->inBuff) - (char*)dstDCtx);
+ memcpy(dstDCtx, srcDCtx, toCopy); /* no need to copy workspace */
}
-static void ZSTD_refDDict(ZSTD_DCtx* dstDCtx, const ZSTD_DDict* ddict);
-
/*-*************************************************************
* Decompression section
@@ -206,7 +274,7 @@ unsigned ZSTD_isFrame(const void* buffer, size_t size)
/** ZSTD_frameHeaderSize() :
* srcSize must be >= ZSTD_frameHeaderSize_prefix.
* @return : size of the Frame Header */
-static size_t ZSTD_frameHeaderSize(const void* src, size_t srcSize)
+size_t ZSTD_frameHeaderSize(const void* src, size_t srcSize)
{
if (srcSize < ZSTD_frameHeaderSize_prefix) return ERROR(srcSize_wrong);
{ BYTE const fhd = ((const BYTE*)src)[4];
@@ -219,22 +287,24 @@ static size_t ZSTD_frameHeaderSize(const void* src, size_t srcSize)
}
-/** ZSTD_getFrameParams() :
+/** ZSTD_getFrameHeader() :
* decode Frame Header, or require larger `srcSize`.
-* @return : 0, `fparamsPtr` is correctly filled,
+* @return : 0, `zfhPtr` is correctly filled,
* >0, `srcSize` is too small, result is expected `srcSize`,
* or an error code, which can be tested using ZSTD_isError() */
-size_t ZSTD_getFrameParams(ZSTD_frameParams* fparamsPtr, const void* src, size_t srcSize)
+size_t ZSTD_getFrameHeader(ZSTD_frameHeader* zfhPtr, const void* src, size_t srcSize)
{
const BYTE* ip = (const BYTE*)src;
-
if (srcSize < ZSTD_frameHeaderSize_prefix) return ZSTD_frameHeaderSize_prefix;
+
if (MEM_readLE32(src) != ZSTD_MAGICNUMBER) {
if ((MEM_readLE32(src) & 0xFFFFFFF0U) == ZSTD_MAGIC_SKIPPABLE_START) {
- if (srcSize < ZSTD_skippableHeaderSize) return ZSTD_skippableHeaderSize; /* magic number + skippable frame length */
- memset(fparamsPtr, 0, sizeof(*fparamsPtr));
- fparamsPtr->frameContentSize = MEM_readLE32((const char *)src + 4);
- fparamsPtr->windowSize = 0; /* windowSize==0 means a frame is skippable */
+ /* skippable frame */
+ if (srcSize < ZSTD_skippableHeaderSize)
+ return ZSTD_skippableHeaderSize; /* magic number + frame length */
+ memset(zfhPtr, 0, sizeof(*zfhPtr));
+ zfhPtr->frameContentSize = MEM_readLE32((const char *)src + 4);
+ zfhPtr->windowSize = 0; /* windowSize==0 means a frame is skippable */
return 0;
}
return ERROR(prefix_unknown);
@@ -254,11 +324,13 @@ size_t ZSTD_getFrameParams(ZSTD_frameParams* fparamsPtr, const void* src, size_t
U32 windowSize = 0;
U32 dictID = 0;
U64 frameContentSize = 0;
- if ((fhdByte & 0x08) != 0) return ERROR(frameParameter_unsupported); /* reserved bits, which must be zero */
+ if ((fhdByte & 0x08) != 0)
+ return ERROR(frameParameter_unsupported); /* reserved bits, must be zero */
if (!singleSegment) {
BYTE const wlByte = ip[pos++];
U32 const windowLog = (wlByte >> 3) + ZSTD_WINDOWLOG_ABSOLUTEMIN;
- if (windowLog > ZSTD_WINDOWLOG_MAX) return ERROR(frameParameter_windowTooLarge); /* avoids issue with 1 << windowLog */
+ if (windowLog > ZSTD_WINDOWLOG_MAX)
+ return ERROR(frameParameter_windowTooLarge);
windowSize = (1U << windowLog);
windowSize += (windowSize >> 3) * (wlByte&7);
}
@@ -281,10 +353,10 @@ size_t ZSTD_getFrameParams(ZSTD_frameParams* fparamsPtr, const void* src, size_t
}
if (!windowSize) windowSize = (U32)frameContentSize;
if (windowSize > windowSizeMax) return ERROR(frameParameter_windowTooLarge);
- fparamsPtr->frameContentSize = frameContentSize;
- fparamsPtr->windowSize = windowSize;
- fparamsPtr->dictID = dictID;
- fparamsPtr->checksumFlag = checksumFlag;
+ zfhPtr->frameContentSize = frameContentSize;
+ zfhPtr->windowSize = windowSize;
+ zfhPtr->dictID = dictID;
+ zfhPtr->checksumFlag = checksumFlag;
}
return 0;
}
@@ -302,9 +374,8 @@ unsigned long long ZSTD_getFrameContentSize(const void *src, size_t srcSize)
return ret == 0 ? ZSTD_CONTENTSIZE_UNKNOWN : ret;
}
#endif
- {
- ZSTD_frameParams fParams;
- if (ZSTD_getFrameParams(&fParams, src, srcSize) != 0) return ZSTD_CONTENTSIZE_ERROR;
+ { ZSTD_frameHeader fParams;
+ if (ZSTD_getFrameHeader(&fParams, src, srcSize) != 0) return ZSTD_CONTENTSIZE_ERROR;
if (fParams.windowSize == 0) {
/* Either skippable or empty frame, size == 0 either way */
return 0;
@@ -323,51 +394,48 @@ unsigned long long ZSTD_getFrameContentSize(const void *src, size_t srcSize)
* @return : decompressed size of the frames contained */
unsigned long long ZSTD_findDecompressedSize(const void* src, size_t srcSize)
{
- {
- unsigned long long totalDstSize = 0;
- while (srcSize >= ZSTD_frameHeaderSize_prefix) {
- const U32 magicNumber = MEM_readLE32(src);
-
- if ((magicNumber & 0xFFFFFFF0U) == ZSTD_MAGIC_SKIPPABLE_START) {
- size_t skippableSize;
- if (srcSize < ZSTD_skippableHeaderSize)
- return ERROR(srcSize_wrong);
- skippableSize = MEM_readLE32((const BYTE *)src + 4) +
- ZSTD_skippableHeaderSize;
- if (srcSize < skippableSize) {
- return ZSTD_CONTENTSIZE_ERROR;
- }
+ unsigned long long totalDstSize = 0;
- src = (const BYTE *)src + skippableSize;
- srcSize -= skippableSize;
- continue;
+ while (srcSize >= ZSTD_frameHeaderSize_prefix) {
+ const U32 magicNumber = MEM_readLE32(src);
+
+ if ((magicNumber & 0xFFFFFFF0U) == ZSTD_MAGIC_SKIPPABLE_START) {
+ size_t skippableSize;
+ if (srcSize < ZSTD_skippableHeaderSize)
+ return ERROR(srcSize_wrong);
+ skippableSize = MEM_readLE32((const BYTE *)src + 4) +
+ ZSTD_skippableHeaderSize;
+ if (srcSize < skippableSize) {
+ return ZSTD_CONTENTSIZE_ERROR;
}
- {
- unsigned long long const ret = ZSTD_getFrameContentSize(src, srcSize);
- if (ret >= ZSTD_CONTENTSIZE_ERROR) return ret;
+ src = (const BYTE *)src + skippableSize;
+ srcSize -= skippableSize;
+ continue;
+ }
- /* check for overflow */
- if (totalDstSize + ret < totalDstSize) return ZSTD_CONTENTSIZE_ERROR;
- totalDstSize += ret;
- }
- {
- size_t const frameSrcSize = ZSTD_findFrameCompressedSize(src, srcSize);
- if (ZSTD_isError(frameSrcSize)) {
- return ZSTD_CONTENTSIZE_ERROR;
- }
+ { unsigned long long const ret = ZSTD_getFrameContentSize(src, srcSize);
+ if (ret >= ZSTD_CONTENTSIZE_ERROR) return ret;
- src = (const BYTE *)src + frameSrcSize;
- srcSize -= frameSrcSize;
- }
+ /* check for overflow */
+ if (totalDstSize + ret < totalDstSize) return ZSTD_CONTENTSIZE_ERROR;
+ totalDstSize += ret;
}
+ { size_t const frameSrcSize = ZSTD_findFrameCompressedSize(src, srcSize);
+ if (ZSTD_isError(frameSrcSize)) {
+ return ZSTD_CONTENTSIZE_ERROR;
+ }
- if (srcSize) {
- return ZSTD_CONTENTSIZE_ERROR;
+ src = (const BYTE *)src + frameSrcSize;
+ srcSize -= frameSrcSize;
}
+ }
- return totalDstSize;
+ if (srcSize) {
+ return ZSTD_CONTENTSIZE_ERROR;
}
+
+ return totalDstSize;
}
/** ZSTD_getDecompressedSize() :
@@ -389,7 +457,7 @@ unsigned long long ZSTD_getDecompressedSize(const void* src, size_t srcSize)
* @return : 0 if success, or an error code, which can be tested using ZSTD_isError() */
static size_t ZSTD_decodeFrameHeader(ZSTD_DCtx* dctx, const void* src, size_t headerSize)
{
- size_t const result = ZSTD_getFrameParams(&(dctx->fParams), src, headerSize);
+ size_t const result = ZSTD_getFrameHeader(&(dctx->fParams), src, headerSize);
if (ZSTD_isError(result)) return result; /* invalid header */
if (result>0) return ERROR(srcSize_wrong); /* headerSize too small */
if (dctx->fParams.dictID && (dctx->dictID != dctx->fParams.dictID)) return ERROR(dictionary_wrong);
@@ -398,13 +466,6 @@ static size_t ZSTD_decodeFrameHeader(ZSTD_DCtx* dctx, const void* src, size_t he
}
-typedef struct
-{
- blockType_e blockType;
- U32 lastBlock;
- U32 origSize;
-} blockProperties_t;
-
/*! ZSTD_getcBlockSize() :
* Provides the size of compressed block from block header `src` */
size_t ZSTD_getcBlockSize(const void* src, size_t srcSize,
@@ -485,7 +546,7 @@ size_t ZSTD_decodeLiteralsBlock(ZSTD_DCtx* dctx,
litCSize = (lhc >> 22) + (istart[4] << 10);
break;
}
- if (litSize > ZSTD_BLOCKSIZE_ABSOLUTEMAX) return ERROR(corruption_detected);
+ if (litSize > ZSTD_BLOCKSIZE_MAX) return ERROR(corruption_detected);
if (litCSize + lhSize > srcSize) return ERROR(corruption_detected);
if (HUF_isError((litEncType==set_repeat) ?
@@ -493,8 +554,10 @@ size_t ZSTD_decodeLiteralsBlock(ZSTD_DCtx* dctx,
HUF_decompress1X_usingDTable(dctx->litBuffer, litSize, istart+lhSize, litCSize, dctx->HUFptr) :
HUF_decompress4X_usingDTable(dctx->litBuffer, litSize, istart+lhSize, litCSize, dctx->HUFptr) ) :
( singleStream ?
- HUF_decompress1X2_DCtx(dctx->entropy.hufTable, dctx->litBuffer, litSize, istart+lhSize, litCSize) :
- HUF_decompress4X_hufOnly (dctx->entropy.hufTable, dctx->litBuffer, litSize, istart+lhSize, litCSize)) ))
+ HUF_decompress1X2_DCtx_wksp(dctx->entropy.hufTable, dctx->litBuffer, litSize, istart+lhSize, litCSize,
+ dctx->entropy.workspace, sizeof(dctx->entropy.workspace)) :
+ HUF_decompress4X_hufOnly_wksp(dctx->entropy.hufTable, dctx->litBuffer, litSize, istart+lhSize, litCSize,
+ dctx->entropy.workspace, sizeof(dctx->entropy.workspace)))))
return ERROR(corruption_detected);
dctx->litPtr = dctx->litBuffer;
@@ -557,7 +620,7 @@ size_t ZSTD_decodeLiteralsBlock(ZSTD_DCtx* dctx,
if (srcSize<4) return ERROR(corruption_detected); /* srcSize >= MIN_CBLOCK_SIZE == 3; here we need lhSize+1 = 4 */
break;
}
- if (litSize > ZSTD_BLOCKSIZE_ABSOLUTEMAX) return ERROR(corruption_detected);
+ if (litSize > ZSTD_BLOCKSIZE_MAX) return ERROR(corruption_detected);
memset(dctx->litBuffer, istart[lhSize], litSize + WILDCOPY_OVERLENGTH);
dctx->litPtr = dctx->litBuffer;
dctx->litSize = litSize;
@@ -684,6 +747,7 @@ size_t ZSTD_decodeSeqHeaders(ZSTD_DCtx* dctx, int* nbSeqPtr,
const BYTE* const istart = (const BYTE* const)src;
const BYTE* const iend = istart + srcSize;
const BYTE* ip = istart;
+ DEBUGLOG(5, "ZSTD_decodeSeqHeaders");
/* check */
if (srcSize < MIN_SEQUENCES_SIZE) return ERROR(srcSize_wrong);
@@ -864,12 +928,18 @@ static seq_t ZSTD_decodeSequence(seqState_t* seqState)
seq.offset = offset;
}
- seq.matchLength = ML_base[mlCode] + ((mlCode>31) ? BIT_readBitsFast(&seqState->DStream, mlBits) : 0); /* <= 16 bits */
+ seq.matchLength = ML_base[mlCode]
+ + ((mlCode>31) ? BIT_readBitsFast(&seqState->DStream, mlBits) : 0); /* <= 16 bits */
if (MEM_32bits() && (mlBits+llBits>24)) BIT_reloadDStream(&seqState->DStream);
- seq.litLength = LL_base[llCode] + ((llCode>15) ? BIT_readBitsFast(&seqState->DStream, llBits) : 0); /* <= 16 bits */
- if (MEM_32bits() ||
- (totalBits > 64 - 7 - (LLFSELog+MLFSELog+OffFSELog)) ) BIT_reloadDStream(&seqState->DStream);
+ seq.litLength = LL_base[llCode]
+ + ((llCode>15) ? BIT_readBitsFast(&seqState->DStream, llBits) : 0); /* <= 16 bits */
+ if ( MEM_32bits()
+ || (totalBits > 64 - 7 - (LLFSELog+MLFSELog+OffFSELog)) )
+ BIT_reloadDStream(&seqState->DStream);
+
+ DEBUGLOG(6, "seq: litL=%u, matchL=%u, offset=%u",
+ (U32)seq.litLength, (U32)seq.matchLength, (U32)seq.offset);
/* ANS state update */
FSE_updateState(&seqState->stateLL, &seqState->DStream); /* <= 9 bits */
@@ -909,7 +979,8 @@ size_t ZSTD_execSequence(BYTE* op,
/* copy Match */
if (sequence.offset > (size_t)(oLitEnd - base)) {
/* offset beyond prefix -> go into extDict */
- if (sequence.offset > (size_t)(oLitEnd - vBase)) return ERROR(corruption_detected);
+ if (sequence.offset > (size_t)(oLitEnd - vBase))
+ return ERROR(corruption_detected);
match = dictEnd + (match - base);
if (match + sequence.matchLength <= dictEnd) {
memmove(oLitEnd, match, sequence.matchLength);
@@ -977,9 +1048,12 @@ static size_t ZSTD_decompressSequences(
const BYTE* const vBase = (const BYTE*) (dctx->vBase);
const BYTE* const dictEnd = (const BYTE*) (dctx->dictEnd);
int nbSeq;
+ DEBUGLOG(5, "ZSTD_decompressSequences");
/* Build Decoding Tables */
{ size_t const seqHSize = ZSTD_decodeSeqHeaders(dctx, &nbSeq, ip, seqSize);
+ DEBUGLOG(5, "ZSTD_decodeSeqHeaders: size=%u, nbSeq=%i",
+ (U32)seqHSize, nbSeq);
if (ZSTD_isError(seqHSize)) return seqHSize;
ip += seqHSize;
}
@@ -998,11 +1072,13 @@ static size_t ZSTD_decompressSequences(
nbSeq--;
{ seq_t const sequence = ZSTD_decodeSequence(&seqState);
size_t const oneSeqSize = ZSTD_execSequence(op, oend, sequence, &litPtr, litEnd, base, vBase, dictEnd);
+ DEBUGLOG(6, "regenerated sequence size : %u", (U32)oneSeqSize);
if (ZSTD_isError(oneSeqSize)) return oneSeqSize;
op += oneSeqSize;
} }
/* check if reached exact end */
+ DEBUGLOG(5, "after decode loop, remaining nbSeq : %i", nbSeq);
if (nbSeq) return ERROR(corruption_detected);
/* save reps for next block */
{ U32 i; for (i=0; i<ZSTD_REP_NUM; i++) dctx->entropy.rep[i] = (U32)(seqState.prevOffset[i]); }
@@ -1216,7 +1292,7 @@ static size_t ZSTD_decompressSequencesLong(
const BYTE* const base = (const BYTE*) (dctx->base);
const BYTE* const vBase = (const BYTE*) (dctx->vBase);
const BYTE* const dictEnd = (const BYTE*) (dctx->dictEnd);
- unsigned const windowSize = dctx->fParams.windowSize;
+ unsigned const windowSize32 = (unsigned)dctx->fParams.windowSize;
int nbSeq;
/* Build Decoding Tables */
@@ -1246,13 +1322,13 @@ static size_t ZSTD_decompressSequencesLong(
/* prepare in advance */
for (seqNb=0; (BIT_reloadDStream(&seqState.DStream) <= BIT_DStream_completed) && seqNb<seqAdvance; seqNb++) {
- sequences[seqNb] = ZSTD_decodeSequenceLong(&seqState, windowSize);
+ sequences[seqNb] = ZSTD_decodeSequenceLong(&seqState, windowSize32);
}
if (seqNb<seqAdvance) return ERROR(corruption_detected);
/* decode and decompress */
for ( ; (BIT_reloadDStream(&(seqState.DStream)) <= BIT_DStream_completed) && seqNb<nbSeq ; seqNb++) {
- seq_t const sequence = ZSTD_decodeSequenceLong(&seqState, windowSize);
+ seq_t const sequence = ZSTD_decodeSequenceLong(&seqState, windowSize32);
size_t const oneSeqSize = ZSTD_execSequenceLong(op, oend, sequences[(seqNb-ADVANCED_SEQS) & STOSEQ_MASK], &litPtr, litEnd, base, vBase, dictEnd);
if (ZSTD_isError(oneSeqSize)) return oneSeqSize;
ZSTD_PREFETCH(sequence.match);
@@ -1289,11 +1365,13 @@ static size_t ZSTD_decompressBlock_internal(ZSTD_DCtx* dctx,
const void* src, size_t srcSize)
{ /* blockType == blockCompressed */
const BYTE* ip = (const BYTE*)src;
+ DEBUGLOG(5, "ZSTD_decompressBlock_internal");
- if (srcSize >= ZSTD_BLOCKSIZE_ABSOLUTEMAX) return ERROR(srcSize_wrong);
+ if (srcSize >= ZSTD_BLOCKSIZE_MAX) return ERROR(srcSize_wrong);
/* Decode literals section */
{ size_t const litCSize = ZSTD_decodeLiteralsBlock(dctx, src, srcSize);
+ DEBUGLOG(5, "ZSTD_decodeLiteralsBlock : %u", (U32)litCSize);
if (ZSTD_isError(litCSize)) return litCSize;
ip += litCSize;
srcSize -= litCSize;
@@ -1364,13 +1442,13 @@ size_t ZSTD_findFrameCompressedSize(const void *src, size_t srcSize)
const BYTE* ip = (const BYTE*)src;
const BYTE* const ipstart = ip;
size_t remainingSize = srcSize;
- ZSTD_frameParams fParams;
+ ZSTD_frameHeader fParams;
size_t const headerSize = ZSTD_frameHeaderSize(ip, remainingSize);
if (ZSTD_isError(headerSize)) return headerSize;
/* Frame Header */
- { size_t const ret = ZSTD_getFrameParams(&fParams, ip, remainingSize);
+ { size_t const ret = ZSTD_getFrameHeader(&fParams, ip, remainingSize);
if (ZSTD_isError(ret)) return ret;
if (ret > 0) return ERROR(srcSize_wrong);
}
@@ -1505,6 +1583,8 @@ static size_t ZSTD_decompressMultiFrame(ZSTD_DCtx* dctx,
size_t decodedSize;
size_t const frameSize = ZSTD_findFrameCompressedSizeLegacy(src, srcSize);
if (ZSTD_isError(frameSize)) return frameSize;
+ /* legacy support is incompatible with static dctx */
+ if (dctx->staticSize) return ERROR(memory_allocation);
decodedSize = ZSTD_decompressLegacy(dst, dstCapacity, src, frameSize, dict, dictSize);
@@ -1540,7 +1620,7 @@ static size_t ZSTD_decompressMultiFrame(ZSTD_DCtx* dctx,
if (ddict) {
/* we were called from ZSTD_decompress_usingDDict */
- ZSTD_refDDict(dctx, ddict);
+ CHECK_F(ZSTD_decompressBegin_usingDDict(dctx, ddict));
} else {
/* this will initialize correctly with no dict if dict == NULL, so
* use this in all cases but ddict */
@@ -1580,7 +1660,7 @@ size_t ZSTD_decompressDCtx(ZSTD_DCtx* dctx, void* dst, size_t dstCapacity, const
size_t ZSTD_decompress(void* dst, size_t dstCapacity, const void* src, size_t srcSize)
{
-#if defined(ZSTD_HEAPMODE) && (ZSTD_HEAPMODE==1)
+#if defined(ZSTD_HEAPMODE) && (ZSTD_HEAPMODE>=1)
size_t regenSize;
ZSTD_DCtx* const dctx = ZSTD_createDCtx();
if (dctx==NULL) return ERROR(memory_allocation);
@@ -1604,6 +1684,7 @@ ZSTD_nextInputType_e ZSTD_nextInputType(ZSTD_DCtx* dctx) {
switch(dctx->stage)
{
default: /* should not happen */
+ assert(0);
case ZSTDds_getFrameHeaderSize:
case ZSTDds_decodeFrameHeader:
return ZSTDnit_frameHeader;
@@ -1621,21 +1702,24 @@ ZSTD_nextInputType_e ZSTD_nextInputType(ZSTD_DCtx* dctx) {
}
}
-int ZSTD_isSkipFrame(ZSTD_DCtx* dctx) { return dctx->stage == ZSTDds_skipFrame; } /* for zbuff */
+static int ZSTD_isSkipFrame(ZSTD_DCtx* dctx) { return dctx->stage == ZSTDds_skipFrame; }
/** ZSTD_decompressContinue() :
-* @return : nb of bytes generated into `dst` (necessarily <= `dstCapacity)
-* or an error code, which can be tested using ZSTD_isError() */
+ * srcSize : must be the exact nb of bytes expected (see ZSTD_nextSrcSizeToDecompress())
+ * @return : nb of bytes generated into `dst` (necessarily <= `dstCapacity)
+ * or an error code, which can be tested using ZSTD_isError() */
size_t ZSTD_decompressContinue(ZSTD_DCtx* dctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize)
{
+ DEBUGLOG(5, "ZSTD_decompressContinue");
/* Sanity check */
- if (srcSize != dctx->expected) return ERROR(srcSize_wrong);
+ if (srcSize != dctx->expected) return ERROR(srcSize_wrong); /* unauthorized */
if (dstCapacity) ZSTD_checkContinuity(dctx, dst);
switch (dctx->stage)
{
case ZSTDds_getFrameHeaderSize :
- if (srcSize != ZSTD_frameHeaderSize_prefix) return ERROR(srcSize_wrong); /* impossible */
+ if (srcSize != ZSTD_frameHeaderSize_prefix) return ERROR(srcSize_wrong); /* unauthorized */
+ assert(src != NULL);
if ((MEM_readLE32(src) & 0xFFFFFFF0U) == ZSTD_MAGIC_SKIPPABLE_START) { /* skippable frame */
memcpy(dctx->headerBuffer, src, ZSTD_frameHeaderSize_prefix);
dctx->expected = ZSTD_skippableHeaderSize - ZSTD_frameHeaderSize_prefix; /* magic number + skippable frame length */
@@ -1653,6 +1737,7 @@ size_t ZSTD_decompressContinue(ZSTD_DCtx* dctx, void* dst, size_t dstCapacity, c
dctx->expected = 0; /* not necessary to copy more */
case ZSTDds_decodeFrameHeader:
+ assert(src != NULL);
memcpy(dctx->headerBuffer + ZSTD_frameHeaderSize_prefix, src, dctx->expected);
CHECK_F(ZSTD_decodeFrameHeader(dctx, dctx->headerBuffer, dctx->headerSize));
dctx->expected = ZSTD_blockHeaderSize;
@@ -1680,17 +1765,19 @@ size_t ZSTD_decompressContinue(ZSTD_DCtx* dctx, void* dst, size_t dstCapacity, c
dctx->stage = ZSTDds_getFrameHeaderSize;
}
} else {
- dctx->expected = 3; /* go directly to next header */
+ dctx->expected = ZSTD_blockHeaderSize; /* jump to next header */
dctx->stage = ZSTDds_decodeBlockHeader;
}
return 0;
}
case ZSTDds_decompressLastBlock:
case ZSTDds_decompressBlock:
+ DEBUGLOG(5, "case ZSTDds_decompressBlock");
{ size_t rSize;
switch(dctx->bType)
{
case bt_compressed:
+ DEBUGLOG(5, "case bt_compressed");
rSize = ZSTD_decompressBlock_internal(dctx, dst, dstCapacity, src, srcSize);
break;
case bt_raw :
@@ -1730,7 +1817,8 @@ size_t ZSTD_decompressContinue(ZSTD_DCtx* dctx, void* dst, size_t dstCapacity, c
return 0;
}
case ZSTDds_decodeSkippableHeader:
- { memcpy(dctx->headerBuffer + ZSTD_frameHeaderSize_prefix, src, dctx->expected);
+ { assert(src != NULL);
+ memcpy(dctx->headerBuffer + ZSTD_frameHeaderSize_prefix, src, dctx->expected);
dctx->expected = MEM_readLE32(dctx->headerBuffer + 4);
dctx->stage = ZSTDds_skipFrame;
return 0;
@@ -1767,7 +1855,9 @@ static size_t ZSTD_loadEntropy(ZSTD_entropyTables_t* entropy, const void* const
dictPtr += 8; /* skip header = magic + dictID */
- { size_t const hSize = HUF_readDTableX4(entropy->hufTable, dictPtr, dictEnd-dictPtr);
+ { size_t const hSize = HUF_readDTableX4_wksp(
+ entropy->hufTable, dictPtr, dictEnd - dictPtr,
+ entropy->workspace, sizeof(entropy->workspace));
if (HUF_isError(hSize)) return ERROR(dictionary_corrupted);
dictPtr += hSize;
}
@@ -1815,7 +1905,7 @@ static size_t ZSTD_decompress_insertDictionary(ZSTD_DCtx* dctx, const void* dict
{
if (dictSize < 8) return ZSTD_refDictContent(dctx, dict, dictSize);
{ U32 const magic = MEM_readLE32(dict);
- if (magic != ZSTD_DICT_MAGIC) {
+ if (magic != ZSTD_MAGIC_DICTIONARY) {
return ZSTD_refDictContent(dctx, dict, dictSize); /* pure content mode */
} }
dctx->dictID = MEM_readLE32((const char*)dict + 4);
@@ -1862,10 +1952,10 @@ static size_t ZSTD_DDictDictSize(const ZSTD_DDict* ddict)
return ddict->dictSize;
}
-static void ZSTD_refDDict(ZSTD_DCtx* dstDCtx, const ZSTD_DDict* ddict)
+size_t ZSTD_decompressBegin_usingDDict(ZSTD_DCtx* dstDCtx, const ZSTD_DDict* ddict)
{
- ZSTD_decompressBegin(dstDCtx); /* init */
- if (ddict) { /* support refDDict on NULL */
+ CHECK_F(ZSTD_decompressBegin(dstDCtx));
+ if (ddict) { /* support begin on NULL */
dstDCtx->dictID = ddict->dictID;
dstDCtx->base = ddict->dictContent;
dstDCtx->vBase = ddict->dictContent;
@@ -1886,6 +1976,7 @@ static void ZSTD_refDDict(ZSTD_DCtx* dstDCtx, const ZSTD_DDict* ddict)
dstDCtx->fseEntropy = 0;
}
}
+ return 0;
}
static size_t ZSTD_loadEntropy_inDDict(ZSTD_DDict* ddict)
@@ -1894,7 +1985,7 @@ static size_t ZSTD_loadEntropy_inDDict(ZSTD_DDict* ddict)
ddict->entropyPresent = 0;
if (ddict->dictSize < 8) return 0;
{ U32 const magic = MEM_readLE32(ddict->dictContent);
- if (magic != ZSTD_DICT_MAGIC) return 0; /* pure content mode */
+ if (magic != ZSTD_MAGIC_DICTIONARY) return 0; /* pure content mode */
}
ddict->dictID = MEM_readLE32((const char*)ddict->dictContent + 4);
@@ -1905,33 +1996,39 @@ static size_t ZSTD_loadEntropy_inDDict(ZSTD_DDict* ddict)
}
+static size_t ZSTD_initDDict_internal(ZSTD_DDict* ddict, const void* dict, size_t dictSize, unsigned byReference)
+{
+ if ((byReference) || (!dict) || (!dictSize)) {
+ ddict->dictBuffer = NULL;
+ ddict->dictContent = dict;
+ } else {
+ void* const internalBuffer = ZSTD_malloc(dictSize, ddict->cMem);
+ ddict->dictBuffer = internalBuffer;
+ ddict->dictContent = internalBuffer;
+ if (!internalBuffer) return ERROR(memory_allocation);
+ memcpy(internalBuffer, dict, dictSize);
+ }
+ ddict->dictSize = dictSize;
+ ddict->entropy.hufTable[0] = (HUF_DTable)((HufLog)*0x1000001); /* cover both little and big endian */
+
+ /* parse dictionary content */
+ CHECK_F( ZSTD_loadEntropy_inDDict(ddict) );
+
+ return 0;
+}
+
ZSTD_DDict* ZSTD_createDDict_advanced(const void* dict, size_t dictSize, unsigned byReference, ZSTD_customMem customMem)
{
- if (!customMem.customAlloc && !customMem.customFree) customMem = defaultCustomMem;
- if (!customMem.customAlloc || !customMem.customFree) return NULL;
+ if (!customMem.customAlloc ^ !customMem.customFree) return NULL;
{ ZSTD_DDict* const ddict = (ZSTD_DDict*) ZSTD_malloc(sizeof(ZSTD_DDict), customMem);
if (!ddict) return NULL;
ddict->cMem = customMem;
- if ((byReference) || (!dict) || (!dictSize)) {
- ddict->dictBuffer = NULL;
- ddict->dictContent = dict;
- } else {
- void* const internalBuffer = ZSTD_malloc(dictSize, customMem);
- if (!internalBuffer) { ZSTD_freeDDict(ddict); return NULL; }
- memcpy(internalBuffer, dict, dictSize);
- ddict->dictBuffer = internalBuffer;
- ddict->dictContent = internalBuffer;
+ if (ZSTD_isError( ZSTD_initDDict_internal(ddict, dict, dictSize, byReference) )) {
+ ZSTD_freeDDict(ddict);
+ return NULL;
}
- ddict->dictSize = dictSize;
- ddict->entropy.hufTable[0] = (HUF_DTable)((HufLog)*0x1000001); /* cover both little and big endian */
- /* parse dictionary content */
- { size_t const errorCode = ZSTD_loadEntropy_inDDict(ddict);
- if (ZSTD_isError(errorCode)) {
- ZSTD_freeDDict(ddict);
- return NULL;
- } }
return ddict;
}
@@ -1947,7 +2044,6 @@ ZSTD_DDict* ZSTD_createDDict(const void* dict, size_t dictSize)
return ZSTD_createDDict_advanced(dict, dictSize, 0, allocator);
}
-
/*! ZSTD_createDDict_byReference() :
* Create a digested dictionary, to start decompression without startup delay.
* Dictionary content is simply referenced, it will be accessed during decompression.
@@ -1959,6 +2055,26 @@ ZSTD_DDict* ZSTD_createDDict_byReference(const void* dictBuffer, size_t dictSize
}
+ZSTD_DDict* ZSTD_initStaticDDict(void* workspace, size_t workspaceSize,
+ const void* dict, size_t dictSize,
+ unsigned byReference)
+{
+ size_t const neededSpace = sizeof(ZSTD_DDict) + (byReference ? 0 : dictSize);
+ ZSTD_DDict* const ddict = (ZSTD_DDict*)workspace;
+ assert(workspace != NULL);
+ assert(dict != NULL);
+ if ((size_t)workspace & 7) return NULL; /* 8-aligned */
+ if (workspaceSize < neededSpace) return NULL;
+ if (!byReference) {
+ memcpy(ddict+1, dict, dictSize); /* local copy */
+ dict = ddict+1;
+ }
+ if (ZSTD_isError( ZSTD_initDDict_internal(ddict, dict, dictSize, 1 /* byRef */) ))
+ return NULL;
+ return ddict;
+}
+
+
size_t ZSTD_freeDDict(ZSTD_DDict* ddict)
{
if (ddict==NULL) return 0; /* support free on NULL */
@@ -1969,6 +2085,14 @@ size_t ZSTD_freeDDict(ZSTD_DDict* ddict)
}
}
+/*! ZSTD_estimateDDictSize() :
+ * Estimate amount of memory that will be needed to create a dictionary for decompression.
+ * Note : dictionary created "byReference" are smaller */
+size_t ZSTD_estimateDDictSize(size_t dictSize, unsigned byReference)
+{
+ return sizeof(ZSTD_DDict) + (byReference ? 0 : dictSize);
+}
+
size_t ZSTD_sizeof_DDict(const ZSTD_DDict* ddict)
{
if (ddict==NULL) return 0; /* support sizeof on NULL */
@@ -1982,7 +2106,7 @@ size_t ZSTD_sizeof_DDict(const ZSTD_DDict* ddict)
unsigned ZSTD_getDictID_fromDict(const void* dict, size_t dictSize)
{
if (dictSize < 8) return 0;
- if (MEM_readLE32(dict) != ZSTD_DICT_MAGIC) return 0;
+ if (MEM_readLE32(dict) != ZSTD_MAGIC_DICTIONARY) return 0;
return MEM_readLE32((const char*)dict + 4);
}
@@ -2008,11 +2132,11 @@ unsigned ZSTD_getDictID_fromDDict(const ZSTD_DDict* ddict)
* Note : possible if `srcSize < ZSTD_FRAMEHEADERSIZE_MAX`.
* - This is not a Zstandard frame.
* When identifying the exact failure cause, it's possible to use
- * ZSTD_getFrameParams(), which will provide a more precise error code. */
+ * ZSTD_getFrameHeader(), which will provide a more precise error code. */
unsigned ZSTD_getDictID_fromFrame(const void* src, size_t srcSize)
{
- ZSTD_frameParams zfp = { 0 , 0 , 0 , 0 };
- size_t const hError = ZSTD_getFrameParams(&zfp, src, srcSize);
+ ZSTD_frameHeader zfp = { 0 , 0 , 0 , 0 };
+ size_t const hError = ZSTD_getFrameHeader(&zfp, src, srcSize);
if (ZSTD_isError(hError)) return 0;
return zfp.dictID;
}
@@ -2037,88 +2161,35 @@ size_t ZSTD_decompress_usingDDict(ZSTD_DCtx* dctx,
* Streaming decompression
*====================================*/
-typedef enum { zdss_init, zdss_loadHeader,
- zdss_read, zdss_load, zdss_flush } ZSTD_dStreamStage;
-
-/* *** Resource management *** */
-struct ZSTD_DStream_s {
- ZSTD_DCtx* dctx;
- ZSTD_DDict* ddictLocal;
- const ZSTD_DDict* ddict;
- ZSTD_frameParams fParams;
- ZSTD_dStreamStage stage;
- char* inBuff;
- size_t inBuffSize;
- size_t inPos;
- size_t maxWindowSize;
- char* outBuff;
- size_t outBuffSize;
- size_t outStart;
- size_t outEnd;
- size_t blockSize;
- BYTE headerBuffer[ZSTD_FRAMEHEADERSIZE_MAX]; /* tmp buffer to store frame header */
- size_t lhSize;
- ZSTD_customMem customMem;
- void* legacyContext;
- U32 previousLegacyVersion;
- U32 legacyVersion;
- U32 hostageByte;
-}; /* typedef'd to ZSTD_DStream within "zstd.h" */
-
-
ZSTD_DStream* ZSTD_createDStream(void)
{
- return ZSTD_createDStream_advanced(defaultCustomMem);
+ return ZSTD_createDStream_advanced(ZSTD_defaultCMem);
}
-ZSTD_DStream* ZSTD_createDStream_advanced(ZSTD_customMem customMem)
+ZSTD_DStream* ZSTD_initStaticDStream(void *workspace, size_t workspaceSize)
{
- ZSTD_DStream* zds;
-
- if (!customMem.customAlloc && !customMem.customFree) customMem = defaultCustomMem;
- if (!customMem.customAlloc || !customMem.customFree) return NULL;
+ return ZSTD_initStaticDCtx(workspace, workspaceSize);
+}
- zds = (ZSTD_DStream*) ZSTD_malloc(sizeof(ZSTD_DStream), customMem);
- if (zds==NULL) return NULL;
- memset(zds, 0, sizeof(ZSTD_DStream));
- memcpy(&zds->customMem, &customMem, sizeof(ZSTD_customMem));
- zds->dctx = ZSTD_createDCtx_advanced(customMem);
- if (zds->dctx == NULL) { ZSTD_freeDStream(zds); return NULL; }
- zds->stage = zdss_init;
- zds->maxWindowSize = ZSTD_MAXWINDOWSIZE_DEFAULT;
- return zds;
+ZSTD_DStream* ZSTD_createDStream_advanced(ZSTD_customMem customMem)
+{
+ return ZSTD_createDCtx_advanced(customMem);
}
size_t ZSTD_freeDStream(ZSTD_DStream* zds)
{
- if (zds==NULL) return 0; /* support free on null */
- { ZSTD_customMem const cMem = zds->customMem;
- ZSTD_freeDCtx(zds->dctx);
- zds->dctx = NULL;
- ZSTD_freeDDict(zds->ddictLocal);
- zds->ddictLocal = NULL;
- ZSTD_free(zds->inBuff, cMem);
- zds->inBuff = NULL;
- ZSTD_free(zds->outBuff, cMem);
- zds->outBuff = NULL;
-#if defined(ZSTD_LEGACY_SUPPORT) && (ZSTD_LEGACY_SUPPORT >= 1)
- if (zds->legacyContext)
- ZSTD_freeLegacyStreamContext(zds->legacyContext, zds->previousLegacyVersion);
-#endif
- ZSTD_free(zds, cMem);
- return 0;
- }
+ return ZSTD_freeDCtx(zds);
}
/* *** Initialization *** */
-size_t ZSTD_DStreamInSize(void) { return ZSTD_BLOCKSIZE_ABSOLUTEMAX + ZSTD_blockHeaderSize; }
-size_t ZSTD_DStreamOutSize(void) { return ZSTD_BLOCKSIZE_ABSOLUTEMAX; }
+size_t ZSTD_DStreamInSize(void) { return ZSTD_BLOCKSIZE_MAX + ZSTD_blockHeaderSize; }
+size_t ZSTD_DStreamOutSize(void) { return ZSTD_BLOCKSIZE_MAX; }
size_t ZSTD_initDStream_usingDict(ZSTD_DStream* zds, const void* dict, size_t dictSize)
{
- zds->stage = zdss_loadHeader;
+ zds->streamStage = zdss_loadHeader;
zds->lhSize = zds->inPos = zds->outStart = zds->outEnd = 0;
ZSTD_freeDDict(zds->ddictLocal);
if (dict && dictSize >= 8) {
@@ -2147,7 +2218,7 @@ size_t ZSTD_initDStream_usingDDict(ZSTD_DStream* zds, const ZSTD_DDict* ddict)
size_t ZSTD_resetDStream(ZSTD_DStream* zds)
{
- zds->stage = zdss_loadHeader;
+ zds->streamStage = zdss_loadHeader;
zds->lhSize = zds->inPos = zds->outStart = zds->outEnd = 0;
zds->legacyVersion = 0;
zds->hostageByte = 0;
@@ -2168,11 +2239,24 @@ size_t ZSTD_setDStreamParameter(ZSTD_DStream* zds,
size_t ZSTD_sizeof_DStream(const ZSTD_DStream* zds)
{
- if (zds==NULL) return 0; /* support sizeof NULL */
- return sizeof(*zds)
- + ZSTD_sizeof_DCtx(zds->dctx)
- + ZSTD_sizeof_DDict(zds->ddictLocal)
- + zds->inBuffSize + zds->outBuffSize;
+ return ZSTD_sizeof_DCtx(zds);
+}
+
+size_t ZSTD_estimateDStreamSize(size_t windowSize)
+{
+ size_t const blockSize = MIN(windowSize, ZSTD_BLOCKSIZE_MAX);
+ size_t const inBuffSize = blockSize; /* no block can be larger */
+ size_t const outBuffSize = windowSize + blockSize + (WILDCOPY_OVERLENGTH * 2);
+ return sizeof(ZSTD_DStream) + ZSTD_estimateDCtxSize() + inBuffSize + outBuffSize;
+}
+
+ZSTDLIB_API size_t ZSTD_estimateDStreamSize_fromFrame(const void* src, size_t srcSize)
+{
+ ZSTD_frameHeader fh;
+ size_t const err = ZSTD_getFrameHeader(&fh, src, srcSize);
+ if (ZSTD_isError(err)) return err;
+ if (err>0) return ERROR(srcSize_wrong);
+ return ZSTD_estimateDStreamSize(fh.windowSize);
}
@@ -2196,44 +2280,55 @@ size_t ZSTD_decompressStream(ZSTD_DStream* zds, ZSTD_outBuffer* output, ZSTD_inB
char* op = ostart;
U32 someMoreWork = 1;
+ DEBUGLOG(5, "ZSTD_decompressStream");
+ DEBUGLOG(5, "input size : %u", (U32)(input->size - input->pos));
#if defined(ZSTD_LEGACY_SUPPORT) && (ZSTD_LEGACY_SUPPORT>=1)
- if (zds->legacyVersion)
+ if (zds->legacyVersion) {
+ /* legacy support is incompatible with static dctx */
+ if (zds->staticSize) return ERROR(memory_allocation);
return ZSTD_decompressLegacyStream(zds->legacyContext, zds->legacyVersion, output, input);
+ }
#endif
while (someMoreWork) {
- switch(zds->stage)
+ switch(zds->streamStage)
{
case zdss_init :
ZSTD_resetDStream(zds); /* transparent reset on starting decoding a new frame */
/* fall-through */
case zdss_loadHeader :
- { size_t const hSize = ZSTD_getFrameParams(&zds->fParams, zds->headerBuffer, zds->lhSize);
- if (ZSTD_isError(hSize))
+ { size_t const hSize = ZSTD_getFrameHeader(&zds->fParams, zds->headerBuffer, zds->lhSize);
+ if (ZSTD_isError(hSize)) {
#if defined(ZSTD_LEGACY_SUPPORT) && (ZSTD_LEGACY_SUPPORT>=1)
- { U32 const legacyVersion = ZSTD_isLegacy(istart, iend-istart);
+ U32 const legacyVersion = ZSTD_isLegacy(istart, iend-istart);
if (legacyVersion) {
const void* const dict = zds->ddict ? zds->ddict->dictContent : NULL;
size_t const dictSize = zds->ddict ? zds->ddict->dictSize : 0;
+ /* legacy support is incompatible with static dctx */
+ if (zds->staticSize) return ERROR(memory_allocation);
CHECK_F(ZSTD_initLegacyStream(&zds->legacyContext, zds->previousLegacyVersion, legacyVersion,
dict, dictSize));
zds->legacyVersion = zds->previousLegacyVersion = legacyVersion;
return ZSTD_decompressLegacyStream(zds->legacyContext, zds->legacyVersion, output, input);
} else {
return hSize; /* error */
- } }
+ }
#else
- return hSize;
+ return hSize;
#endif
+ }
if (hSize != 0) { /* need more input */
size_t const toLoad = hSize - zds->lhSize; /* if hSize!=0, hSize > zds->lhSize */
if (toLoad > (size_t)(iend-ip)) { /* not enough input to load full header */
- memcpy(zds->headerBuffer + zds->lhSize, ip, iend-ip);
- zds->lhSize += iend-ip;
+ if (iend-ip > 0) {
+ memcpy(zds->headerBuffer + zds->lhSize, ip, iend-ip);
+ zds->lhSize += iend-ip;
+ }
input->pos = input->size;
return (MAX(ZSTD_frameHeaderSize_min, hSize) - zds->lhSize) + ZSTD_blockHeaderSize; /* remaining header bytes + next block header */
}
+ assert(ip != NULL);
memcpy(zds->headerBuffer + zds->lhSize, ip, toLoad); zds->lhSize = hSize; ip += toLoad;
break;
} }
@@ -2243,74 +2338,90 @@ size_t ZSTD_decompressStream(ZSTD_DStream* zds, ZSTD_outBuffer* output, ZSTD_inB
&& (U64)(size_t)(oend-op) >= zds->fParams.frameContentSize) {
size_t const cSize = ZSTD_findFrameCompressedSize(istart, iend-istart);
if (cSize <= (size_t)(iend-istart)) {
- size_t const decompressedSize = ZSTD_decompress_usingDDict(zds->dctx, op, oend-op, istart, cSize, zds->ddict);
+ size_t const decompressedSize = ZSTD_decompress_usingDDict(zds, op, oend-op, istart, cSize, zds->ddict);
if (ZSTD_isError(decompressedSize)) return decompressedSize;
ip = istart + cSize;
op += decompressedSize;
- zds->dctx->expected = 0;
- zds->stage = zdss_init;
+ zds->expected = 0;
+ zds->streamStage = zdss_init;
someMoreWork = 0;
break;
} }
- /* Consume header */
- ZSTD_refDDict(zds->dctx, zds->ddict);
- { size_t const h1Size = ZSTD_nextSrcSizeToDecompress(zds->dctx); /* == ZSTD_frameHeaderSize_prefix */
- CHECK_F(ZSTD_decompressContinue(zds->dctx, NULL, 0, zds->headerBuffer, h1Size));
- { size_t const h2Size = ZSTD_nextSrcSizeToDecompress(zds->dctx);
- CHECK_F(ZSTD_decompressContinue(zds->dctx, NULL, 0, zds->headerBuffer+h1Size, h2Size));
- } }
+ /* Consume header (see ZSTDds_decodeFrameHeader) */
+ DEBUGLOG(4, "Consume header");
+ CHECK_F(ZSTD_decompressBegin_usingDDict(zds, zds->ddict));
+
+ if ((MEM_readLE32(zds->headerBuffer) & 0xFFFFFFF0U) == ZSTD_MAGIC_SKIPPABLE_START) { /* skippable frame */
+ zds->expected = MEM_readLE32(zds->headerBuffer + 4);
+ zds->stage = ZSTDds_skipFrame;
+ } else {
+ CHECK_F(ZSTD_decodeFrameHeader(zds, zds->headerBuffer, zds->lhSize));
+ zds->expected = ZSTD_blockHeaderSize;
+ zds->stage = ZSTDds_decodeBlockHeader;
+ }
+ /* control buffer memory usage */
+ DEBUGLOG(4, "Control max buffer memory usage");
zds->fParams.windowSize = MAX(zds->fParams.windowSize, 1U << ZSTD_WINDOWLOG_ABSOLUTEMIN);
if (zds->fParams.windowSize > zds->maxWindowSize) return ERROR(frameParameter_windowTooLarge);
/* Adapt buffer sizes to frame header instructions */
- { size_t const blockSize = MIN(zds->fParams.windowSize, ZSTD_BLOCKSIZE_ABSOLUTEMAX);
+ { size_t const blockSize = MIN(zds->fParams.windowSize, ZSTD_BLOCKSIZE_MAX);
size_t const neededOutSize = zds->fParams.windowSize + blockSize + WILDCOPY_OVERLENGTH * 2;
zds->blockSize = blockSize;
- if (zds->inBuffSize < blockSize) {
- ZSTD_free(zds->inBuff, zds->customMem);
- zds->inBuffSize = 0;
- zds->inBuff = (char*)ZSTD_malloc(blockSize, zds->customMem);
- if (zds->inBuff == NULL) return ERROR(memory_allocation);
+ if ((zds->inBuffSize < blockSize) || (zds->outBuffSize < neededOutSize)) {
+ size_t const bufferSize = blockSize + neededOutSize;
+ DEBUGLOG(4, "inBuff : from %u to %u",
+ (U32)zds->inBuffSize, (U32)blockSize);
+ DEBUGLOG(4, "outBuff : from %u to %u",
+ (U32)zds->outBuffSize, (U32)neededOutSize);
+ if (zds->staticSize) { /* static DCtx */
+ DEBUGLOG(4, "staticSize : %u", (U32)zds->staticSize);
+ assert(zds->staticSize >= sizeof(ZSTD_DCtx)); /* controlled at init */
+ if (bufferSize > zds->staticSize - sizeof(ZSTD_DCtx))
+ return ERROR(memory_allocation);
+ } else {
+ ZSTD_free(zds->inBuff, zds->customMem);
+ zds->inBuffSize = 0;
+ zds->outBuffSize = 0;
+ zds->inBuff = (char*)ZSTD_malloc(bufferSize, zds->customMem);
+ if (zds->inBuff == NULL) return ERROR(memory_allocation);
+ }
zds->inBuffSize = blockSize;
- }
- if (zds->outBuffSize < neededOutSize) {
- ZSTD_free(zds->outBuff, zds->customMem);
- zds->outBuffSize = 0;
- zds->outBuff = (char*)ZSTD_malloc(neededOutSize, zds->customMem);
- if (zds->outBuff == NULL) return ERROR(memory_allocation);
+ zds->outBuff = zds->inBuff + zds->inBuffSize;
zds->outBuffSize = neededOutSize;
} }
- zds->stage = zdss_read;
+ zds->streamStage = zdss_read;
/* pass-through */
case zdss_read:
- { size_t const neededInSize = ZSTD_nextSrcSizeToDecompress(zds->dctx);
+ DEBUGLOG(5, "stage zdss_read");
+ { size_t const neededInSize = ZSTD_nextSrcSizeToDecompress(zds);
+ DEBUGLOG(5, "neededInSize = %u", (U32)neededInSize);
if (neededInSize==0) { /* end of frame */
- zds->stage = zdss_init;
+ zds->streamStage = zdss_init;
someMoreWork = 0;
break;
}
if ((size_t)(iend-ip) >= neededInSize) { /* decode directly from src */
- const int isSkipFrame = ZSTD_isSkipFrame(zds->dctx);
- size_t const decodedSize = ZSTD_decompressContinue(zds->dctx,
+ int const isSkipFrame = ZSTD_isSkipFrame(zds);
+ size_t const decodedSize = ZSTD_decompressContinue(zds,
zds->outBuff + zds->outStart, (isSkipFrame ? 0 : zds->outBuffSize - zds->outStart),
ip, neededInSize);
if (ZSTD_isError(decodedSize)) return decodedSize;
ip += neededInSize;
if (!decodedSize && !isSkipFrame) break; /* this was just a header */
zds->outEnd = zds->outStart + decodedSize;
- zds->stage = zdss_flush;
+ zds->streamStage = zdss_flush;
break;
- }
- if (ip==iend) { someMoreWork = 0; break; } /* no more input */
- zds->stage = zdss_load;
- /* pass-through */
- }
+ } }
+ if (ip==iend) { someMoreWork = 0; break; } /* no more input */
+ zds->streamStage = zdss_load;
+ /* pass-through */
case zdss_load:
- { size_t const neededInSize = ZSTD_nextSrcSizeToDecompress(zds->dctx);
+ { size_t const neededInSize = ZSTD_nextSrcSizeToDecompress(zds);
size_t const toLoad = neededInSize - zds->inPos; /* should always be <= remaining space within inBuff */
size_t loadedSize;
if (toLoad > zds->inBuffSize - zds->inPos) return ERROR(corruption_detected); /* should never happen */
@@ -2320,17 +2431,17 @@ size_t ZSTD_decompressStream(ZSTD_DStream* zds, ZSTD_outBuffer* output, ZSTD_inB
if (loadedSize < toLoad) { someMoreWork = 0; break; } /* not enough input, wait for more */
/* decode loaded input */
- { const int isSkipFrame = ZSTD_isSkipFrame(zds->dctx);
- size_t const decodedSize = ZSTD_decompressContinue(zds->dctx,
+ { const int isSkipFrame = ZSTD_isSkipFrame(zds);
+ size_t const decodedSize = ZSTD_decompressContinue(zds,
zds->outBuff + zds->outStart, zds->outBuffSize - zds->outStart,
zds->inBuff, neededInSize);
if (ZSTD_isError(decodedSize)) return decodedSize;
zds->inPos = 0; /* input is consumed */
- if (!decodedSize && !isSkipFrame) { zds->stage = zdss_read; break; } /* this was just a header */
+ if (!decodedSize && !isSkipFrame) { zds->streamStage = zdss_read; break; } /* this was just a header */
zds->outEnd = zds->outStart + decodedSize;
- zds->stage = zdss_flush;
- /* pass-through */
} }
+ zds->streamStage = zdss_flush;
+ /* pass-through */
case zdss_flush:
{ size_t const toFlushSize = zds->outEnd - zds->outStart;
@@ -2338,37 +2449,41 @@ size_t ZSTD_decompressStream(ZSTD_DStream* zds, ZSTD_outBuffer* output, ZSTD_inB
op += flushedSize;
zds->outStart += flushedSize;
if (flushedSize == toFlushSize) { /* flush completed */
- zds->stage = zdss_read;
+ zds->streamStage = zdss_read;
if (zds->outStart + zds->blockSize > zds->outBuffSize)
zds->outStart = zds->outEnd = 0;
break;
- }
- /* cannot complete flush */
- someMoreWork = 0;
- break;
- }
+ } }
+ /* cannot complete flush */
+ someMoreWork = 0;
+ break;
+
default: return ERROR(GENERIC); /* impossible */
} }
/* result */
input->pos += (size_t)(ip-istart);
output->pos += (size_t)(op-ostart);
- { size_t nextSrcSizeHint = ZSTD_nextSrcSizeToDecompress(zds->dctx);
+ { size_t nextSrcSizeHint = ZSTD_nextSrcSizeToDecompress(zds);
if (!nextSrcSizeHint) { /* frame fully decoded */
if (zds->outEnd == zds->outStart) { /* output fully flushed */
if (zds->hostageByte) {
- if (input->pos >= input->size) { zds->stage = zdss_read; return 1; } /* can't release hostage (not present) */
+ if (input->pos >= input->size) {
+ /* can't release hostage (not present) */
+ zds->streamStage = zdss_read;
+ return 1;
+ }
input->pos++; /* release hostage */
- }
+ } /* zds->hostageByte */
return 0;
- }
+ } /* zds->outEnd == zds->outStart */
if (!zds->hostageByte) { /* output not fully flushed; keep last byte as hostage; will be released when all output is flushed */
input->pos--; /* note : pos > 0, otherwise, impossible to finish reading last block */
zds->hostageByte=1;
}
return 1;
- }
- nextSrcSizeHint += ZSTD_blockHeaderSize * (ZSTD_nextInputType(zds->dctx) == ZSTDnit_block); /* preload header of next block */
+ } /* nextSrcSizeHint==0 */
+ nextSrcSizeHint += ZSTD_blockHeaderSize * (ZSTD_nextInputType(zds) == ZSTDnit_block); /* preload header of next block */
if (zds->inPos > nextSrcSizeHint) return ERROR(GENERIC); /* should never happen */
nextSrcSizeHint -= zds->inPos; /* already loaded*/
return nextSrcSizeHint;
diff --git a/thirdparty/zstd/zstd.h b/thirdparty/zstd/zstd.h
index f8050c1361..58e9a5606d 100644
--- a/thirdparty/zstd/zstd.h
+++ b/thirdparty/zstd/zstd.h
@@ -19,10 +19,12 @@ extern "C" {
/* ===== ZSTDLIB_API : control library symbols visibility ===== */
-#if defined(__GNUC__) && (__GNUC__ >= 4)
-# define ZSTDLIB_VISIBILITY __attribute__ ((visibility ("default")))
-#else
-# define ZSTDLIB_VISIBILITY
+#ifndef ZSTDLIB_VISIBILITY
+# if defined(__GNUC__) && (__GNUC__ >= 4)
+# define ZSTDLIB_VISIBILITY __attribute__ ((visibility ("default")))
+# else
+# define ZSTDLIB_VISIBILITY
+# endif
#endif
#if defined(ZSTD_DLL_EXPORT) && (ZSTD_DLL_EXPORT==1)
# define ZSTDLIB_API __declspec(dllexport) ZSTDLIB_VISIBILITY
@@ -36,35 +38,37 @@ extern "C" {
/*******************************************************************************************************
Introduction
- zstd, short for Zstandard, is a fast lossless compression algorithm, targeting real-time compression scenarios
- at zlib-level and better compression ratios. The zstd compression library provides in-memory compression and
- decompression functions. The library supports compression levels from 1 up to ZSTD_maxCLevel() which is 22.
+ zstd, short for Zstandard, is a fast lossless compression algorithm,
+ targeting real-time compression scenarios at zlib-level and better compression ratios.
+ The zstd compression library provides in-memory compression and decompression functions.
+ The library supports compression levels from 1 up to ZSTD_maxCLevel() which is currently 22.
Levels >= 20, labeled `--ultra`, should be used with caution, as they require more memory.
Compression can be done in:
- a single step (described as Simple API)
- a single step, reusing a context (described as Explicit memory management)
- unbounded multiple steps (described as Streaming compression)
- The compression ratio achievable on small data can be highly improved using compression with a dictionary in:
+ The compression ratio achievable on small data can be highly improved using a dictionary in:
- a single step (described as Simple dictionary API)
- a single step, reusing a dictionary (described as Fast dictionary API)
Advanced experimental functions can be accessed using #define ZSTD_STATIC_LINKING_ONLY before including zstd.h.
- These APIs shall never be used with a dynamic library.
+ Advanced experimental APIs shall never be used with a dynamic library.
They are not "stable", their definition may change in the future. Only static linking is allowed.
*********************************************************************************************************/
/*------ Version ------*/
#define ZSTD_VERSION_MAJOR 1
-#define ZSTD_VERSION_MINOR 2
+#define ZSTD_VERSION_MINOR 3
#define ZSTD_VERSION_RELEASE 0
+#define ZSTD_VERSION_NUMBER (ZSTD_VERSION_MAJOR *100*100 + ZSTD_VERSION_MINOR *100 + ZSTD_VERSION_RELEASE)
+ZSTDLIB_API unsigned ZSTD_versionNumber(void); /**< useful to check dll version */
+
#define ZSTD_LIB_VERSION ZSTD_VERSION_MAJOR.ZSTD_VERSION_MINOR.ZSTD_VERSION_RELEASE
#define ZSTD_QUOTE(str) #str
#define ZSTD_EXPAND_AND_QUOTE(str) ZSTD_QUOTE(str)
#define ZSTD_VERSION_STRING ZSTD_EXPAND_AND_QUOTE(ZSTD_LIB_VERSION)
-
-#define ZSTD_VERSION_NUMBER (ZSTD_VERSION_MAJOR *100*100 + ZSTD_VERSION_MINOR *100 + ZSTD_VERSION_RELEASE)
-ZSTDLIB_API unsigned ZSTD_versionNumber(void); /**< library version number; to be used when checking dll version */
+ZSTDLIB_API const char* ZSTD_versionString(void); /* v1.3.0 */
/***************************************
@@ -81,38 +85,48 @@ ZSTDLIB_API size_t ZSTD_compress( void* dst, size_t dstCapacity,
/*! ZSTD_decompress() :
* `compressedSize` : must be the _exact_ size of some number of compressed and/or skippable frames.
- * `dstCapacity` is an upper bound of originalSize.
+ * `dstCapacity` is an upper bound of originalSize to regenerate.
* If user cannot imply a maximum upper bound, it's better to use streaming mode to decompress data.
* @return : the number of bytes decompressed into `dst` (<= `dstCapacity`),
* or an errorCode if it fails (which can be tested using ZSTD_isError()). */
ZSTDLIB_API size_t ZSTD_decompress( void* dst, size_t dstCapacity,
const void* src, size_t compressedSize);
-/*! ZSTD_getDecompressedSize() :
- * NOTE: This function is planned to be obsolete, in favour of ZSTD_getFrameContentSize.
- * ZSTD_getFrameContentSize functions the same way, returning the decompressed size of a single
- * frame, but distinguishes empty frames from frames with an unknown size, or errors.
- *
- * Additionally, ZSTD_findDecompressedSize can be used instead. It can handle multiple
- * concatenated frames in one buffer, and so is more general.
- * As a result however, it requires more computation and entire frames to be passed to it,
- * as opposed to ZSTD_getFrameContentSize which requires only a single frame's header.
- *
- * 'src' is the start of a zstd compressed frame.
- * @return : content size to be decompressed, as a 64-bits value _if known_, 0 otherwise.
- * note 1 : decompressed size is an optional field, that may not be present, especially in streaming mode.
- * When `return==0`, data to decompress could be any size.
+/*! ZSTD_getFrameContentSize() : v1.3.0
+ * `src` should point to the start of a ZSTD encoded frame.
+ * `srcSize` must be at least as large as the frame header.
+ * hint : any size >= `ZSTD_frameHeaderSize_max` is large enough.
+ * @return : - decompressed size of the frame in `src`, if known
+ * - ZSTD_CONTENTSIZE_UNKNOWN if the size cannot be determined
+ * - ZSTD_CONTENTSIZE_ERROR if an error occurred (e.g. invalid magic number, srcSize too small)
+ * note 1 : a 0 return value means the frame is valid but "empty".
+ * note 2 : decompressed size is an optional field, it may not be present, typically in streaming mode.
+ * When `return==ZSTD_CONTENTSIZE_UNKNOWN`, data to decompress could be any size.
* In which case, it's necessary to use streaming mode to decompress data.
- * Optionally, application can still use ZSTD_decompress() while relying on implied limits.
- * (For example, data may be necessarily cut into blocks <= 16 KB).
- * note 2 : decompressed size is always present when compression is done with ZSTD_compress()
- * note 3 : decompressed size can be very large (64-bits value),
+ * Optionally, application can rely on some implicit limit,
+ * as ZSTD_decompress() only needs an upper bound of decompressed size.
+ * (For example, data could be necessarily cut into blocks <= 16 KB).
+ * note 3 : decompressed size is always present when compression is done with ZSTD_compress()
+ * note 4 : decompressed size can be very large (64-bits value),
* potentially larger than what local system can handle as a single memory segment.
* In which case, it's necessary to use streaming mode to decompress data.
- * note 4 : If source is untrusted, decompressed size could be wrong or intentionally modified.
- * Always ensure result fits within application's authorized limits.
+ * note 5 : If source is untrusted, decompressed size could be wrong or intentionally modified.
+ * Always ensure return value fits within application's authorized limits.
* Each application can set its own limits.
- * note 5 : when `return==0`, if precise failure cause is needed, use ZSTD_getFrameParams() to know more. */
+ * note 6 : This function replaces ZSTD_getDecompressedSize() */
+#define ZSTD_CONTENTSIZE_UNKNOWN (0ULL - 1)
+#define ZSTD_CONTENTSIZE_ERROR (0ULL - 2)
+ZSTDLIB_API unsigned long long ZSTD_getFrameContentSize(const void *src, size_t srcSize);
+
+/*! ZSTD_getDecompressedSize() :
+ * NOTE: This function is now obsolete, in favor of ZSTD_getFrameContentSize().
+ * Both functions work the same way,
+ * but ZSTD_getDecompressedSize() blends
+ * "empty", "unknown" and "error" results in the same return value (0),
+ * while ZSTD_getFrameContentSize() distinguishes them.
+ *
+ * 'src' is the start of a zstd compressed frame.
+ * @return : content size to be decompressed, as a 64-bits value _if known and not empty_, 0 otherwise. */
ZSTDLIB_API unsigned long long ZSTD_getDecompressedSize(const void* src, size_t srcSize);
@@ -137,29 +151,35 @@ ZSTDLIB_API size_t ZSTD_freeCCtx(ZSTD_CCtx* cctx);
/*! ZSTD_compressCCtx() :
* Same as ZSTD_compress(), requires an allocated ZSTD_CCtx (see ZSTD_createCCtx()). */
-ZSTDLIB_API size_t ZSTD_compressCCtx(ZSTD_CCtx* ctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize, int compressionLevel);
+ZSTDLIB_API size_t ZSTD_compressCCtx(ZSTD_CCtx* ctx,
+ void* dst, size_t dstCapacity,
+ const void* src, size_t srcSize,
+ int compressionLevel);
/*= Decompression context
* When decompressing many times,
- * it is recommended to allocate a context just once, and re-use it for each successive compression operation.
+ * it is recommended to allocate a context only once,
+ * and re-use it for each successive compression operation.
* This will make workload friendlier for system's memory.
- * Use one context per thread for parallel execution in multi-threaded environments. */
+ * Use one context per thread for parallel execution. */
typedef struct ZSTD_DCtx_s ZSTD_DCtx;
ZSTDLIB_API ZSTD_DCtx* ZSTD_createDCtx(void);
ZSTDLIB_API size_t ZSTD_freeDCtx(ZSTD_DCtx* dctx);
/*! ZSTD_decompressDCtx() :
- * Same as ZSTD_decompress(), requires an allocated ZSTD_DCtx (see ZSTD_createDCtx()). */
-ZSTDLIB_API size_t ZSTD_decompressDCtx(ZSTD_DCtx* ctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
+ * Same as ZSTD_decompress(), requires an allocated ZSTD_DCtx (see ZSTD_createDCtx()) */
+ZSTDLIB_API size_t ZSTD_decompressDCtx(ZSTD_DCtx* ctx,
+ void* dst, size_t dstCapacity,
+ const void* src, size_t srcSize);
/**************************
* Simple dictionary API
***************************/
/*! ZSTD_compress_usingDict() :
-* Compression using a predefined Dictionary (see dictBuilder/zdict.h).
-* Note : This function loads the dictionary, resulting in significant startup delay.
-* Note : When `dict == NULL || dictSize < 8` no dictionary is used. */
+ * Compression using a predefined Dictionary (see dictBuilder/zdict.h).
+ * Note : This function loads the dictionary, resulting in significant startup delay.
+ * Note : When `dict == NULL || dictSize < 8` no dictionary is used. */
ZSTDLIB_API size_t ZSTD_compress_usingDict(ZSTD_CCtx* ctx,
void* dst, size_t dstCapacity,
const void* src, size_t srcSize,
@@ -167,30 +187,31 @@ ZSTDLIB_API size_t ZSTD_compress_usingDict(ZSTD_CCtx* ctx,
int compressionLevel);
/*! ZSTD_decompress_usingDict() :
-* Decompression using a predefined Dictionary (see dictBuilder/zdict.h).
-* Dictionary must be identical to the one used during compression.
-* Note : This function loads the dictionary, resulting in significant startup delay.
-* Note : When `dict == NULL || dictSize < 8` no dictionary is used. */
+ * Decompression using a predefined Dictionary (see dictBuilder/zdict.h).
+ * Dictionary must be identical to the one used during compression.
+ * Note : This function loads the dictionary, resulting in significant startup delay.
+ * Note : When `dict == NULL || dictSize < 8` no dictionary is used. */
ZSTDLIB_API size_t ZSTD_decompress_usingDict(ZSTD_DCtx* dctx,
void* dst, size_t dstCapacity,
const void* src, size_t srcSize,
const void* dict,size_t dictSize);
-/****************************
-* Fast dictionary API
-****************************/
+/**********************************
+ * Bulk processing dictionary API
+ *********************************/
typedef struct ZSTD_CDict_s ZSTD_CDict;
/*! ZSTD_createCDict() :
-* When compressing multiple messages / blocks with the same dictionary, it's recommended to load it just once.
-* ZSTD_createCDict() will create a digested dictionary, ready to start future compression operations without startup delay.
-* ZSTD_CDict can be created once and used by multiple threads concurrently, as its usage is read-only.
-* `dictBuffer` can be released after ZSTD_CDict creation, as its content is copied within CDict */
-ZSTDLIB_API ZSTD_CDict* ZSTD_createCDict(const void* dictBuffer, size_t dictSize, int compressionLevel);
+ * When compressing multiple messages / blocks with the same dictionary, it's recommended to load it just once.
+ * ZSTD_createCDict() will create a digested dictionary, ready to start future compression operations without startup delay.
+ * ZSTD_CDict can be created once and shared by multiple threads concurrently, since its usage is read-only.
+ * `dictBuffer` can be released after ZSTD_CDict creation, since its content is copied within CDict */
+ZSTDLIB_API ZSTD_CDict* ZSTD_createCDict(const void* dictBuffer, size_t dictSize,
+ int compressionLevel);
/*! ZSTD_freeCDict() :
-* Function frees memory allocated by ZSTD_createCDict(). */
+ * Function frees memory allocated by ZSTD_createCDict(). */
ZSTDLIB_API size_t ZSTD_freeCDict(ZSTD_CDict* CDict);
/*! ZSTD_compress_usingCDict() :
@@ -207,17 +228,17 @@ ZSTDLIB_API size_t ZSTD_compress_usingCDict(ZSTD_CCtx* cctx,
typedef struct ZSTD_DDict_s ZSTD_DDict;
/*! ZSTD_createDDict() :
-* Create a digested dictionary, ready to start decompression operation without startup delay.
-* dictBuffer can be released after DDict creation, as its content is copied inside DDict */
+ * Create a digested dictionary, ready to start decompression operation without startup delay.
+ * dictBuffer can be released after DDict creation, as its content is copied inside DDict */
ZSTDLIB_API ZSTD_DDict* ZSTD_createDDict(const void* dictBuffer, size_t dictSize);
/*! ZSTD_freeDDict() :
-* Function frees memory allocated with ZSTD_createDDict() */
+ * Function frees memory allocated with ZSTD_createDDict() */
ZSTDLIB_API size_t ZSTD_freeDDict(ZSTD_DDict* ddict);
/*! ZSTD_decompress_usingDDict() :
-* Decompression using a digested Dictionary.
-* Faster startup than ZSTD_decompress_usingDict(), recommended when same dictionary is used multiple times. */
+ * Decompression using a digested Dictionary.
+ * Faster startup than ZSTD_decompress_usingDict(), recommended when same dictionary is used multiple times. */
ZSTDLIB_API size_t ZSTD_decompress_usingDDict(ZSTD_DCtx* dctx,
void* dst, size_t dstCapacity,
const void* src, size_t srcSize,
@@ -274,14 +295,17 @@ typedef struct ZSTD_outBuffer_s {
* ZSTD_endStream() instructs to finish a frame.
* It will perform a flush and write frame epilogue.
* The epilogue is required for decoders to consider a frame completed.
-* Similar to ZSTD_flushStream(), it may not be able to flush the full content if `output->size` is too small.
+* ZSTD_endStream() may not be able to flush full data if `output->size` is too small.
* In which case, call again ZSTD_endStream() to complete the flush.
-* @return : nb of bytes still present within internal buffer (0 if it's empty, hence compression completed)
+* @return : 0 if frame fully completed and fully flushed,
+ or >0 if some data is still present within internal buffer
+ (value is minimum size estimation for remaining data to flush, but it could be more)
* or an error code, which can be tested using ZSTD_isError().
*
* *******************************************************************/
-typedef struct ZSTD_CStream_s ZSTD_CStream;
+typedef ZSTD_CCtx ZSTD_CStream; /**< CCtx and CStream are now effectively same object (>= v1.3.0) */
+ /* Continue to distinguish them for compatibility with versions <= v1.2.0 */
/*===== ZSTD_CStream management functions =====*/
ZSTDLIB_API ZSTD_CStream* ZSTD_createCStream(void);
ZSTDLIB_API size_t ZSTD_freeCStream(ZSTD_CStream* zcs);
@@ -319,7 +343,8 @@ ZSTDLIB_API size_t ZSTD_CStreamOutSize(void); /**< recommended size for output
* The return value is a suggested next input size (a hint to improve latency) that will never load more than the current frame.
* *******************************************************************************/
-typedef struct ZSTD_DStream_s ZSTD_DStream;
+typedef ZSTD_DCtx ZSTD_DStream; /**< DCtx and DStream are now effectively same object (>= v1.3.0) */
+ /* Continue to distinguish them for compatibility with versions <= v1.2.0 */
/*===== ZSTD_DStream management functions =====*/
ZSTDLIB_API ZSTD_DStream* ZSTD_createDStream(void);
ZSTDLIB_API size_t ZSTD_freeDStream(ZSTD_DStream* zds);
@@ -334,23 +359,22 @@ ZSTDLIB_API size_t ZSTD_DStreamOutSize(void); /*!< recommended size for output
#endif /* ZSTD_H_235446 */
-#if defined(ZSTD_STATIC_LINKING_ONLY) && !defined(ZSTD_H_ZSTD_STATIC_LINKING_ONLY)
-#define ZSTD_H_ZSTD_STATIC_LINKING_ONLY
/****************************************************************************************
* START OF ADVANCED AND EXPERIMENTAL FUNCTIONS
* The definitions in this section are considered experimental.
- * They should never be used with a dynamic library, as they may change in the future.
- * They are provided for advanced usages.
+ * They should never be used with a dynamic library, as prototypes may change in the future.
+ * They are provided for advanced scenarios.
* Use them only in association with static linking.
* ***************************************************************************************/
+#if defined(ZSTD_STATIC_LINKING_ONLY) && !defined(ZSTD_H_ZSTD_STATIC_LINKING_ONLY)
+#define ZSTD_H_ZSTD_STATIC_LINKING_ONLY
+
/* --- Constants ---*/
#define ZSTD_MAGICNUMBER 0xFD2FB528 /* >= v0.8.0 */
#define ZSTD_MAGIC_SKIPPABLE_START 0x184D2A50U
-
-#define ZSTD_CONTENTSIZE_UNKNOWN (0ULL - 1)
-#define ZSTD_CONTENTSIZE_ERROR (0ULL - 2)
+#define ZSTD_MAGIC_DICTIONARY 0xEC30A437 /* v0.7+ */
#define ZSTD_WINDOWLOG_MAX_32 27
#define ZSTD_WINDOWLOG_MAX_64 27
@@ -370,14 +394,15 @@ ZSTDLIB_API size_t ZSTD_DStreamOutSize(void); /*!< recommended size for output
#define ZSTD_FRAMEHEADERSIZE_MAX 18 /* for static allocation */
#define ZSTD_FRAMEHEADERSIZE_MIN 6
-static const size_t ZSTD_frameHeaderSize_prefix = 5;
-static const size_t ZSTD_frameHeaderSize_min = ZSTD_FRAMEHEADERSIZE_MIN;
+static const size_t ZSTD_frameHeaderSize_prefix = 5; /* minimum input size to know frame header size */
static const size_t ZSTD_frameHeaderSize_max = ZSTD_FRAMEHEADERSIZE_MAX;
+static const size_t ZSTD_frameHeaderSize_min = ZSTD_FRAMEHEADERSIZE_MIN;
static const size_t ZSTD_skippableHeaderSize = 8; /* magic number + skippable frame length */
/*--- Advanced types ---*/
-typedef enum { ZSTD_fast, ZSTD_dfast, ZSTD_greedy, ZSTD_lazy, ZSTD_lazy2, ZSTD_btlazy2, ZSTD_btopt, ZSTD_btopt2 } ZSTD_strategy; /* from faster to stronger */
+typedef enum { ZSTD_fast=1, ZSTD_dfast, ZSTD_greedy, ZSTD_lazy, ZSTD_lazy2,
+ ZSTD_btlazy2, ZSTD_btopt, ZSTD_btultra } ZSTD_strategy; /* from faster to stronger */
typedef struct {
unsigned windowLog; /**< largest match distance : larger == more compression, more memory needed during decompression */
@@ -400,76 +425,141 @@ typedef struct {
ZSTD_frameParameters fParams;
} ZSTD_parameters;
+typedef struct {
+ unsigned long long frameContentSize;
+ size_t windowSize;
+ unsigned dictID;
+ unsigned checksumFlag;
+} ZSTD_frameHeader;
+
/*= Custom memory allocation functions */
typedef void* (*ZSTD_allocFunction) (void* opaque, size_t size);
typedef void (*ZSTD_freeFunction) (void* opaque, void* address);
typedef struct { ZSTD_allocFunction customAlloc; ZSTD_freeFunction customFree; void* opaque; } ZSTD_customMem;
+/* use this constant to defer to stdlib's functions */
+static const ZSTD_customMem ZSTD_defaultCMem = { NULL, NULL, NULL };
+
/***************************************
-* Compressed size functions
+* Frame size functions
***************************************/
/*! ZSTD_findFrameCompressedSize() :
* `src` should point to the start of a ZSTD encoded frame or skippable frame
* `srcSize` must be at least as large as the frame
- * @return : the compressed size of the frame pointed to by `src`, suitable to pass to
- * `ZSTD_decompress` or similar, or an error code if given invalid input. */
+ * @return : the compressed size of the first frame starting at `src`,
+ * suitable to pass to `ZSTD_decompress` or similar,
+ * or an error code if input is invalid */
ZSTDLIB_API size_t ZSTD_findFrameCompressedSize(const void* src, size_t srcSize);
+/*! ZSTD_findDecompressedSize() :
+ * `src` should point the start of a series of ZSTD encoded and/or skippable frames
+ * `srcSize` must be the _exact_ size of this series
+ * (i.e. there should be a frame boundary exactly at `srcSize` bytes after `src`)
+ * @return : - decompressed size of all data in all successive frames
+ * - if the decompressed size cannot be determined: ZSTD_CONTENTSIZE_UNKNOWN
+ * - if an error occurred: ZSTD_CONTENTSIZE_ERROR
+ *
+ * note 1 : decompressed size is an optional field, that may not be present, especially in streaming mode.
+ * When `return==ZSTD_CONTENTSIZE_UNKNOWN`, data to decompress could be any size.
+ * In which case, it's necessary to use streaming mode to decompress data.
+ * note 2 : decompressed size is always present when compression is done with ZSTD_compress()
+ * note 3 : decompressed size can be very large (64-bits value),
+ * potentially larger than what local system can handle as a single memory segment.
+ * In which case, it's necessary to use streaming mode to decompress data.
+ * note 4 : If source is untrusted, decompressed size could be wrong or intentionally modified.
+ * Always ensure result fits within application's authorized limits.
+ * Each application can set its own limits.
+ * note 5 : ZSTD_findDecompressedSize handles multiple frames, and so it must traverse the input to
+ * read each contained frame header. This is fast as most of the data is skipped,
+ * however it does mean that all frame data must be present and valid. */
+ZSTDLIB_API unsigned long long ZSTD_findDecompressedSize(const void* src, size_t srcSize);
+
+/*! ZSTD_frameHeaderSize() :
+* `src` should point to the start of a ZSTD frame
+* `srcSize` must be >= ZSTD_frameHeaderSize_prefix.
+* @return : size of the Frame Header */
+ZSTDLIB_API size_t ZSTD_frameHeaderSize(const void* src, size_t srcSize);
+
+
/***************************************
-* Decompressed size functions
+* Context memory usage
***************************************/
-/*! ZSTD_getFrameContentSize() :
-* `src` should point to the start of a ZSTD encoded frame
-* `srcSize` must be at least as large as the frame header. A value greater than or equal
-* to `ZSTD_frameHeaderSize_max` is guaranteed to be large enough in all cases.
-* @return : decompressed size of the frame pointed to be `src` if known, otherwise
-* - ZSTD_CONTENTSIZE_UNKNOWN if the size cannot be determined
-* - ZSTD_CONTENTSIZE_ERROR if an error occurred (e.g. invalid magic number, srcSize too small) */
-ZSTDLIB_API unsigned long long ZSTD_getFrameContentSize(const void *src, size_t srcSize);
-/*! ZSTD_findDecompressedSize() :
-* `src` should point the start of a series of ZSTD encoded and/or skippable frames
-* `srcSize` must be the _exact_ size of this series
-* (i.e. there should be a frame boundary exactly `srcSize` bytes after `src`)
-* @return : the decompressed size of all data in the contained frames, as a 64-bit value _if known_
-* - if the decompressed size cannot be determined: ZSTD_CONTENTSIZE_UNKNOWN
-* - if an error occurred: ZSTD_CONTENTSIZE_ERROR
-*
-* note 1 : decompressed size is an optional field, that may not be present, especially in streaming mode.
-* When `return==ZSTD_CONTENTSIZE_UNKNOWN`, data to decompress could be any size.
-* In which case, it's necessary to use streaming mode to decompress data.
-* Optionally, application can still use ZSTD_decompress() while relying on implied limits.
-* (For example, data may be necessarily cut into blocks <= 16 KB).
-* note 2 : decompressed size is always present when compression is done with ZSTD_compress()
-* note 3 : decompressed size can be very large (64-bits value),
-* potentially larger than what local system can handle as a single memory segment.
-* In which case, it's necessary to use streaming mode to decompress data.
-* note 4 : If source is untrusted, decompressed size could be wrong or intentionally modified.
-* Always ensure result fits within application's authorized limits.
-* Each application can set its own limits.
-* note 5 : ZSTD_findDecompressedSize handles multiple frames, and so it must traverse the input to
-* read each contained frame header. This is efficient as most of the data is skipped,
-* however it does mean that all frame data must be present and valid. */
-ZSTDLIB_API unsigned long long ZSTD_findDecompressedSize(const void* src, size_t srcSize);
+/*! ZSTD_sizeof_*() :
+ * These functions give the current memory usage of selected object.
+ * Object memory usage can evolve if it's re-used multiple times. */
+ZSTDLIB_API size_t ZSTD_sizeof_CCtx(const ZSTD_CCtx* cctx);
+ZSTDLIB_API size_t ZSTD_sizeof_DCtx(const ZSTD_DCtx* dctx);
+ZSTDLIB_API size_t ZSTD_sizeof_CStream(const ZSTD_CStream* zcs);
+ZSTDLIB_API size_t ZSTD_sizeof_DStream(const ZSTD_DStream* zds);
+ZSTDLIB_API size_t ZSTD_sizeof_CDict(const ZSTD_CDict* cdict);
+ZSTDLIB_API size_t ZSTD_sizeof_DDict(const ZSTD_DDict* ddict);
+
+/*! ZSTD_estimate*() :
+ * These functions make it possible to estimate memory usage
+ * of a future {D,C}Ctx, before its creation.
+ * ZSTD_estimateCCtxSize() will provide a budget large enough for any compression level up to selected one.
+ * It will also consider src size to be arbitrarily "large", which is worst case.
+ * If srcSize is known to always be small, ZSTD_estimateCCtxSize_advanced() can provide a tighter estimation.
+ * ZSTD_estimateCCtxSize_advanced() can be used in tandem with ZSTD_getCParams() to create cParams from compressionLevel.
+ * Note : CCtx estimation is only correct for single-threaded compression */
+ZSTDLIB_API size_t ZSTD_estimateCCtxSize(int compressionLevel);
+ZSTDLIB_API size_t ZSTD_estimateCCtxSize_advanced(ZSTD_compressionParameters cParams);
+ZSTDLIB_API size_t ZSTD_estimateDCtxSize(void);
+
+/*! ZSTD_estimate?StreamSize() :
+ * ZSTD_estimateCStreamSize() will provide a budget large enough for any compression level up to selected one.
+ * It will also consider src size to be arbitrarily "large", which is worst case.
+ * If srcSize is known to always be small, ZSTD_estimateCStreamSize_advanced() can provide a tighter estimation.
+ * ZSTD_estimateCStreamSize_advanced() can be used in tandem with ZSTD_getCParams() to create cParams from compressionLevel.
+ * Note : CStream estimation is only correct for single-threaded compression.
+ * ZSTD_DStream memory budget depends on window Size.
+ * This information can be passed manually, using ZSTD_estimateDStreamSize,
+ * or deducted from a valid frame Header, using ZSTD_estimateDStreamSize_fromFrame();
+ * Note : if streaming is init with function ZSTD_init?Stream_usingDict(),
+ * an internal ?Dict will be created, which additional size is not estimated here.
+ * In this case, get total size by adding ZSTD_estimate?DictSize */
+ZSTDLIB_API size_t ZSTD_estimateCStreamSize(int compressionLevel);
+ZSTDLIB_API size_t ZSTD_estimateCStreamSize_advanced(ZSTD_compressionParameters cParams);
+ZSTDLIB_API size_t ZSTD_estimateDStreamSize(size_t windowSize);
+ZSTDLIB_API size_t ZSTD_estimateDStreamSize_fromFrame(const void* src, size_t srcSize);
+
+/*! ZSTD_estimate?DictSize() :
+ * ZSTD_estimateCDictSize() will bet that src size is relatively "small", and content is copied, like ZSTD_createCDict().
+ * ZSTD_estimateCStreamSize_advanced() makes it possible to control precisely compression parameters, like ZSTD_createCDict_advanced().
+ * Note : dictionary created "byReference" are smaller */
+ZSTDLIB_API size_t ZSTD_estimateCDictSize(size_t dictSize, int compressionLevel);
+ZSTDLIB_API size_t ZSTD_estimateCDictSize_advanced(size_t dictSize, ZSTD_compressionParameters cParams, unsigned byReference);
+ZSTDLIB_API size_t ZSTD_estimateDDictSize(size_t dictSize, unsigned byReference);
/***************************************
* Advanced compression functions
***************************************/
-/*! ZSTD_estimateCCtxSize() :
- * Gives the amount of memory allocated for a ZSTD_CCtx given a set of compression parameters.
- * `frameContentSize` is an optional parameter, provide `0` if unknown */
-ZSTDLIB_API size_t ZSTD_estimateCCtxSize(ZSTD_compressionParameters cParams);
-
/*! ZSTD_createCCtx_advanced() :
* Create a ZSTD compression context using external alloc and free functions */
ZSTDLIB_API ZSTD_CCtx* ZSTD_createCCtx_advanced(ZSTD_customMem customMem);
-/*! ZSTD_sizeofCCtx() :
- * Gives the amount of memory used by a given ZSTD_CCtx */
-ZSTDLIB_API size_t ZSTD_sizeof_CCtx(const ZSTD_CCtx* cctx);
+/*! ZSTD_initStaticCCtx() : initialize a fixed-size zstd compression context
+ * workspace: The memory area to emplace the context into.
+ * Provided pointer must 8-bytes aligned.
+ * It must outlive context usage.
+ * workspaceSize: Use ZSTD_estimateCCtxSize() or ZSTD_estimateCStreamSize()
+ * to determine how large workspace must be to support scenario.
+ * @return : pointer to ZSTD_CCtx*, or NULL if error (size too small)
+ * Note : zstd will never resize nor malloc() when using a static cctx.
+ * If it needs more memory than available, it will simply error out.
+ * Note 2 : there is no corresponding "free" function.
+ * Since workspace was allocated externally, it must be freed externally too.
+ * Limitation 1 : currently not compatible with internal CDict creation, such as
+ * ZSTD_CCtx_loadDictionary() or ZSTD_initCStream_usingDict().
+ * Limitation 2 : currently not compatible with multi-threading
+ */
+ZSTDLIB_API ZSTD_CCtx* ZSTD_initStaticCCtx(void* workspace, size_t workspaceSize);
+
+/* !!! To be deprecated !!! */
typedef enum {
ZSTD_p_forceWindow, /* Force back-references to remain < windowSize, even when referencing Dictionary content (default:0) */
ZSTD_p_forceRawDict /* Force loading dictionary in "content-only" mode (no header analysis) */
@@ -479,20 +569,43 @@ typedef enum {
* @result : 0, or an error code (which can be tested with ZSTD_isError()) */
ZSTDLIB_API size_t ZSTD_setCCtxParameter(ZSTD_CCtx* cctx, ZSTD_CCtxParameter param, unsigned value);
+
/*! ZSTD_createCDict_byReference() :
* Create a digested dictionary for compression
* Dictionary content is simply referenced, and therefore stays in dictBuffer.
* It is important that dictBuffer outlives CDict, it must remain read accessible throughout the lifetime of CDict */
ZSTDLIB_API ZSTD_CDict* ZSTD_createCDict_byReference(const void* dictBuffer, size_t dictSize, int compressionLevel);
+
+typedef enum { ZSTD_dm_auto=0, /* dictionary is "full" if it starts with ZSTD_MAGIC_DICTIONARY, otherwise it is "rawContent" */
+ ZSTD_dm_rawContent, /* ensures dictionary is always loaded as rawContent, even if it starts with ZSTD_MAGIC_DICTIONARY */
+ ZSTD_dm_fullDict /* refuses to load a dictionary if it does not respect Zstandard's specification */
+} ZSTD_dictMode_e;
/*! ZSTD_createCDict_advanced() :
* Create a ZSTD_CDict using external alloc and free, and customized compression parameters */
-ZSTDLIB_API ZSTD_CDict* ZSTD_createCDict_advanced(const void* dict, size_t dictSize, unsigned byReference,
- ZSTD_compressionParameters cParams, ZSTD_customMem customMem);
-
-/*! ZSTD_sizeof_CDict() :
- * Gives the amount of memory used by a given ZSTD_sizeof_CDict */
-ZSTDLIB_API size_t ZSTD_sizeof_CDict(const ZSTD_CDict* cdict);
+ZSTDLIB_API ZSTD_CDict* ZSTD_createCDict_advanced(const void* dict, size_t dictSize,
+ unsigned byReference, ZSTD_dictMode_e dictMode,
+ ZSTD_compressionParameters cParams,
+ ZSTD_customMem customMem);
+
+/*! ZSTD_initStaticCDict_advanced() :
+ * Generate a digested dictionary in provided memory area.
+ * workspace: The memory area to emplace the dictionary into.
+ * Provided pointer must 8-bytes aligned.
+ * It must outlive dictionary usage.
+ * workspaceSize: Use ZSTD_estimateCDictSize()
+ * to determine how large workspace must be.
+ * cParams : use ZSTD_getCParams() to transform a compression level
+ * into its relevants cParams.
+ * @return : pointer to ZSTD_CDict*, or NULL if error (size too small)
+ * Note : there is no corresponding "free" function.
+ * Since workspace was allocated externally, it must be freed externally.
+ */
+ZSTDLIB_API ZSTD_CDict* ZSTD_initStaticCDict(
+ void* workspace, size_t workspaceSize,
+ const void* dict, size_t dictSize,
+ unsigned byReference, ZSTD_dictMode_e dictMode,
+ ZSTD_compressionParameters cParams);
/*! ZSTD_getCParams() :
* @return ZSTD_compressionParameters structure for a selected compression level and estimated srcSize.
@@ -509,8 +622,8 @@ ZSTDLIB_API ZSTD_parameters ZSTD_getParams(int compressionLevel, unsigned long l
ZSTDLIB_API size_t ZSTD_checkCParams(ZSTD_compressionParameters params);
/*! ZSTD_adjustCParams() :
-* optimize params for a given `srcSize` and `dictSize`.
-* both values are optional, select `0` if unknown. */
+ * optimize params for a given `srcSize` and `dictSize`.
+ * both values are optional, select `0` if unknown. */
ZSTDLIB_API ZSTD_compressionParameters ZSTD_adjustCParams(ZSTD_compressionParameters cPar, unsigned long long srcSize, size_t dictSize);
/*! ZSTD_compress_advanced() :
@@ -538,22 +651,32 @@ ZSTDLIB_API size_t ZSTD_compress_usingCDict_advanced(ZSTD_CCtx* cctx,
* Note 3 : Skippable Frame Identifiers are considered valid. */
ZSTDLIB_API unsigned ZSTD_isFrame(const void* buffer, size_t size);
-/*! ZSTD_estimateDCtxSize() :
- * Gives the potential amount of memory allocated to create a ZSTD_DCtx */
-ZSTDLIB_API size_t ZSTD_estimateDCtxSize(void);
-
/*! ZSTD_createDCtx_advanced() :
* Create a ZSTD decompression context using external alloc and free functions */
ZSTDLIB_API ZSTD_DCtx* ZSTD_createDCtx_advanced(ZSTD_customMem customMem);
-/*! ZSTD_sizeof_DCtx() :
- * Gives the amount of memory used by a given ZSTD_DCtx */
-ZSTDLIB_API size_t ZSTD_sizeof_DCtx(const ZSTD_DCtx* dctx);
+/*! ZSTD_initStaticDCtx() : initialize a fixed-size zstd decompression context
+ * workspace: The memory area to emplace the context into.
+ * Provided pointer must 8-bytes aligned.
+ * It must outlive context usage.
+ * workspaceSize: Use ZSTD_estimateDCtxSize() or ZSTD_estimateDStreamSize()
+ * to determine how large workspace must be to support scenario.
+ * @return : pointer to ZSTD_DCtx*, or NULL if error (size too small)
+ * Note : zstd will never resize nor malloc() when using a static dctx.
+ * If it needs more memory than available, it will simply error out.
+ * Note 2 : static dctx is incompatible with legacy support
+ * Note 3 : there is no corresponding "free" function.
+ * Since workspace was allocated externally, it must be freed externally.
+ * Limitation : currently not compatible with internal DDict creation,
+ * such as ZSTD_initDStream_usingDict().
+ */
+ZSTDLIB_API ZSTD_DCtx* ZSTD_initStaticDCtx(void* workspace, size_t workspaceSize);
/*! ZSTD_createDDict_byReference() :
* Create a digested dictionary, ready to start decompression operation without startup delay.
- * Dictionary content is simply referenced, and therefore stays in dictBuffer.
- * It is important that dictBuffer outlives DDict, it must remain read accessible throughout the lifetime of DDict */
+ * Dictionary content is referenced, and therefore stays in dictBuffer.
+ * It is important that dictBuffer outlives DDict,
+ * it must remain read accessible throughout the lifetime of DDict */
ZSTDLIB_API ZSTD_DDict* ZSTD_createDDict_byReference(const void* dictBuffer, size_t dictSize);
/*! ZSTD_createDDict_advanced() :
@@ -561,9 +684,20 @@ ZSTDLIB_API ZSTD_DDict* ZSTD_createDDict_byReference(const void* dictBuffer, siz
ZSTDLIB_API ZSTD_DDict* ZSTD_createDDict_advanced(const void* dict, size_t dictSize,
unsigned byReference, ZSTD_customMem customMem);
-/*! ZSTD_sizeof_DDict() :
- * Gives the amount of memory used by a given ZSTD_DDict */
-ZSTDLIB_API size_t ZSTD_sizeof_DDict(const ZSTD_DDict* ddict);
+/*! ZSTD_initStaticDDict() :
+ * Generate a digested dictionary in provided memory area.
+ * workspace: The memory area to emplace the dictionary into.
+ * Provided pointer must 8-bytes aligned.
+ * It must outlive dictionary usage.
+ * workspaceSize: Use ZSTD_estimateDDictSize()
+ * to determine how large workspace must be.
+ * @return : pointer to ZSTD_DDict*, or NULL if error (size too small)
+ * Note : there is no corresponding "free" function.
+ * Since workspace was allocated externally, it must be freed externally.
+ */
+ZSTDLIB_API ZSTD_DDict* ZSTD_initStaticDDict(void* workspace, size_t workspaceSize,
+ const void* dict, size_t dictSize,
+ unsigned byReference);
/*! ZSTD_getDictID_fromDict() :
* Provides the dictID stored within dictionary.
@@ -586,7 +720,7 @@ ZSTDLIB_API unsigned ZSTD_getDictID_fromDDict(const ZSTD_DDict* ddict);
* Note : this use case also happens when using a non-conformant dictionary.
* - `srcSize` is too small, and as a result, the frame header could not be decoded (only possible if `srcSize < ZSTD_FRAMEHEADERSIZE_MAX`).
* - This is not a Zstandard frame.
- * When identifying the exact failure cause, it's possible to use ZSTD_getFrameParams(), which will provide a more precise error code. */
+ * When identifying the exact failure cause, it's possible to use ZSTD_getFrameHeader(), which will provide a more precise error code. */
ZSTDLIB_API unsigned ZSTD_getDictID_fromFrame(const void* src, size_t srcSize);
@@ -596,13 +730,13 @@ ZSTDLIB_API unsigned ZSTD_getDictID_fromFrame(const void* src, size_t srcSize);
/*===== Advanced Streaming compression functions =====*/
ZSTDLIB_API ZSTD_CStream* ZSTD_createCStream_advanced(ZSTD_customMem customMem);
-ZSTDLIB_API size_t ZSTD_sizeof_CStream(const ZSTD_CStream* zcs); /**< size of CStream is variable, depending primarily on compression level */
+ZSTDLIB_API ZSTD_CStream* ZSTD_initStaticCStream(void* workspace, size_t workspaceSize); /**< same as ZSTD_initStaticCCtx() */
ZSTDLIB_API size_t ZSTD_initCStream_srcSize(ZSTD_CStream* zcs, int compressionLevel, unsigned long long pledgedSrcSize); /**< pledgedSrcSize must be correct, a size of 0 means unknown. for a frame size of 0 use initCStream_advanced */
-ZSTDLIB_API size_t ZSTD_initCStream_usingDict(ZSTD_CStream* zcs, const void* dict, size_t dictSize, int compressionLevel); /**< note: a dict will not be used if dict == NULL or dictSize < 8 */
+ZSTDLIB_API size_t ZSTD_initCStream_usingDict(ZSTD_CStream* zcs, const void* dict, size_t dictSize, int compressionLevel); /**< creates of an internal CDict (incompatible with static CCtx), except if dict == NULL or dictSize < 8, in which case no dict is used. */
ZSTDLIB_API size_t ZSTD_initCStream_advanced(ZSTD_CStream* zcs, const void* dict, size_t dictSize,
ZSTD_parameters params, unsigned long long pledgedSrcSize); /**< pledgedSrcSize is optional and can be 0 (meaning unknown). note: if the contentSizeFlag is set, pledgedSrcSize == 0 means the source size is actually 0 */
ZSTDLIB_API size_t ZSTD_initCStream_usingCDict(ZSTD_CStream* zcs, const ZSTD_CDict* cdict); /**< note : cdict will just be referenced, and must outlive compression session */
-ZSTDLIB_API size_t ZSTD_initCStream_usingCDict_advanced(ZSTD_CStream* zcs, const ZSTD_CDict* cdict, unsigned long long pledgedSrcSize, ZSTD_frameParameters fParams); /**< same as ZSTD_initCStream_usingCDict(), with control over frame parameters */
+ZSTDLIB_API size_t ZSTD_initCStream_usingCDict_advanced(ZSTD_CStream* zcs, const ZSTD_CDict* cdict, ZSTD_frameParameters fParams, unsigned long long pledgedSrcSize); /**< same as ZSTD_initCStream_usingCDict(), with control over frame parameters */
/*! ZSTD_resetCStream() :
* start a new compression job, using same parameters from previous job.
@@ -617,11 +751,11 @@ ZSTDLIB_API size_t ZSTD_resetCStream(ZSTD_CStream* zcs, unsigned long long pledg
/*===== Advanced Streaming decompression functions =====*/
typedef enum { DStream_p_maxWindowSize } ZSTD_DStreamParameter_e;
ZSTDLIB_API ZSTD_DStream* ZSTD_createDStream_advanced(ZSTD_customMem customMem);
-ZSTDLIB_API size_t ZSTD_initDStream_usingDict(ZSTD_DStream* zds, const void* dict, size_t dictSize); /**< note: a dict will not be used if dict == NULL or dictSize < 8 */
+ZSTDLIB_API ZSTD_DStream* ZSTD_initStaticDStream(void* workspace, size_t workspaceSize); /**< same as ZSTD_initStaticDCtx() */
ZSTDLIB_API size_t ZSTD_setDStreamParameter(ZSTD_DStream* zds, ZSTD_DStreamParameter_e paramType, unsigned paramValue);
+ZSTDLIB_API size_t ZSTD_initDStream_usingDict(ZSTD_DStream* zds, const void* dict, size_t dictSize); /**< note: a dict will not be used if dict == NULL or dictSize < 8 */
ZSTDLIB_API size_t ZSTD_initDStream_usingDDict(ZSTD_DStream* zds, const ZSTD_DDict* ddict); /**< note : ddict will just be referenced, and must outlive decompression session */
ZSTDLIB_API size_t ZSTD_resetDStream(ZSTD_DStream* zds); /**< re-use decompression parameters from previous init; saves dictionary loading */
-ZSTDLIB_API size_t ZSTD_sizeof_DStream(const ZSTD_DStream* zds);
/*********************************************************************
@@ -683,21 +817,24 @@ ZSTDLIB_API size_t ZSTD_compressEnd(ZSTD_CCtx* cctx, void* dst, size_t dstCapaci
Use ZSTD_createDCtx() / ZSTD_freeDCtx() to manage it.
A ZSTD_DCtx object can be re-used multiple times.
- First typical operation is to retrieve frame parameters, using ZSTD_getFrameParams().
- It fills a ZSTD_frameParams structure which provide important information to correctly decode the frame,
- such as the minimum rolling buffer size to allocate to decompress data (`windowSize`),
- and the dictionary ID used.
+ First typical operation is to retrieve frame parameters, using ZSTD_getFrameHeader().
+ It fills a ZSTD_frameHeader structure with important information to correctly decode the frame,
+ such as minimum rolling buffer size to allocate to decompress data (`windowSize`),
+ and the dictionary ID in use.
(Note : content size is optional, it may not be present. 0 means : content size unknown).
Note that these values could be wrong, either because of data malformation, or because an attacker is spoofing deliberate false information.
As a consequence, check that values remain within valid application range, especially `windowSize`, before allocation.
- Each application can set its own limit, depending on local restrictions. For extended interoperability, it is recommended to support at least 8 MB.
- Frame parameters are extracted from the beginning of the compressed frame.
- Data fragment must be large enough to ensure successful decoding, typically `ZSTD_frameHeaderSize_max` bytes.
- @result : 0 : successful decoding, the `ZSTD_frameParams` structure is correctly filled.
+ Each application can set its own limit, depending on local restrictions.
+ For extended interoperability, it is recommended to support windowSize of at least 8 MB.
+ Frame header is extracted from the beginning of compressed frame, so providing only the frame's beginning is enough.
+ Data fragment must be large enough to ensure successful decoding.
+ `ZSTD_frameHeaderSize_max` bytes is guaranteed to always be large enough.
+ @result : 0 : successful decoding, the `ZSTD_frameHeader` structure is correctly filled.
>0 : `srcSize` is too small, please provide at least @result bytes on next attempt.
errorCode, which can be tested using ZSTD_isError().
- Start decompression, with ZSTD_decompressBegin() or ZSTD_decompressBegin_usingDict().
+ Start decompression, with ZSTD_decompressBegin().
+ If decompression requires a dictionary, use ZSTD_decompressBegin_usingDict() or ZSTD_decompressBegin_usingDDict().
Alternatively, you can copy a prepared context, using ZSTD_copyDCtx().
Then use ZSTD_nextSrcSizeToDecompress() and ZSTD_decompressContinue() alternatively.
@@ -729,30 +866,233 @@ ZSTDLIB_API size_t ZSTD_compressEnd(ZSTD_CCtx* cctx, void* dst, size_t dstCapaci
b) Frame Size - 4 Bytes, Little endian format, unsigned 32-bits
c) Frame Content - any content (User Data) of length equal to Frame Size
For skippable frames ZSTD_decompressContinue() always returns 0.
- For skippable frames ZSTD_getFrameParams() returns fparamsPtr->windowLog==0 what means that a frame is skippable.
+ For skippable frames ZSTD_getFrameHeader() returns fparamsPtr->windowLog==0 what means that a frame is skippable.
Note : If fparamsPtr->frameContentSize==0, it is ambiguous: the frame might actually be a Zstd encoded frame with no content.
For purposes of decompression, it is valid in both cases to skip the frame using
ZSTD_findFrameCompressedSize to find its size in bytes.
It also returns Frame Size as fparamsPtr->frameContentSize.
*/
-typedef struct {
- unsigned long long frameContentSize;
- unsigned windowSize;
- unsigned dictID;
- unsigned checksumFlag;
-} ZSTD_frameParams;
-
/*===== Buffer-less streaming decompression functions =====*/
-ZSTDLIB_API size_t ZSTD_getFrameParams(ZSTD_frameParams* fparamsPtr, const void* src, size_t srcSize); /**< doesn't consume input, see details below */
+ZSTDLIB_API size_t ZSTD_getFrameHeader(ZSTD_frameHeader* zfhPtr, const void* src, size_t srcSize); /**< doesn't consume input */
ZSTDLIB_API size_t ZSTD_decompressBegin(ZSTD_DCtx* dctx);
ZSTDLIB_API size_t ZSTD_decompressBegin_usingDict(ZSTD_DCtx* dctx, const void* dict, size_t dictSize);
+ZSTDLIB_API size_t ZSTD_decompressBegin_usingDDict(ZSTD_DCtx* dctx, const ZSTD_DDict* ddict);
ZSTDLIB_API void ZSTD_copyDCtx(ZSTD_DCtx* dctx, const ZSTD_DCtx* preparedDCtx);
+
ZSTDLIB_API size_t ZSTD_nextSrcSizeToDecompress(ZSTD_DCtx* dctx);
ZSTDLIB_API size_t ZSTD_decompressContinue(ZSTD_DCtx* dctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
typedef enum { ZSTDnit_frameHeader, ZSTDnit_blockHeader, ZSTDnit_block, ZSTDnit_lastBlock, ZSTDnit_checksum, ZSTDnit_skippableFrame } ZSTD_nextInputType_e;
ZSTDLIB_API ZSTD_nextInputType_e ZSTD_nextInputType(ZSTD_DCtx* dctx);
+
+
+/*=== New advanced API (experimental, and compression only) ===*/
+
+/* notes on API design :
+ * In this proposal, parameters are pushed one by one into an existing CCtx,
+ * and then applied on all subsequent compression jobs.
+ * When no parameter is ever provided, CCtx is created with compression level ZSTD_CLEVEL_DEFAULT.
+ *
+ * This API is intended to replace all others experimental API.
+ * It can basically do all other use cases, and even new ones.
+ * It stands a good chance to become "stable",
+ * after a reasonable testing period.
+ */
+
+/* note on naming convention :
+ * Initially, the API favored names like ZSTD_setCCtxParameter() .
+ * In this proposal, convention is changed towards ZSTD_CCtx_setParameter() .
+ * The main driver is that it identifies more clearly the target object type.
+ * It feels clearer in light of potential variants :
+ * ZSTD_CDict_setParameter() (rather than ZSTD_setCDictParameter())
+ * ZSTD_DCtx_setParameter() (rather than ZSTD_setDCtxParameter() )
+ * Left variant feels easier to distinguish.
+ */
+
+/* note on enum design :
+ * All enum will be manually set to explicit values before reaching "stable API" status */
+
+typedef enum {
+ /* compression parameters */
+ ZSTD_p_compressionLevel=100, /* Update all compression parameters according to pre-defined cLevel table
+ * Default level is ZSTD_CLEVEL_DEFAULT==3.
+ * Special: value 0 means "do not change cLevel". */
+ ZSTD_p_windowLog, /* Maximum allowed back-reference distance, expressed as power of 2.
+ * Must be clamped between ZSTD_WINDOWLOG_MIN and ZSTD_WINDOWLOG_MAX.
+ * Special: value 0 means "do not change windowLog". */
+ ZSTD_p_hashLog, /* Size of the probe table, as a power of 2.
+ * Resulting table size is (1 << (hashLog+2)).
+ * Must be clamped between ZSTD_HASHLOG_MIN and ZSTD_HASHLOG_MAX.
+ * Larger tables improve compression ratio of strategies <= dFast,
+ * and improve speed of strategies > dFast.
+ * Special: value 0 means "do not change hashLog". */
+ ZSTD_p_chainLog, /* Size of the full-search table, as a power of 2.
+ * Resulting table size is (1 << (chainLog+2)).
+ * Larger tables result in better and slower compression.
+ * This parameter is useless when using "fast" strategy.
+ * Special: value 0 means "do not change chainLog". */
+ ZSTD_p_searchLog, /* Number of search attempts, as a power of 2.
+ * More attempts result in better and slower compression.
+ * This parameter is useless when using "fast" and "dFast" strategies.
+ * Special: value 0 means "do not change searchLog". */
+ ZSTD_p_minMatch, /* Minimum size of searched matches (note : repCode matches can be smaller).
+ * Larger values make faster compression and decompression, but decrease ratio.
+ * Must be clamped between ZSTD_SEARCHLENGTH_MIN and ZSTD_SEARCHLENGTH_MAX.
+ * Note that currently, for all strategies < btopt, effective minimum is 4.
+ * Note that currently, for all strategies > fast, effective maximum is 6.
+ * Special: value 0 means "do not change minMatchLength". */
+ ZSTD_p_targetLength, /* Only useful for strategies >= btopt.
+ * Length of Match considered "good enough" to stop search.
+ * Larger values make compression stronger and slower.
+ * Special: value 0 means "do not change targetLength". */
+ ZSTD_p_compressionStrategy, /* See ZSTD_strategy enum definition.
+ * Cast selected strategy as unsigned for ZSTD_CCtx_setParameter() compatibility.
+ * The higher the value of selected strategy, the more complex it is,
+ * resulting in stronger and slower compression.
+ * Special: value 0 means "do not change strategy". */
+
+ /* frame parameters */
+ ZSTD_p_contentSizeFlag=200, /* Content size is written into frame header _whenever known_ (default:1) */
+ ZSTD_p_checksumFlag, /* A 32-bits checksum of content is written at end of frame (default:0) */
+ ZSTD_p_dictIDFlag, /* When applicable, dictID of dictionary is provided in frame header (default:1) */
+
+ /* dictionary parameters (must be set before ZSTD_CCtx_loadDictionary) */
+ ZSTD_p_dictMode=300, /* Select how dictionary content must be interpreted. Value must be from type ZSTD_dictMode_e.
+ * default : 0==auto : dictionary will be "full" if it respects specification, otherwise it will be "rawContent" */
+ ZSTD_p_refDictContent, /* Dictionary content will be referenced, instead of copied (default:0==byCopy).
+ * It requires that dictionary buffer outlives its users */
+
+ /* multi-threading parameters */
+ ZSTD_p_nbThreads=400, /* Select how many threads a compression job can spawn (default:1)
+ * More threads improve speed, but also increase memory usage.
+ * Can only receive a value > 1 if ZSTD_MULTITHREAD is enabled.
+ * Special: value 0 means "do not change nbThreads" */
+ ZSTD_p_jobSize, /* Size of a compression job. Each compression job is completed in parallel.
+ * 0 means default, which is dynamically determined based on compression parameters.
+ * Job size must be a minimum of overlapSize, or 1 KB, whichever is largest
+ * The minimum size is automatically and transparently enforced */
+ ZSTD_p_overlapSizeLog, /* Size of previous input reloaded at the beginning of each job.
+ * 0 => no overlap, 6(default) => use 1/8th of windowSize, >=9 => use full windowSize */
+
+ /* advanced parameters - may not remain available after API update */
+ ZSTD_p_forceMaxWindow=1100, /* Force back-reference distances to remain < windowSize,
+ * even when referencing into Dictionary content (default:0) */
+
+} ZSTD_cParameter;
+
+
+/*! ZSTD_CCtx_setParameter() :
+ * Set one compression parameter, selected by enum ZSTD_cParameter.
+ * Note : when `value` is an enum, cast it to unsigned for proper type checking.
+ * @result : 0, or an error code (which can be tested with ZSTD_isError()). */
+ZSTDLIB_API size_t ZSTD_CCtx_setParameter(ZSTD_CCtx* cctx, ZSTD_cParameter param, unsigned value);
+
+/*! ZSTD_CCtx_setPledgedSrcSize() :
+ * Total input data size to be compressed as a single frame.
+ * This value will be controlled at the end, and result in error if not respected.
+ * @result : 0, or an error code (which can be tested with ZSTD_isError()).
+ * Note 1 : 0 means zero, empty.
+ * In order to mean "unknown content size", pass constant ZSTD_CONTENTSIZE_UNKNOWN.
+ * Note that ZSTD_CONTENTSIZE_UNKNOWN is default value for new compression jobs.
+ * Note 2 : If all data is provided and consumed in a single round,
+ * this value is overriden by srcSize instead. */
+ZSTDLIB_API size_t ZSTD_CCtx_setPledgedSrcSize(ZSTD_CCtx* cctx, unsigned long long pledgedSrcSize);
+
+/*! ZSTD_CCtx_loadDictionary() :
+ * Create an internal CDict from dict buffer.
+ * Decompression will have to use same buffer.
+ * @result : 0, or an error code (which can be tested with ZSTD_isError()).
+ * Special : Adding a NULL (or 0-size) dictionary invalidates any previous dictionary,
+ * meaning "return to no-dictionary mode".
+ * Note 1 : `dict` content will be copied internally,
+ * except if ZSTD_p_refDictContent is set before loading.
+ * Note 2 : Loading a dictionary involves building tables, which are dependent on compression parameters.
+ * For this reason, compression parameters cannot be changed anymore after loading a dictionary.
+ * It's also a CPU-heavy operation, with non-negligible impact on latency.
+ * Note 3 : Dictionary will be used for all future compression jobs.
+ * To return to "no-dictionary" situation, load a NULL dictionary */
+ZSTDLIB_API size_t ZSTD_CCtx_loadDictionary(ZSTD_CCtx* cctx, const void* dict, size_t dictSize);
+
+/*! ZSTD_CCtx_refCDict() :
+ * Reference a prepared dictionary, to be used for all next compression jobs.
+ * Note that compression parameters are enforced from within CDict,
+ * and supercede any compression parameter previously set within CCtx.
+ * The dictionary will remain valid for future compression jobs using same CCtx.
+ * @result : 0, or an error code (which can be tested with ZSTD_isError()).
+ * Special : adding a NULL CDict means "return to no-dictionary mode".
+ * Note 1 : Currently, only one dictionary can be managed.
+ * Adding a new dictionary effectively "discards" any previous one.
+ * Note 2 : CDict is just referenced, its lifetime must outlive CCtx.
+ */
+ZSTDLIB_API size_t ZSTD_CCtx_refCDict(ZSTD_CCtx* cctx, const ZSTD_CDict* cdict);
+
+/*! ZSTD_CCtx_refPrefix() :
+ * Reference a prefix (single-usage dictionary) for next compression job.
+ * Decompression need same prefix to properly regenerate data.
+ * Prefix is **only used once**. Tables are discarded at end of compression job.
+ * Subsequent compression jobs will be done without prefix (if none is explicitly referenced).
+ * If there is a need to use same prefix multiple times, consider embedding it into a ZSTD_CDict instead.
+ * @result : 0, or an error code (which can be tested with ZSTD_isError()).
+ * Special : Adding any prefix (including NULL) invalidates any previous prefix or dictionary
+ * Note 1 : Prefix buffer is referenced. It must outlive compression job.
+ * Note 2 : Referencing a prefix involves building tables, which are dependent on compression parameters.
+ * It's a CPU-heavy operation, with non-negligible impact on latency.
+ * Note 3 : it's possible to alter ZSTD_p_dictMode using ZSTD_CCtx_setParameter() */
+ZSTDLIB_API size_t ZSTD_CCtx_refPrefix(ZSTD_CCtx* cctx, const void* prefix, size_t prefixSize);
+
+
+
+typedef enum {
+ ZSTD_e_continue=0, /* collect more data, encoder transparently decides when to output result, for optimal conditions */
+ ZSTD_e_flush, /* flush any data provided so far - frame will continue, future data can still reference previous data for better compression */
+ ZSTD_e_end /* flush any remaining data and ends current frame. Any future compression starts a new frame. */
+} ZSTD_EndDirective;
+
+/*! ZSTD_compress_generic() :
+ * Behave about the same as ZSTD_compressStream. To note :
+ * - Compression parameters are pushed into CCtx before starting compression, using ZSTD_CCtx_setParameter()
+ * - Compression parameters cannot be changed once compression is started.
+ * - *dstPos must be <= dstCapacity, *srcPos must be <= srcSize
+ * - *dspPos and *srcPos will be updated. They are guaranteed to remain below their respective limit.
+ * - @return provides the minimum amount of data still to flush from internal buffers
+ * or an error code, which can be tested using ZSTD_isError().
+ * if @return != 0, flush is not fully completed, there is some data left within internal buffers.
+ * - after a ZSTD_e_end directive, if internal buffer is not fully flushed,
+ * only ZSTD_e_end or ZSTD_e_flush operations are allowed.
+ * It is necessary to fully flush internal buffers
+ * before starting a new compression job, or changing compression parameters.
+ */
+ZSTDLIB_API size_t ZSTD_compress_generic (ZSTD_CCtx* cctx,
+ ZSTD_outBuffer* output,
+ ZSTD_inBuffer* input,
+ ZSTD_EndDirective endOp);
+
+/*! ZSTD_CCtx_reset() :
+ * Return a CCtx to clean state.
+ * Useful after an error, or to interrupt an ongoing compression job and start a new one.
+ * Any internal data not yet flushed is cancelled.
+ * Dictionary (if any) is dropped.
+ * It's possible to modify compression parameters after a reset.
+ */
+ZSTDLIB_API void ZSTD_CCtx_reset(ZSTD_CCtx* cctx); /* Not ready yet ! */
+
+
+/*! ZSTD_compress_generic_simpleArgs() :
+ * Same as ZSTD_compress_generic(),
+ * but using only integral types as arguments.
+ * Argument list is larger and less expressive than ZSTD_{in,out}Buffer,
+ * but can be helpful for binders from dynamic languages
+ * which have troubles handling structures containing memory pointers.
+ */
+size_t ZSTD_compress_generic_simpleArgs (
+ ZSTD_CCtx* cctx,
+ void* dst, size_t dstCapacity, size_t* dstPos,
+ const void* src, size_t srcSize, size_t* srcPos,
+ ZSTD_EndDirective endOp);
+
+
+
/**
Block functions
@@ -767,7 +1107,7 @@ ZSTDLIB_API ZSTD_nextInputType_e ZSTD_nextInputType(ZSTD_DCtx* dctx);
+ compression : any ZSTD_compressBegin*() variant, including with dictionary
+ decompression : any ZSTD_decompressBegin*() variant, including with dictionary
+ copyCCtx() and copyDCtx() can be used too
- - Block size is limited, it must be <= ZSTD_getBlockSizeMax() <= ZSTD_BLOCKSIZE_ABSOLUTEMAX
+ - Block size is limited, it must be <= ZSTD_getBlockSize() <= ZSTD_BLOCKSIZE_MAX
+ If input is larger than a block size, it's necessary to split input data into multiple blocks
+ For inputs larger than a single block size, consider using the regular ZSTD_compress() instead.
Frame metadata is not that costly, and quickly becomes negligible as source size grows larger.
@@ -780,9 +1120,10 @@ ZSTDLIB_API ZSTD_nextInputType_e ZSTD_nextInputType(ZSTD_DCtx* dctx);
Use ZSTD_insertBlock() for such a case.
*/
-#define ZSTD_BLOCKSIZE_ABSOLUTEMAX (128 * 1024) /* define, for static allocation */
+#define ZSTD_BLOCKSIZELOG_MAX 17
+#define ZSTD_BLOCKSIZE_MAX (1<<ZSTD_BLOCKSIZELOG_MAX) /* define, for static allocation */
/*===== Raw zstd block functions =====*/
-ZSTDLIB_API size_t ZSTD_getBlockSizeMax(ZSTD_CCtx* cctx);
+ZSTDLIB_API size_t ZSTD_getBlockSize (const ZSTD_CCtx* cctx);
ZSTDLIB_API size_t ZSTD_compressBlock (ZSTD_CCtx* cctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
ZSTDLIB_API size_t ZSTD_decompressBlock(ZSTD_DCtx* dctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
ZSTDLIB_API size_t ZSTD_insertBlock(ZSTD_DCtx* dctx, const void* blockStart, size_t blockSize); /**< insert block into `dctx` history. Useful for uncompressed blocks */